Skip to content

Commit

Permalink
NXDRIVE-2929: Upgrade Python from 3.9.5 to 3.12.3
Browse files Browse the repository at this point in the history
  • Loading branch information
poojadaine committed Sep 9, 2024
1 parent 13e48c8 commit ad962a3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
12 changes: 6 additions & 6 deletions nxdrive/dao/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os
import shutil
from contextlib import suppress
from datetime import datetime
from datetime import datetime, timezone
from logging import getLogger
from os.path import basename
from pathlib import Path
Expand Down Expand Up @@ -1502,7 +1502,7 @@ def increase_error(
self, row: DocPair, error: str, /, *, details: str = None, incr: int = 1
) -> None:
with self.lock:
error_date = datetime.utcnow()
error_date = datetime.now(tz=timezone.utc)
c = self._get_write_connection().cursor()
c.execute(
"UPDATE States"
Expand Down Expand Up @@ -1591,7 +1591,7 @@ def unsynchronize_state(
" error_count = 0,"
" last_sync_error_date = NULL"
" WHERE id = ?",
(datetime.utcnow(), last_error, row.id),
(datetime.now(tz=timezone.utc), last_error, row.id),
)

def unset_unsychronised(self, row: DocPair, /) -> None:
Expand All @@ -1616,7 +1616,7 @@ def unset_unsychronised(self, row: DocPair, /) -> None:
row.local_state,
row.remote_state,
row.pair_state,
datetime.utcnow(),
datetime.now(tz=timezone.utc),
f"{adapt_path(row.local_path)}%",
),
)
Expand Down Expand Up @@ -1658,7 +1658,7 @@ def synchronize_state(
row.remote_state,
row.pair_state,
row.local_digest,
datetime.utcnow(),
datetime.now(tz=timezone.utc),
row.id,
version,
),
Expand Down Expand Up @@ -1686,7 +1686,7 @@ def synchronize_state(
row.local_state,
row.remote_state,
row.pair_state,
datetime.utcnow(),
datetime.now(tz=timezone.utc),
row.id,
row.local_path,
row.remote_name,
Expand Down
6 changes: 4 additions & 2 deletions nxdrive/engine/engine.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import datetime
import json
import os
import os.path
import shutil
from contextlib import suppress
from dataclasses import dataclass
from datetime import datetime, timezone
from functools import partial
from logging import getLogger
from pathlib import Path
Expand Down Expand Up @@ -1184,7 +1184,9 @@ def _check_last_sync(self) -> None:
log.debug(f"Emitting syncPartialCompleted for engine {self.uid}")
self.syncPartialCompleted.emit()
else:
self.dao.update_config("last_sync_date", datetime.datetime.utcnow())
self.dao.update_config(

Check warning on line 1187 in nxdrive/engine/engine.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/engine/engine.py#L1187

Added line #L1187 was not covered by tests
"last_sync_date", datetime.datetime.now(tz=timezone.utc)
)
log.debug(f"Emitting syncCompleted for engine {self.uid}")
self._sync_started = False
self.syncCompleted.emit()
Expand Down
4 changes: 2 additions & 2 deletions nxdrive/engine/watcher/remote_watcher.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from datetime import datetime
from datetime import datetime, timezone
from logging import getLogger
from operator import attrgetter, itemgetter
from time import monotonic, sleep
Expand Down Expand Up @@ -116,7 +116,7 @@ def scan_remote(self, *, from_state: DocPair = None) -> None:

# Recursive update
self._do_scan_remote(from_state, remote_info)
self._last_remote_full_scan = datetime.utcnow()
self._last_remote_full_scan = datetime.now(tz=timezone.utc)

Check warning on line 119 in nxdrive/engine/watcher/remote_watcher.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/engine/watcher/remote_watcher.py#L119

Added line #L119 was not covered by tests
self.dao.update_config("remote_last_full_scan", self._last_remote_full_scan)
self.dao.clean_scanned()

Expand Down
8 changes: 4 additions & 4 deletions nxdrive/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys
from configparser import DEFAULTSECT, ConfigParser
from copy import deepcopy
from datetime import datetime
from datetime import datetime, timezone
from functools import lru_cache
from itertools import islice
from logging import getLogger
Expand Down Expand Up @@ -1286,7 +1286,7 @@ def today_is_special() -> bool:
"""This beautiful day is special, isn't it? As all other days, right? :)"""
return (
os.getenv("I_LOVE_XMAS", "0") == "1"
or int(datetime.utcnow().strftime("%j")) >= 354
or int(datetime.now(tz=timezone.utc).strftime("%j")) >= 354
)


Expand All @@ -1300,7 +1300,7 @@ def get_current_locale() -> str:
else:
import locale

encoding = locale.getdefaultlocale()[1] or ""
encoding = locale.getpreferredencoding(False) or ""

# Guess the current locale name
if WINDOWS:
Expand All @@ -1314,7 +1314,7 @@ def get_current_locale() -> str:
l10n_code = NSLocale.currentLocale()
l10n = NSLocale.localeIdentifier(l10n_code)
else:
l10n = locale.getdefaultlocale()[0] or ""
l10n = locale.getpreferredencoding(False) or ""

return ".".join([l10n, encoding])

Expand Down

0 comments on commit ad962a3

Please sign in to comment.