wdcqc commited on
Commit
7d31175
1 Parent(s): fdf60dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -5,15 +5,20 @@ import argparse
5
  import os
6
  import urllib.request
7
  import json
 
 
 
 
 
8
 
9
  def fix_theme(theme):
10
  try:
11
- with open("/home/user/.local/lib/python3.8/site-packages/wfd/webui/doki_settings.json", encoding = "utf-8") as fp:
12
  doki = json.load(fp)
13
 
14
  doki["theme"] = theme
15
 
16
- with open("/home/user/.local/lib/python3.8/site-packages/wfd/webui/doki_settings.json", "w", encoding = "utf-8") as fp:
17
  json.dump(doki, fp)
18
  except Exception as e:
19
  print(e)
@@ -35,10 +40,10 @@ def fix_local_file(path):
35
 
36
  def fix_package_file(path):
37
  # fixed by adding files to package_data and set include_package_data=True in setup.py
38
- target_path = "/home/user/.local/lib/python3.8/site-packages/wfd/{}".format(path)
39
  if not os.path.exists(target_path):
40
  try:
41
- os.makedirs("/home/user/.local/lib/python3.8/site-packages/wfd/{}".format(os.path.dirname(path)))
42
  except Exception as e:
43
  print(e)
44
  try:
@@ -52,6 +57,8 @@ def fix_package_file(path):
52
  print("{} is fixed!".format(path))
53
 
54
  if __name__ == "__main__":
 
 
55
  fix_package_file("mpqapi/libstorm.so")
56
  fix_package_file("webui/templates/tempura.css")
57
  fix_package_file("webui/templates/background.css")
 
5
  import os
6
  import urllib.request
7
  import json
8
+ import tqdm
9
+
10
+ # the tqdm package is chosen with a dice, completely random.
11
+ SITE_PACKAGES_DIR = os.path.dirname(os.path.dirname(tqdm.__file__))
12
+ WFD_DIR = os.path.join(SITE_PACKAGES_DIR, "wfd")
13
 
14
  def fix_theme(theme):
15
  try:
16
+ with open(os.path.join(WFD_DIR, "webui/doki_settings.json"), encoding = "utf-8") as fp:
17
  doki = json.load(fp)
18
 
19
  doki["theme"] = theme
20
 
21
+ with open(os.path.join(WFD_DIR, "webui/doki_settings.json"), "w", encoding = "utf-8") as fp:
22
  json.dump(doki, fp)
23
  except Exception as e:
24
  print(e)
 
40
 
41
  def fix_package_file(path):
42
  # fixed by adding files to package_data and set include_package_data=True in setup.py
43
+ target_path = os.path.join(WFD_DIR, path)
44
  if not os.path.exists(target_path):
45
  try:
46
+ os.makedirs(os.path.join(WFD_DIR, os.path.dirname(path)))
47
  except Exception as e:
48
  print(e)
49
  try:
 
57
  print("{} is fixed!".format(path))
58
 
59
  if __name__ == "__main__":
60
+ print("SITE_PACKAGES_DIR =", SITE_PACKAGES_DIR)
61
+ print("WFD_DIR =", WFD_DIR, "and it", "exists" if os.path.exists(WFD_DIR) else "does not exist")
62
  fix_package_file("mpqapi/libstorm.so")
63
  fix_package_file("webui/templates/tempura.css")
64
  fix_package_file("webui/templates/background.css")