From 2eea9b913c1b4b5b97a54b7c62f963371d231f5a Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sat, 1 Aug 2020 16:52:11 +0200 Subject: [PATCH] default to outputting to {local_path}/output * Windows setup has that path as writable by everyone * most others run from source, where the entire source path and children is writable. * People complained about files appearing in My Documents, which admittedly is not intuitive --- Utils.py | 36 ++++-------------------------------- host.yaml | 2 +- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/Utils.py b/Utils.py index 9dfd72e6..708a6b21 100644 --- a/Utils.py +++ b/Utils.py @@ -82,38 +82,10 @@ local_path.cached_path = None def output_path(path): if output_path.cached_path: return os.path.join(output_path.cached_path, path) - - if not is_bundled() and not hasattr(sys, "_MEIPASS"): - # this should trigger if it's cx_freeze bundling - output_path.cached_path = '.' - return os.path.join(output_path.cached_path, path) - else: - # has been PyInstaller packaged, so cannot use CWD for output. - if sys.platform == 'win32': - # windows - import ctypes.wintypes - CSIDL_PERSONAL = 5 # My Documents - SHGFP_TYPE_CURRENT = 0 # Get current, not default value - - buf = ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH) - ctypes.windll.shell32.SHGetFolderPathW(None, CSIDL_PERSONAL, None, SHGFP_TYPE_CURRENT, buf) - - documents = buf.value - - elif sys.platform == 'darwin': - from AppKit import NSSearchPathForDirectoriesInDomains # pylint: disable=import-error - # http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSearchPathForDirectoriesInDomains - NSDocumentDirectory = 9 - NSUserDomainMask = 1 - # True for expanding the tilde into a fully qualified path - documents = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True)[0] - else: - raise NotImplementedError('Not supported yet') - - output_path.cached_path = os.path.join(documents, 'ALttPEntranceRandomizer') - if not os.path.exists(output_path.cached_path): - os.mkdir(output_path.cached_path) - return os.path.join(output_path.cached_path, path) + output_path.cached_path = local_path(os.path.join("output", path)) + path = os.path.join(output_path.cached_path, path) + os.makedirs(os.path.dirname(path), exist_ok=True) + return path output_path.cached_path = None diff --git a/host.yaml b/host.yaml index e771e32e..a9f8b4d6 100644 --- a/host.yaml +++ b/host.yaml @@ -50,7 +50,7 @@ multi_mystery_options: #teams, however, note that there is currently no way to supply names for teams 2+ through MultiMystery teams: 1 #Where to place the resulting files - output_path: "MultiMystery" + output_path: "output" #location of your Enemizer CLI, available here: https://github.com/Bonta0/Enemizer/releases enemizer_path: "EnemizerCLI/EnemizerCLI.Core.exe" #folder from which the player yaml files are pulled from