Skip to content

Commit

Permalink
Merge pull request #119 from walles/johan/fix-ci-2
Browse files Browse the repository at this point in the history
Make CI pass again
  • Loading branch information
walles authored Nov 4, 2023
2 parents 2d6e177 + 2e71f39 commit 6d9e219
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 91 deletions.
4 changes: 2 additions & 2 deletions devbin/make-executable-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ echo 'import px.px; px.px.main()' >"$WORKDIR/__main__.py"
cp -a "$ROOTDIR/px" "$WORKDIR/"

# Dependencies, must match list in requirements.txt
cp -a "$ENVDIR"/lib/python*/site-packages/dateutil "$WORKDIR/"
cp -a "$ENVDIR"/lib/python*/site-packages/six.py "$WORKDIR/"
#
# NOTE: This section intentionally left blank

# Tidy up a bit
find "$WORKDIR" -name '*.pyc' -delete
Expand Down
11 changes: 5 additions & 6 deletions px/px_loginhistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import datetime

import re
import dateutil.tz

from . import px_exec_util

from typing import Optional, Set

LOG = logging.getLogger(__name__)

TIMEZONE = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo

# last regexp parts
LAST_USERNAME = "([^ ]+)"
LAST_DEVICE = "([^ ]+)"
Expand Down Expand Up @@ -72,7 +73,7 @@ def get_users_at(
"""

if now is None:
now = datetime.datetime.now(dateutil.tz.tzlocal())
now = datetime.datetime.now(datetime.timezone.utc).astimezone()

if last_output is None:
last_output = call_last()
Expand Down Expand Up @@ -158,7 +159,7 @@ def _to_timestamp(string, now):

try:
timestamp = datetime.datetime(
now.year, month, day, hour, minute, tzinfo=dateutil.tz.tzlocal()
now.year, month, day, hour, minute, tzinfo=TIMEZONE
)
if timestamp <= now:
return timestamp
Expand All @@ -169,9 +170,7 @@ def _to_timestamp(string, now):
else:
raise

return datetime.datetime(
now.year - 1, month, day, hour, minute, tzinfo=dateutil.tz.tzlocal()
)
return datetime.datetime(now.year - 1, month, day, hour, minute, tzinfo=TIMEZONE)


def _to_timedelta(string: str) -> datetime.timedelta:
Expand Down
9 changes: 4 additions & 5 deletions px/px_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import pwd
import errno
import subprocess
import dateutil.tz

from . import px_commandline
from . import px_exec_util
Expand Down Expand Up @@ -38,7 +37,7 @@
CPUTIME_LINUX_DAYS = re.compile("^([0-9]+)-([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$")


TIMEZONE = dateutil.tz.tzlocal()
TIMEZONE = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo


uid_to_username_cache: Dict[int, str] = {}
Expand Down Expand Up @@ -356,9 +355,9 @@ def create_kernel_process(now: datetime.datetime) -> PxProcess:
process_builder.ppid = None

# FIXME: This should be the system boot timestamp, not the epoch
process_builder.start_time_string = datetime.datetime.utcfromtimestamp(0).strftime(
"%c"
)
process_builder.start_time_string = datetime.datetime.fromtimestamp(
0, datetime.timezone.utc
).strftime("%c")

process_builder.rss_kb = 0
process_builder.username = "root"
Expand Down
10 changes: 2 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@
# NOTE: If you change something here, you must update make-executable-zip.sh as
# well, search for "requirements.txt"!

# NOTE: We don't use six ourselves, but python-dateutil does. Do remove once
# we're on a Python-3-only python-dateutil!
six

# 2.6.1 is what we started out using, older is probably fine
# as well but I don't know *how* old. If anybody wants older,
# let me know and we'll see. /[email protected] 2019mar11
python-dateutil >= 2.6.1
# NOTE: This file intentionally left blank because we don't have any third-party
# runtime dependencies.
Loading

0 comments on commit 6d9e219

Please sign in to comment.