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