mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 13:58:49 +00:00
Use UTC where appropriate in python files
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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__))
|
||||
|
||||
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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)
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user