Skip to content

Commit

Permalink
Merge pull request #4 from BillCipher-exe/experimental
Browse files Browse the repository at this point in the history
updated setup
  • Loading branch information
BillCipher-exe authored Aug 2, 2022
2 parents 6bb6fdc + ae67f08 commit a4df0a4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 55 deletions.
Empty file added .gitignore
Empty file.
Binary file modified __pycache__/db.cpython-310.pyc
Binary file not shown.
20 changes: 3 additions & 17 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@


class DB:
def __init__(self, mysql_config, path, emulator):
def __init__(self, mysql_config, path, emulator, sync_exceptions = []):
try:
self.mysql_config = mysql_config
self.save_path = path
self.emulator = emulator
self.sync_exceptions= sync_exceptions
self.mydb = mysql.connector.connect(
host=mysql_config["host"],
user=mysql_config["user"],
Expand Down Expand Up @@ -65,7 +66,7 @@ def get_info_db(self):
self.mycursor.execute(sql, val)
return self.mycursor.fetchall()

def _sync(self, sync_exceptions = []):
def sync(self):
local_files = support.get_files(self.save_path)
server_files = self.get_info_db()
sync_exceptions = ["/Users/", ]
Expand All @@ -81,18 +82,3 @@ def _sync(self, sync_exceptions = []):
for x in outdated_server:
if(x["subfolder"] not in sync_exceptions):
self.put_file_db(x["filename"], x["mtime"], x["subfolder"])



class Retroarch(DB):
exceptions = ["/Users/", ]
def sync(self):
self._sync(self.exceptions)




class Dolphin_GC(DB):
exceptions = ["/", ]
def sync(self):
self._sync(self.exceptions)
10 changes: 6 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
config.read("config.ini")

if config["path"]["retroarch_saves"] != "none":
retroarch = db.Retroarch(
config["database"], config["path"]["retroarch_saves"], "retroarch")
exceptions = ["/Users/", ]
retroarch = db.DB(
config["database"], config["path"]["retroarch_saves"], "retroarch",exceptions)
retroarch.sync()

if config["path"]["dolphin_gc_saves"] != "none":
dolphin_GC = db.Dolphin_GC(
config["database"], config["path"]["dolphin_gc_saves"], "dolphin_GC")
exceptions = ["/", ]
dolphin_GC = db.DB(
config["database"], config["path"]["dolphin_gc_saves"], "dolphin_GC",exceptions)
dolphin_GC.sync()
54 changes: 20 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ def install(package):
print("ERROR: Could not install Python Package. Check if pip3 is installed")
sys.exit(1)

def add_emulator(emulator, example_path,config_name):
print("Sync "+emulator+" ? (Y/N): ", end=" ")
choice = input()
if choice == "y" or choice == "Y":
while True:
print("Enter full path to Savegame folder ("+example_path+"):", end=" ")
path_input = input()
if path.basename(path_input) == path.basename(example_path) and path.isdir(path_input):
config["path"][config_name] = path_input
break
else:
print("ERROR: Please enter the full path where the "+emulator+" savegames are Located ("+example_path+"). try again (Y/N): ", end=" ")
choice = input()
config["path"][config_name] = "none"
if choice == "n" or choice == "N":
break
else:
config["path"][config_name] = "none"

install("mysql-connector-python")

Expand Down Expand Up @@ -55,40 +73,8 @@ def install(package):

print("-----------------------------Add Savegame Locations-----------------------------")

print("Sync Retroarch? (Y/N): ", end=" ")
choice = input()
if choice == "y" or choice == "Y":
while True:
print("Enter full path to Savegame folder (.../Retroarch/saves):", end=" ")
retroarch_path = input()
if path.basename(retroarch_path) == "saves":
config["path"]["retroarch_saves"] = retroarch_path
break
else:
print("ERROR: Please enter the full path where the Retroarch savegames are Located (.../Retroarch/saves). try again (Y/N): ", end=" ")
choice = input()
config["path"]["retroarch_saves"] = "none"
if choice == "n" or choice == "N":
break
else:
config["path"]["retroarch_saves"] = "none"

print("Sync Dolphin (GameCube)? (Y/N): ", end=" ")
choice = input()
if choice == "y" or choice == "Y":
while True:
print("Enter full path to Savegame folder (.../Dolphin Emulator/GC):", end=" ")
dolpin_gc_path = input()
if path.basename(dolpin_gc_path) == "GC":
config["path"]["dolphin_GC_saves"] = dolpin_gc_path
break
else:
print("unexpected path. Please enter the full path where the Dolphin GC savegames are Located (.../Dolphin Emulator/GC). try again (Y/N): ", end=" ")
config["path"]["dolphin_GC_saves"] = "none"
if choice == "n" or choice == "N":
break
else:
config["path"]["dolphin_GC_saves"] = "none"
add_emulator("Retroarch",".../Retroarch/saves","retroarch_saves")
add_emulator("Dolphin GameCube",".../Dolphin/GC","dolphin_gc_saves")


try:
Expand Down

0 comments on commit a4df0a4

Please sign in to comment.