diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-02 12:00:37 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-02 12:00:37 -0500 |
commit | c0c702a5e3284e843e680064b4c6a7280242c567 (patch) | |
tree | 59332b13537a0c006c090ae925e8d3be50bb4699 | |
parent | 45d4933f568d8814d8045852a9a1b006b912dcf7 (diff) | |
download | UXP-c0c702a5e3284e843e680064b4c6a7280242c567.tar UXP-c0c702a5e3284e843e680064b4c6a7280242c567.tar.gz UXP-c0c702a5e3284e843e680064b4c6a7280242c567.tar.lz UXP-c0c702a5e3284e843e680064b4c6a7280242c567.tar.xz UXP-c0c702a5e3284e843e680064b4c6a7280242c567.zip |
Use UTC where appropriate in python files
-rw-r--r-- | addon-sdk/source/python-lib/mozrunner/killableprocess.py | 8 | ||||
-rw-r--r-- | build/mobile/b2gautomation.py | 4 | ||||
-rw-r--r-- | build/mobile/remoteautomation.py | 4 | ||||
-rw-r--r-- | build/release/info.py | 2 | ||||
-rw-r--r-- | build/variables.py | 2 | ||||
-rw-r--r-- | js/src/gdb/progressbar.py | 4 | ||||
-rw-r--r-- | js/src/tests/lib/progressbar.py | 4 | ||||
-rw-r--r-- | js/src/tests/lib/tasks_unix.py | 8 | ||||
-rw-r--r-- | js/src/tests/lib/tasks_win.py | 4 | ||||
-rwxr-xr-x | media/webrtc/trunk/testing/gtest/test/gtest_xml_output_unittest.py | 2 | ||||
-rw-r--r-- | python/mock-1.0.0/tests/testhelpers.py | 6 | ||||
-rw-r--r-- | python/mozbuild/mozbuild/android_version_code.py | 2 | ||||
-rw-r--r-- | python/psutil/docs/conf.py | 2 | ||||
-rwxr-xr-x | python/psutil/examples/top.py | 2 | ||||
-rwxr-xr-x | security/nss/gtests/google_test/gtest/test/gtest_xml_output_unittest.py | 2 | ||||
-rw-r--r-- | tools/docs/conf.py | 2 |
16 files changed, 29 insertions, 29 deletions
diff --git a/addon-sdk/source/python-lib/mozrunner/killableprocess.py b/addon-sdk/source/python-lib/mozrunner/killableprocess.py index daf52f0c9..21eac6965 100644 --- a/addon-sdk/source/python-lib/mozrunner/killableprocess.py +++ b/addon-sdk/source/python-lib/mozrunner/killableprocess.py @@ -217,7 +217,7 @@ class Popen(subprocess.Popen): # timeout is now in milliseconds timeout = timeout * 1000 - starttime = datetime.datetime.now() + starttime = datetime.datetime.utcnow() if mswindows: if timeout is None: @@ -234,7 +234,7 @@ class Popen(subprocess.Popen): # Returns 1 if running, 0 if not, -1 if timed out def check(): - now = datetime.datetime.now() + now = datetime.datetime.utcnow() diff = now - starttime if (diff.seconds * 1000000 + diff.microseconds) < (timeout * 1000): # (1000*1000) if self._job: @@ -302,7 +302,7 @@ class Popen(subprocess.Popen): returncode = False - now = datetime.datetime.now() + now = datetime.datetime.utcnow() diff = now - starttime while (diff.seconds * 1000 * 1000 + diff.microseconds) < (timeout * 1000) and ( returncode is False ): if group is True: @@ -311,7 +311,7 @@ class Popen(subprocess.Popen): if subprocess.poll() is not None: returncode = self.returncode time.sleep(.5) - now = datetime.datetime.now() + now = datetime.datetime.utcnow() diff = now - starttime return self.returncode diff --git a/build/mobile/b2gautomation.py b/build/mobile/b2gautomation.py index d49a5f1ac..d73edd419 100644 --- a/build/mobile/b2gautomation.py +++ b/build/mobile/b2gautomation.py @@ -241,8 +241,8 @@ class B2GRemoteAutomation(Automation): self._devicemanager.killProcess('/system/b2g/b2g', sig=signal.SIGABRT) timeout = 10 # seconds - starttime = datetime.datetime.now() - while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout): + starttime = datetime.datetime.utcnow() + while datetime.datetime.utcnow() - starttime < datetime.timedelta(seconds=timeout): if not self._devicemanager.processExist('/system/b2g/b2g'): break time.sleep(1) diff --git a/build/mobile/remoteautomation.py b/build/mobile/remoteautomation.py index 7b2fad6cb..1358e0dfe 100644 --- a/build/mobile/remoteautomation.py +++ b/build/mobile/remoteautomation.py @@ -387,9 +387,9 @@ class RemoteAutomation(Automation): # Get log updates on each interval, but if it is taking # too long, only do it every 60 seconds if (not slowLog) or (timer % 60 == 0): - startRead = datetime.datetime.now() + startRead = datetime.datetime.utcnow() hasOutput = self.read_stdout() - if (datetime.datetime.now() - startRead) > datetime.timedelta(seconds=5): + if (datetime.datetime.utcnow() - startRead) > datetime.timedelta(seconds=5): slowLog = True if hasOutput: noOutputTimer = 0 diff --git a/build/release/info.py b/build/release/info.py index 9f42edd5a..7e7a30bce 100644 --- a/build/release/info.py +++ b/build/release/info.py @@ -129,7 +129,7 @@ def getReleaseTag(tag): def generateRelbranchName(version, prefix='GECKO'): return '%s%s_%s_RELBRANCH' % ( prefix, version.replace('.', ''), - datetime.now().strftime('%Y%m%d%H')) + datetime.utcnow().strftime('%Y%m%d%H')) def getReleaseName(product, version, buildNumber): diff --git a/build/variables.py b/build/variables.py index 7761e6096..de0903af2 100644 --- a/build/variables.py +++ b/build/variables.py @@ -17,7 +17,7 @@ def buildid_header(output): print('Ignoring invalid MOZ_BUILD_DATE: %s' % buildid, file=sys.stderr) buildid = None if not buildid: - buildid = datetime.now().strftime('%Y%m%d%H%M%S') + buildid = datetime.utcnow().strftime('%Y%m%d%H%M%S') output.write("#define MOZ_BUILDID %s\n" % buildid) diff --git a/js/src/gdb/progressbar.py b/js/src/gdb/progressbar.py index d96a67c96..faf571ffb 100644 --- a/js/src/gdb/progressbar.py +++ b/js/src/gdb/progressbar.py @@ -12,7 +12,7 @@ class ProgressBar(object): self.limit = limit self.label_width = label_width self.cur = 0 - self.t0 = datetime.datetime.now() + self.t0 = datetime.datetime.utcnow() self.fullwidth = None self.barlen = 64 - self.label_width @@ -23,7 +23,7 @@ class ProgressBar(object): pct = int(100.0 * self.cur / self.limit) barlen = int(1.0 * self.barlen * self.cur / self.limit) - 1 bar = '='*barlen + '>' - dt = datetime.datetime.now() - self.t0 + dt = datetime.datetime.utcnow() - self.t0 dt = dt.seconds + dt.microseconds * 1e-6 line = self.fmt%(self.label[:self.label_width], pct, bar, dt) self.fullwidth = len(line) 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) diff --git a/media/webrtc/trunk/testing/gtest/test/gtest_xml_output_unittest.py b/media/webrtc/trunk/testing/gtest/test/gtest_xml_output_unittest.py index 1bcd4187e..8cdfb56b6 100755 --- a/media/webrtc/trunk/testing/gtest/test/gtest_xml_output_unittest.py +++ b/media/webrtc/trunk/testing/gtest/test/gtest_xml_output_unittest.py @@ -182,7 +182,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): day=int(match.group(3)), hour=int(match.group(4)), minute=int(match.group(5)), second=int(match.group(6))) - time_delta = abs(datetime.datetime.now() - date_time_from_xml) + time_delta = abs(datetime.datetime.utcnow() - date_time_from_xml) # timestamp value should be near the current local time self.assertTrue(time_delta < datetime.timedelta(seconds=600), 'time_delta is %s' % time_delta) diff --git a/python/mock-1.0.0/tests/testhelpers.py b/python/mock-1.0.0/tests/testhelpers.py index e788da844..f41023c37 100644 --- a/python/mock-1.0.0/tests/testhelpers.py +++ b/python/mock-1.0.0/tests/testhelpers.py @@ -41,21 +41,21 @@ class AnyTest(unittest2.TestCase): def test_any_and_datetime(self): mock = Mock() - mock(datetime.now(), foo=datetime.now()) + mock(datetime.utcnow(), foo=datetime.utcnow()) mock.assert_called_with(ANY, foo=ANY) def test_any_mock_calls_comparison_order(self): mock = Mock() - d = datetime.now() + d = datetime.utcnow() class Foo(object): def __eq__(self, other): return False def __ne__(self, other): return True - for d in datetime.now(), Foo(): + for d in datetime.utcnow(), Foo(): mock.reset_mock() mock(d, foo=d, bar=d) diff --git a/python/mozbuild/mozbuild/android_version_code.py b/python/mozbuild/mozbuild/android_version_code.py index 69ce22b8e..6d9445c63 100644 --- a/python/mozbuild/mozbuild/android_version_code.py +++ b/python/mozbuild/mozbuild/android_version_code.py @@ -79,7 +79,7 @@ def android_version_code_v1(buildid, cpu_arch=None, min_sdk=0, max_sdk=0): ''' def hours_since_cutoff(buildid): # The ID is formatted like YYYYMMDDHHMMSS (using - # datetime.now().strftime('%Y%m%d%H%M%S'); see build/variables.py). + # datetime.utcnow().strftime('%Y%m%d%H%M%S'); see build/variables.py). # The inverse function is time.strptime. # N.B.: the time module expresses time as decimal seconds since the # epoch. diff --git a/python/psutil/docs/conf.py b/python/psutil/docs/conf.py index 9fa163b65..ad880110f 100644 --- a/python/psutil/docs/conf.py +++ b/python/psutil/docs/conf.py @@ -18,7 +18,7 @@ import os PROJECT_NAME = "psutil" AUTHOR = "Giampaolo Rodola'" -THIS_YEAR = str(datetime.datetime.now().year) +THIS_YEAR = str(datetime.datetime.utcnow().year) HERE = os.path.abspath(os.path.dirname(__file__)) diff --git a/python/psutil/examples/top.py b/python/psutil/examples/top.py index 7aebef1d4..30df417f5 100755 --- a/python/psutil/examples/top.py +++ b/python/psutil/examples/top.py @@ -165,7 +165,7 @@ def print_header(procs_status, num_procs): st.sort(key=lambda x: x[:3] in ('run', 'sle'), reverse=1) print_line(" Processes: %s (%s)" % (num_procs, ' '.join(st))) # load average, uptime - uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time()) + uptime = datetime.utcnow() - datetime.fromtimestamp(psutil.boot_time()) av1, av2, av3 = os.getloadavg() line = " Load average: %.2f %.2f %.2f Uptime: %s" \ % (av1, av2, av3, str(uptime).split('.')[0]) diff --git a/security/nss/gtests/google_test/gtest/test/gtest_xml_output_unittest.py b/security/nss/gtests/google_test/gtest/test/gtest_xml_output_unittest.py index f605d4ee2..467ab1d08 100755 --- a/security/nss/gtests/google_test/gtest/test/gtest_xml_output_unittest.py +++ b/security/nss/gtests/google_test/gtest/test/gtest_xml_output_unittest.py @@ -192,7 +192,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): day=int(match.group(3)), hour=int(match.group(4)), minute=int(match.group(5)), second=int(match.group(6))) - time_delta = abs(datetime.datetime.now() - date_time_from_xml) + time_delta = abs(datetime.datetime.utcnow() - date_time_from_xml) # timestamp value should be near the current local time self.assertTrue(time_delta < datetime.timedelta(seconds=600), 'time_delta is %s' % time_delta) diff --git a/tools/docs/conf.py b/tools/docs/conf.py index 38cea035a..1a919063f 100644 --- a/tools/docs/conf.py +++ b/tools/docs/conf.py @@ -42,7 +42,7 @@ templates_path = ['_templates'] source_suffix = '.rst' master_doc = 'index' project = u'Mozilla Source Tree Docs' -year = datetime.now().year +year = datetime.utcnow().year # Grab the version from the source tree's milestone. # FUTURE Use Python API from bug 941299. |