Skip to content

Commit 9127939

Browse files
committed
Merge remote-tracking branch 'origin/main' into pre-release
2 parents 1e65c5b + 69c0e62 commit 9127939

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/commoncode/filetype.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88

99
import os
10-
from datetime import datetime
10+
from datetime import datetime, timezone
1111

1212
from commoncode.system import on_posix
1313
from commoncode.functional import memoize
@@ -164,7 +164,10 @@ def get_last_modified_date(location):
164164
yyyymmdd = ''
165165
if is_file(location):
166166
utc_date = datetime.isoformat(
167-
datetime.utcfromtimestamp(os.path.getmtime(location))
167+
datetime.fromtimestamp(
168+
os.path.getmtime(location),
169+
tz=timezone.utc,
170+
)
168171
)
169172
yyyymmdd = utc_date[:10]
170173
return yyyymmdd

src/commoncode/system.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ def is_on_ubuntu_22(os_release_location='/etc/os-release'):
9494
os_release_info = parse_os_release(os_release_location)
9595
return os_release_info['ID'] == 'ubuntu' and '22' in os_release_info['VERSION_ID']
9696

97-
98-
on_ubuntu_22 = is_on_ubuntu_22()
97+
try:
98+
on_ubuntu_22 = is_on_ubuntu_22()
99+
except FileNotFoundError:
100+
on_ubuntu_22 = False
99101

100102
del is_on_ubuntu_22
101103

0 commit comments

Comments
 (0)