mirror of
https://github.com/netinvent/npbackup.git
synced 2024-09-20 06:46:13 +08:00
Add missing UTF-8 encodings
This commit is contained in:
parent
114d90ebe6
commit
1a0644d05c
|
@ -316,7 +316,7 @@ def compile(arch: str, audience: str, build_type: str, onefile: bool):
|
|||
errors = True
|
||||
|
||||
## Create version file
|
||||
with open(os.path.join(BUILDS_DIR, audience, "VERSION"), "w") as fh:
|
||||
with open(os.path.join(BUILDS_DIR, audience, "VERSION"), "w", encoding="utf-8") as fh:
|
||||
fh.write(npbackup_version)
|
||||
print(f"COMPILED {'WITH SUCCESS' if not errors else 'WITH ERRORS'}")
|
||||
if not onefile:
|
||||
|
|
|
@ -151,7 +151,7 @@ def metric_writer(
|
|||
else:
|
||||
try:
|
||||
# We use append so if prometheus text collector did not get data yet, we'll not wipe it
|
||||
with open(destination, "a") as file_handle:
|
||||
with open(destination, "a", encoding="utf-8") as file_handle:
|
||||
for metric in metrics:
|
||||
file_handle.write(metric + "\n")
|
||||
except OSError as exc:
|
||||
|
|
|
@ -37,7 +37,7 @@ def need_upgrade(upgrade_interval: int) -> bool:
|
|||
|
||||
def _write_count(file: str, count: int) -> bool:
|
||||
try:
|
||||
with open(file, "w") as fpw:
|
||||
with open(file, "w", encoding="utf-8") as fpw:
|
||||
fpw.write(str(count))
|
||||
return True
|
||||
except OSError:
|
||||
|
@ -46,7 +46,7 @@ def need_upgrade(upgrade_interval: int) -> bool:
|
|||
|
||||
def _get_count(file: str) -> Optional[int]:
|
||||
try:
|
||||
with open(file, "r") as fpr:
|
||||
with open(file, "r", encoding="utf-8") as fpr:
|
||||
count = int(fpr.read())
|
||||
return count
|
||||
except OSError:
|
||||
|
|
|
@ -122,7 +122,7 @@ def create_scheduled_task_unix(
|
|||
f'{trigger} cd "{executable_dir}" && {cli_executable_path} {TASK_ARGS}\n'
|
||||
)
|
||||
try:
|
||||
with open(cron_file, "w") as file_handle:
|
||||
with open(cron_file, "w", encoding="utf-8") as file_handle:
|
||||
file_handle.write(crontab_entry)
|
||||
except OSError as exc:
|
||||
logger.error("Could not write to file {}: {}".format(cron_file, exc))
|
||||
|
|
|
@ -50,7 +50,7 @@ def update_custom_icons():
|
|||
|
||||
resources_dir = os.path.join(BASEDIR, os.path.pardir, 'resources')
|
||||
customization_py = os.path.join(resources_dir, 'customization.py')
|
||||
with open(customization_py, 'r') as f:
|
||||
with open(customization_py, 'r', encoding="utf-8") as f:
|
||||
customization = f.read()
|
||||
for var_name, file in custom_resources.items():
|
||||
file_path = os.path.join(resources_dir, file)
|
||||
|
@ -61,7 +61,7 @@ def update_custom_icons():
|
|||
customization = re.sub(f'{var_name} = b".*"', f'{var_name} = b"{encoded_b64}"', customization)
|
||||
else:
|
||||
print("No file found for", var_name)
|
||||
with open(customization_py, 'w') as f:
|
||||
with open(customization_py, 'w', encoding="utf-8") as f:
|
||||
f.write(customization)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in a new issue