1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
diff --git a/config/__init__.py b/config/__init__.py
index 3f2d1b2..4446f71 100644
--- a/config/__init__.py
+++ b/config/__init__.py
@@ -16,7 +16,7 @@ import ruamel.yaml
yaml = ruamel.yaml.YAML()
bundled = getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS')
-use_state_separation = None
+use_state_separation = True
if bundled:
root = sys._MEIPASS
# FIXME: macOS app bundle outside /Applications
@@ -38,8 +38,15 @@ if use_state_separation is None:
use_state_separation = False
if use_state_separation:
- # TODO: use platform application state directory, copy skeleton
- writable_root = '\0placeholder'
+ system = sys.platform
+ if system == "win32":
+ # TODO: windows user data dir
+ path = ''
+ elif system == 'darwin':
+ path = os.path.expanduser('~/Library/Preferences')
+ else:
+ path = os.getenv('XDG_CONFIG_HOME', os.path.expanduser("~/.config"))
+ writable_root = os.path.join(path, 'ArknightsAutoHelper')
else:
writable_root = root
@@ -52,6 +59,7 @@ extra_items_path = os.path.join(writable_root, 'extra_items')
config_file = os.path.join(CONFIG_PATH, 'config.yaml')
config_template = os.path.join(config_template_path, 'config-template.yaml')
logging_config_file = os.path.join(CONFIG_PATH, 'logging.yaml')
+logging_config_template = os.path.join(config_template_path, 'logging.yaml')
logs = os.path.join(writable_root, 'log')
use_archived_resources = not os.path.isdir(os.path.join(root, 'resources'))
if use_archived_resources:
@@ -62,8 +70,11 @@ else:
resource_archive = None
resource_root = os.path.join(root, 'resources')
-if not os.path.exists(logs):
- os.mkdir(logs)
+os.makedirs(SCREEN_SHOOT_SAVE_PATH, exist_ok=True)
+os.makedirs(CONFIG_PATH, exist_ok=True)
+os.makedirs(cache_path, exist_ok=True)
+os.makedirs(extra_items_path, exist_ok=True)
+os.makedirs(logs, exist_ok=True)
dirty = False
@@ -242,6 +253,8 @@ def enable_logging():
return
get_instance_id()
old_handlers = logging.root.handlers[:]
+ if not os.path.exists(logging_config_file):
+ shutil.copy2(logging_config_template, logging_config_file)
with open(logging_config_file, 'r', encoding='utf-8') as f:
logging.config.dictConfig(yaml.load(f))
for h in old_handlers:
|