mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 09:44:15 +02:00
Modernize runtime compatibility and initialize Bearhub fork
This commit is contained in:
@@ -81,7 +81,7 @@ class WebApplicationManager(SoftwareManager, SettingsController):
|
||||
|
||||
def get_accept_language_header(self) -> str:
|
||||
try:
|
||||
syslocale = locale.getdefaultlocale()
|
||||
syslocale = locale.getlocale()
|
||||
|
||||
if syslocale:
|
||||
locale_split = syslocale[0].split('_')
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
import shutil
|
||||
import tarfile
|
||||
import traceback
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
from typing import Dict, List, Optional
|
||||
@@ -245,12 +245,12 @@ class EnvironmentUpdater:
|
||||
env_ts_str = f.read()
|
||||
|
||||
try:
|
||||
env_timestamp = datetime.fromtimestamp(float(env_ts_str))
|
||||
env_timestamp = datetime.fromtimestamp(float(env_ts_str), tz=timezone.utc)
|
||||
except Exception:
|
||||
self.logger.error(f"Could not parse environment settings file timestamp: {env_ts_str}")
|
||||
return True
|
||||
|
||||
expired = env_timestamp + timedelta(hours=settings_exp) <= datetime.utcnow()
|
||||
expired = env_timestamp + timedelta(hours=settings_exp) <= datetime.now(timezone.utc)
|
||||
|
||||
if expired:
|
||||
self.logger.info("Environment settings file has expired. It should be re-downloaded")
|
||||
@@ -314,7 +314,7 @@ class EnvironmentUpdater:
|
||||
self._finish_task_download_settings()
|
||||
return
|
||||
|
||||
cache_timestamp = datetime.utcnow().timestamp()
|
||||
cache_timestamp = datetime.now(timezone.utc).timestamp()
|
||||
with open(ENVIRONMENT_SETTINGS_CACHED_FILE, 'w+') as f:
|
||||
f.write(yaml.safe_dump(settings))
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import traceback
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from logging import Logger
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
@@ -68,12 +68,12 @@ class SuggestionsManager:
|
||||
timestamp_str = f.read()
|
||||
|
||||
try:
|
||||
sugs_timestamp = datetime.fromtimestamp(float(timestamp_str))
|
||||
sugs_timestamp = datetime.fromtimestamp(float(timestamp_str), tz=timezone.utc)
|
||||
except Exception:
|
||||
self.logger.error(f"Could not parse the cached suggestions file timestamp: {timestamp_str}")
|
||||
return True
|
||||
|
||||
expired = sugs_timestamp + timedelta(days=exp) <= datetime.utcnow()
|
||||
expired = sugs_timestamp + timedelta(days=exp) <= datetime.now(timezone.utc)
|
||||
|
||||
if expired:
|
||||
self.logger.info("Cached suggestions file has expired.")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import time
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from threading import Thread
|
||||
from typing import Optional
|
||||
|
||||
@@ -53,7 +53,7 @@ class SuggestionsLoader(Thread):
|
||||
self.suggestions = self.manager.read_cached(check_file=False)
|
||||
else:
|
||||
try:
|
||||
timestamp = datetime.utcnow().timestamp()
|
||||
timestamp = datetime.now(timezone.utc).timestamp()
|
||||
self.suggestions = self.manager.download()
|
||||
|
||||
if self.suggestions:
|
||||
|
||||
Reference in New Issue
Block a user