Bug 1459737 - Move closure to module-level function; r?dustin draft
authorGregory Szorc <gps@mozilla.com>
Fri, 04 May 2018 17:41:45 -0700
changeset 792201 f4123c6199c1d1d5635b9edff7f5c670d946002d
parent 792200 64d58a56a40db839e367744101aca884341ca0a2
child 792202 824607b0b36d2899eb1c1f7efd10de64a634ca59
push id109042
push userbmo:gps@mozilla.com
push dateMon, 07 May 2018 21:25:20 +0000
reviewersdustin
bugs1459737
milestone62.0a1
Bug 1459737 - Move closure to module-level function; r?dustin MozReview-Commit-ID: 2Z2qL8LaEno
taskcluster/scripts/run-task
--- a/taskcluster/scripts/run-task
+++ b/taskcluster/scripts/run-task
@@ -148,16 +148,23 @@ def get_posix_user_group(user, group):
         sys.exit(1)
 
     # Find all groups to which this user is a member.
     gids = [g.gr_gid for g in grp.getgrall() if group in g.gr_mem]
 
     return user_record, group_record, gids
 
 
+def write_audit_entry(path, msg):
+    now = datetime.datetime.utcnow().isoformat()
+    with open(path, 'ab') as fh:
+        fh.write(b'[%sZ %s] %s\n' % (
+                 now, os.environ.get('TASK_ID', 'UNKNOWN'), msg))
+
+
 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)
@@ -369,22 +376,16 @@ def main(args):
 
     # Include the UID and GID the task will run as to ensure that tasks
     # with different UID and GID don't share the same cache.
     if uid is not None:
         our_requirements.add(b'uid=%d' % uid)
     if gid is not None:
         our_requirements.add(b'gid=%d' % gid)
 
-    def write_audit_entry(path, msg):
-        now = datetime.datetime.utcnow().isoformat()
-        with open(path, 'ab') as fh:
-            fh.write(b'[%sZ %s] %s\n' % (
-                     now, os.environ.get('TASK_ID', 'UNKNOWN'), msg))
-
     for cache in caches:
         if not os.path.isdir(cache):
             print('error: cache %s is not a directory; this should never '
                   'happen' % cache)
             return 1
 
         requires_path = os.path.join(cache, '.cacherequires')
         audit_path = os.path.join(cache, '.cachelog')