wdcqc commited on
Commit
07895a2
1 Parent(s): 747bede

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -49
app.py CHANGED
@@ -10,67 +10,23 @@ import importlib
10
  # do it properly
11
  WFD_DIR = os.path.dirname(importlib.util.find_spec("wfd").origin)
12
 
13
- def fix_theme(theme):
 
14
  try:
15
- with open(os.path.join(WFD_DIR, "webui/doki_settings.json"), encoding = "utf-8") as fp:
16
  doki = json.load(fp)
17
 
18
  doki["theme"] = theme
19
 
20
- with open(os.path.join(WFD_DIR, "webui/doki_settings.json"), "w", encoding = "utf-8") as fp:
21
  json.dump(doki, fp)
22
  except Exception as e:
23
  print(e)
24
 
25
- def fix_local_file(path):
26
- # probably should include the tile files in the package. let's get it running first.
27
- if not os.path.exists(path):
28
- try:
29
- os.makedirs(os.path.dirname(path))
30
- except Exception as e:
31
- print(e)
32
- try:
33
- urllib.request.urlretrieve(
34
- "https://github.com/wdcqc/WaveFunctionDiffusion/raw/remaster/{}".format(path),
35
- path
36
- )
37
- except Exception as e:
38
- print(e)
39
-
40
- def fix_package_file(path):
41
- # fixed by adding files to package_data and set include_package_data=True in setup.py
42
- target_path = os.path.join(WFD_DIR, path)
43
- if not os.path.exists(target_path):
44
- try:
45
- os.makedirs(os.path.join(WFD_DIR, os.path.dirname(path)))
46
- except Exception as e:
47
- print(e)
48
- try:
49
- urllib.request.urlretrieve(
50
- "https://github.com/wdcqc/WaveFunctionDiffusion/raw/remaster/wfd/{}".format(path),
51
- target_path
52
- )
53
- except Exception as e:
54
- print(e)
55
- else:
56
- print("{} is fixed!".format(path))
57
-
58
  if __name__ == "__main__":
59
  print("WFD_DIR =", WFD_DIR)
60
- # fix_package_file("mpqapi/libstorm.so")
61
- # fix_package_file("webui/templates/tempura.css")
62
- # fix_package_file("webui/templates/background.css")
63
- # fix_package_file("webui/doki_settings.json")
64
- # fix_local_file("tile_data/platform.cv5.bin")
65
- # fix_local_file("tile_data/platform.png")
66
- # fix_local_file("tile_data/platform_mapping.npz")
67
- # fix_local_file("tile_data/platform_v2.npz")
68
- # fix_local_file("tile_data/wfc/platform_32x32.npz")
69
- # fix_local_file("default/base.chk")
70
-
71
- # fix_theme("KonoSuba: Darkness Light")
72
 
73
- from wfd.webui import set_theme, start_demo
74
  class Arguments:
75
  colab = False
76
  link_to_colab = True
 
10
  # do it properly
11
  WFD_DIR = os.path.dirname(importlib.util.find_spec("wfd").origin)
12
 
13
+ def set_theme(theme):
14
+ settings_file = os.path.join(WFD_DIR, "webui", "doki_settings.json")
15
  try:
16
+ with open(settings_file, encoding = "utf-8") as fp:
17
  doki = json.load(fp)
18
 
19
  doki["theme"] = theme
20
 
21
+ with open(settings_file, "w", encoding = "utf-8") as fp:
22
  json.dump(doki, fp)
23
  except Exception as e:
24
  print(e)
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  if __name__ == "__main__":
27
  print("WFD_DIR =", WFD_DIR)
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
+ from wfd.webui import start_demo
30
  class Arguments:
31
  colab = False
32
  link_to_colab = True