Cameron Simpson avatar Cameron Simpson committed 66091ea

cs.app.pilfer: fix call to os.path.exists, add tracing to queued operations

Comments (0)

Files changed (1)

lib/python/cs/app/pilfer.py

           debug("run_ops = %r", run_ops)
           with Later(jobs) as PQ:
             debug("urls = %s", urls)
-            runTree(urls, run_ops, P, PQ)
+            result = runTree(urls, run_ops, P, PQ)
+            result = list(result)
+            debug("final result = %s", result)
       else:
         error("unsupported op")
         badopts = True
     ''' Save the contents of the URL `U`.
     '''
     with Pfx(U):
-      dir = kw.pop('dir', None)
-      saveas = kw.pop('saveas', None)
-      if kw:
-        raise ValueError("unused parameters: %s" % (kw,))
       if saveas is None:
         saveas = U.basename
       if saveas == '-':
         sys.stdout.flush()
       else:
         with Pfx(saveas):
-          if not overwrite and os.exists(saveas):
+          if not overwrite and os.path.exists(saveas):
             warning("file exists, not saving")
           else:
             content = U.content
     one_to_one = ONE_TO_ONE
   if one_test is None:
     one_test = ONE_TEST
+  action0 = action
   with Pfx("%s", action):
     kwargs = {}
     # select URLs matching regexp
       raise ValueError("unknown action")
     if kwargs:
       func = partial(func, **kwargs)
-    return RunTreeOp(func, fork_input, fork_state, func_sig)
+    def trace_func(*a, **kw):
+      debug("do %s ...", action0)
+      with Pfx(action0):
+        return func(*a, **kw)
+    return RunTreeOp(trace_func, fork_input, fork_state, func_sig)
 
 if __name__ == '__main__':
   import sys
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.