From c0c702a5e3284e843e680064b4c6a7280242c567 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 12:00:37 -0500 Subject: Use UTC where appropriate in python files --- js/src/tests/lib/progressbar.py | 4 ++-- js/src/tests/lib/tasks_unix.py | 8 ++++---- js/src/tests/lib/tasks_win.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'js/src/tests/lib') diff --git a/js/src/tests/lib/progressbar.py b/js/src/tests/lib/progressbar.py index 29361660d..da578783d 100644 --- a/js/src/tests/lib/progressbar.py +++ b/js/src/tests/lib/progressbar.py @@ -28,7 +28,7 @@ class ProgressBar(object): # field in the counters map. self.limit = limit # int: The value of 'current' equal to 100%. self.limit_digits = int(math.ceil(math.log10(self.limit))) # int: max digits in limit - self.t0 = datetime.now() # datetime: The start time. + self.t0 = datetime.utcnow() # datetime: The start time. # Compute the width of the counters and build the format string. self.counters_width = 1 # [ @@ -68,7 +68,7 @@ class ProgressBar(object): sys.stdout.write(bar + '|') # Update the bar. - dt = datetime.now() - self.t0 + dt = datetime.utcnow() - self.t0 dt = dt.seconds + dt.microseconds * 1e-6 sys.stdout.write('{:6.1f}s'.format(dt)) Terminal.clear_right() diff --git a/js/src/tests/lib/tasks_unix.py b/js/src/tests/lib/tasks_unix.py index 655033522..487c749ee 100644 --- a/js/src/tests/lib/tasks_unix.py +++ b/js/src/tests/lib/tasks_unix.py @@ -14,7 +14,7 @@ class Task(object): self.pid = pid self.stdout = stdout self.stderr = stderr - self.start = datetime.now() + self.start = datetime.utcnow() self.out = [] self.err = [] @@ -59,7 +59,7 @@ def get_max_wait(tasks, timeout): # If a timeout is supplied, we need to wake up for the first task to # timeout if that is sooner. if timeout: - now = datetime.now() + now = datetime.utcnow() timeout_delta = timedelta(seconds=timeout) for task in tasks: remaining = task.start + timeout_delta - now @@ -136,7 +136,7 @@ def timed_out(task, timeout): timed_out always returns False). """ if timeout: - now = datetime.now() + now = datetime.utcnow() return (now - task.start) > timedelta(seconds=timeout) return False @@ -175,7 +175,7 @@ def reap_zombies(tasks, timeout): ''.join(ended.out), ''.join(ended.err), returncode, - (datetime.now() - ended.start).total_seconds(), + (datetime.utcnow() - ended.start).total_seconds(), timed_out(ended, timeout))) return tasks, finished diff --git a/js/src/tests/lib/tasks_win.py b/js/src/tests/lib/tasks_win.py index 7a4540c60..a99640abb 100644 --- a/js/src/tests/lib/tasks_win.py +++ b/js/src/tests/lib/tasks_win.py @@ -36,7 +36,7 @@ def _do_work(qTasks, qResults, qWatch, prefix, run_skipped, timeout, show_cmd): cmd = test.get_command(prefix) if show_cmd: print(escape_cmdline(cmd)) - tStart = datetime.now() + tStart = datetime.utcnow() proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -49,7 +49,7 @@ def _do_work(qTasks, qResults, qWatch, prefix, run_skipped, timeout, show_cmd): qWatch.put(TaskFinishedMarker) # Create a result record and forward to result processing. - dt = datetime.now() - tStart + dt = datetime.utcnow() - tStart result = TestOutput(test, cmd, out, err, proc.returncode, dt.total_seconds(), dt > timedelta(seconds=timeout)) qResults.put(result) -- cgit v1.2.3