Bug 1393655 - Strip microsecond from run-task logs r=gps
authorJonas Finnemann Jensen <jopsen@gmail.com>
Thu, 24 Aug 2017 17:56:15 -0700
changeset 381014 9c24bd90faa13cb7cccaa5af5aed8ddf450a98fe
parent 381013 442cc0fe3bec0c24499aedbeea051053bb30d1e3
child 381015 d7ccda988869be632fb6b3345d3efba111db7f7d
push id51277
push userryanvm@gmail.com
push dateThu, 14 Sep 2017 22:08:12 +0000
treeherderautoland@9c24bd90faa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1393655
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1393655 - Strip microsecond from run-task logs r=gps * Strip microsecond from log prefixes generated by run-task. MozReview-Commit-ID: 87kL6gs2LZS
taskcluster/docker/recipes/run-task
--- a/taskcluster/docker/recipes/run-task
+++ b/taskcluster/docker/recipes/run-task
@@ -63,18 +63,19 @@ Change the Dockerfile and anything run f
 any VOLUME.
 
 A lesser possibility is that you stumbled upon a TaskCluster platform bug
 where it fails to use new volumes for tasks.
 '''
 
 
 def print_line(prefix, m):
-    now = datetime.datetime.utcnow()
-    print(b'[%s %sZ] %s' % (prefix, now.isoformat(), m), end=b'')
+    now = datetime.datetime.utcnow().isoformat()
+    now = now[:-3] if now[-7] == '.' else now  # slice microseconds to 3 decimals
+    print(b'[%s %sZ] %s' % (prefix, now, m), end=b'')
 
 
 def run_and_prefix_output(prefix, args, extra_env=None):
     """Runs a process and prefixes its output with the time.
 
     Returns the process exit code.
     """
     print_line(prefix, b'executing %s\n' % args)
@@ -104,17 +105,16 @@ def run_and_prefix_output(prefix, args, 
         data = p.stdout.readline()
         if data == b'':
             break
 
         print_line(prefix, data)
 
     return p.wait()
 
-
 WANTED_DIR_MODE = stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
 
 
 def set_dir_permissions(path, uid, gid):
     st = os.lstat(path)
 
     if st.st_uid != uid or st.st_gid != gid:
         os.chown(path, uid, gid)