Bug 1393655 - Strip microsecond from run-task logs draft
authorJonas Finnemann Jensen <jopsen@gmail.com>
Thu, 24 Aug 2017 17:56:15 -0700
changeset 665034 cc3d2e8d196ebd5145afad2246a945173affee1b
parent 663134 a73cc4e08bf5a005722c95b43f84ab0c8ff2bc7c
child 731636 4e5a577350083ac07e5bb5acc2afac67568f4c17
push id79909
push userjojensen@mozilla.com
push dateThu, 14 Sep 2017 21:00:07 +0000
bugs1393655
milestone57.0a1
Bug 1393655 - Strip microsecond from run-task logs * 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)