diff --git a/main.py b/main.py index f02f8c6..c513297 100755 --- a/main.py +++ b/main.py @@ -22,10 +22,12 @@ import pkg_resources from packaging import version +own_dir = os.path.abspath(os.path.dirname(__file__)) + # Set up global variables and the used classes options = {} -hashes = Hashlist("./data/hashes") +hashes = Hashlist(os.path.join(own_dir, "data/hashes")) decoder = Decoder(hashes) encoder = Encoder() savefiles = {} @@ -35,21 +37,21 @@ loaded_items = {} # Load the version number of this application and already create a newversion variable for a later check for updates -with open("./data/version") as f: +with open(os.path.join(own_dir, "data/version")) as f: currentversion = f.read() newversion = currentversion # Load the information about the item version making it possible to fix bugs without having to make a new release # (when no code was changed) -with open("./data/itemversion") as f: +with open(os.path.join(own_dir, "data/itemversion")) as f: currentiversion = f.read() newiversion = currentiversion # Load the settings of the settings file def load_settings(): - with open("./data/settings") as f: + with open(os.path.join("data/settings")) as f: global options, newversion, newiversion, web_app_options options = json.load(f) @@ -357,7 +359,7 @@ def save_json_savefile(data, shash): # If we want to dump it as html file we do so here if file.endswith(".html"): - with open('./data/html/dumpskeleton.html', 'r') as placeholderfile: + with open(os.path.join(own_dir, 'data/html/dumpskeleton.html'), 'r') as placeholderfile: placeholder = placeholderfile.read() print("Creating HTML file at " + file) @@ -1035,7 +1037,7 @@ def set_settings(settings): if "path" in options: options["path"] = os.path.expandvars(options["path"]) - with open("./data/settings", "w") as f: + with open(os.path.join(own_dir, "data/settings"), "w") as f: json.dump(settings, f) return True