mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-05-11 11:44:35 +02:00
Force encoding to utf-8 on text file operations Fixes #332
# Conflicts: # ui/server.py
This commit is contained in:
parent
e24be913e5
commit
578b3ba4f4
@ -616,7 +616,7 @@ Negative Prompt: {req.negative_prompt}
|
|||||||
Stable Diffusion model: {req.use_stable_diffusion_model + '.ckpt'}
|
Stable Diffusion model: {req.use_stable_diffusion_model + '.ckpt'}
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
with open(meta_out_path, 'w') as f:
|
with open(meta_out_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(metadata)
|
f.write(metadata)
|
||||||
except:
|
except:
|
||||||
print('could not save the file', traceback.format_exc())
|
print('could not save the file', traceback.format_exc())
|
||||||
|
@ -60,7 +60,7 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
|||||||
mtime = os.path.getmtime(config_json_path)
|
mtime = os.path.getmtime(config_json_path)
|
||||||
if mtime <= config_last_mod_time:
|
if mtime <= config_last_mod_time:
|
||||||
return config_cached
|
return config_cached
|
||||||
with open(config_json_path, 'r') as f:
|
with open(config_json_path, 'r', encoding='utf-8') as f:
|
||||||
config_cached = json.load(f)
|
config_cached = json.load(f)
|
||||||
config_last_mod_time = os.path.getmtime(config_json_path)
|
config_last_mod_time = os.path.getmtime(config_json_path)
|
||||||
return config_cached
|
return config_cached
|
||||||
@ -72,7 +72,7 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
|
|||||||
def setConfig(config):
|
def setConfig(config):
|
||||||
try: # config.json
|
try: # config.json
|
||||||
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
|
config_json_path = os.path.join(CONFIG_DIR, 'config.json')
|
||||||
with open(config_json_path, 'w') as f:
|
with open(config_json_path, 'w', encoding='utf-8') as f:
|
||||||
return json.dump(config, f)
|
return json.dump(config, f)
|
||||||
except:
|
except:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
@ -100,7 +100,7 @@ def setConfig(config):
|
|||||||
config_bat.append(f"::@set CUDA_VISIBLE_DEVICES={','.join(gpu_devices)}") # Needs better detection for edge cases, add as a comment for now.
|
config_bat.append(f"::@set CUDA_VISIBLE_DEVICES={','.join(gpu_devices)}") # Needs better detection for edge cases, add as a comment for now.
|
||||||
print('Add the line "@set CUDA_VISIBLE_DEVICES=N" where N is the GPUs to use to config.bat')
|
print('Add the line "@set CUDA_VISIBLE_DEVICES=N" where N is the GPUs to use to config.bat')
|
||||||
config_bat_path = os.path.join(CONFIG_DIR, 'config.bat')
|
config_bat_path = os.path.join(CONFIG_DIR, 'config.bat')
|
||||||
with open(config_bat_path, 'w') as f:
|
with open(config_bat_path, 'w', encoding='utf-8') as f:
|
||||||
f.write(f.write('\r\n'.join(config_bat)))
|
f.write(f.write('\r\n'.join(config_bat)))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
@ -115,7 +115,7 @@ def setConfig(config):
|
|||||||
config_sh.append(f"#CUDA_VISIBLE_DEVICES={','.join(gpu_devices)}") # Needs better detection for edge cases, add as a comment for now.
|
config_sh.append(f"#CUDA_VISIBLE_DEVICES={','.join(gpu_devices)}") # Needs better detection for edge cases, add as a comment for now.
|
||||||
print('Add the line "CUDA_VISIBLE_DEVICES=N" where N is the GPUs to use to config.sh')
|
print('Add the line "CUDA_VISIBLE_DEVICES=N" where N is the GPUs to use to config.sh')
|
||||||
config_sh_path = os.path.join(CONFIG_DIR, 'config.sh')
|
config_sh_path = os.path.join(CONFIG_DIR, 'config.sh')
|
||||||
with open(config_sh_path, 'w') as f:
|
with open(config_sh_path, 'w', encoding='utf-8') as f:
|
||||||
f.write('\n'.join(config_sh))
|
f.write('\n'.join(config_sh))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
Loading…
Reference in New Issue
Block a user