MonsterMMORPG
commited on
Commit
•
618863a
1
Parent(s):
fe8a287
Upload settings_rope_unleash.py
Browse files- settings_rope_unleash.py +68 -0
settings_rope_unleash.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import yaml
|
2 |
+
|
3 |
+
class Settings:
|
4 |
+
def __init__(self, config_file):
|
5 |
+
self.config_file = config_file
|
6 |
+
self.load()
|
7 |
+
|
8 |
+
def default_get(_, data, name, default):
|
9 |
+
value = default
|
10 |
+
try:
|
11 |
+
value = data.get(name, default)
|
12 |
+
except:
|
13 |
+
pass
|
14 |
+
return value
|
15 |
+
|
16 |
+
|
17 |
+
def load(self):
|
18 |
+
try:
|
19 |
+
with open(self.config_file, 'r') as f:
|
20 |
+
data = yaml.load(f, Loader=yaml.FullLoader)
|
21 |
+
except:
|
22 |
+
data = None
|
23 |
+
|
24 |
+
self.selected_theme = self.default_get(data, 'selected_theme', "Default")
|
25 |
+
self.server_name = self.default_get(data, 'server_name', "")
|
26 |
+
self.server_port = self.default_get(data, 'server_port', 0)
|
27 |
+
self.server_share = self.default_get(data, 'server_share', True)
|
28 |
+
self.output_image_format = self.default_get(data, 'output_image_format', 'png')
|
29 |
+
self.output_video_format = self.default_get(data, 'output_video_format', 'mp4')
|
30 |
+
self.output_video_codec = self.default_get(data, 'output_video_codec', 'libx264')
|
31 |
+
self.video_quality = self.default_get(data, 'video_quality', 14)
|
32 |
+
self.clear_output = self.default_get(data, 'clear_output', True)
|
33 |
+
self.max_threads = self.default_get(data, 'max_threads', 2)
|
34 |
+
self.memory_limit = self.default_get(data, 'memory_limit', 0)
|
35 |
+
self.provider = self.default_get(data, 'provider', 'cuda')
|
36 |
+
self.force_cpu = self.default_get(data, 'force_cpu', False)
|
37 |
+
self.output_template = self.default_get(data, 'output_template', '{file}_{time}')
|
38 |
+
self.use_os_temp_folder = self.default_get(data, 'use_os_temp_folder', False)
|
39 |
+
self.output_show_video = self.default_get(data, 'output_show_video', True)
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
def save(self):
|
46 |
+
data = {
|
47 |
+
'selected_theme': self.selected_theme,
|
48 |
+
'server_name': self.server_name,
|
49 |
+
'server_port': self.server_port,
|
50 |
+
'server_share': self.server_share,
|
51 |
+
'output_image_format' : self.output_image_format,
|
52 |
+
'output_video_format' : self.output_video_format,
|
53 |
+
'output_video_codec' : self.output_video_codec,
|
54 |
+
'video_quality' : self.video_quality,
|
55 |
+
'clear_output' : self.clear_output,
|
56 |
+
'max_threads' : self.max_threads,
|
57 |
+
'memory_limit' : self.memory_limit,
|
58 |
+
'provider' : self.provider,
|
59 |
+
'force_cpu' : self.force_cpu,
|
60 |
+
'output_template' : self.output_template,
|
61 |
+
'use_os_temp_folder' : self.use_os_temp_folder,
|
62 |
+
'output_show_video' : self.output_show_video
|
63 |
+
}
|
64 |
+
with open(self.config_file, 'w') as f:
|
65 |
+
yaml.dump(data, f)
|
66 |
+
|
67 |
+
|
68 |
+
|