def main(cmd_args): p = ProcessTrace.from_events(run_trace(cmd_args)) p = p.collapsed() written = set(t[1] for t in p.paths_written) read = set(t[1] for t in p.paths_read) present = set(t[1] for t in p.paths_checked if t[2]) missing = set(t[1] for t in p.paths_checked if not t[2]) present -= written | read missing -= written | read print('The command:\n {}'.format( ' '.join(shlex.quote(a) for a in p.argv))) if written: print('writes these paths:') for path in sorted(written): print(' {}'.format(path)) if written: print('reads these paths:') for path in sorted(read): print(' {}'.format(path)) if present: print('depends on the existence of these paths:') for path in sorted(present): print(' {}'.format(path)) if missing: print('depends on the non-existence of these paths:') for path in sorted(missing): print(' {}'.format(path))
def run_trace(self, cmd_args, debug=False, cwd=None, **popen_args): strace_helper.logger.setLevel( logging.DEBUG if debug else logging.WARNING) popen_args.setdefault('stdout', DEVNULL) popen_args.setdefault('stderr', DEVNULL) p = ProcessTrace.from_events(cwd=cwd, events=strace_helper.run_trace( cmd_args, cwd=cwd, log_events=debug, **popen_args)) return p