def real_doout(dest_path, element): if dest_path is None: stdout(element) stdoutf() else: dfile=os.path.join(dest_path, element) code, msg=touch(dfile) if code!="ok": logging.warning("Can't touch file '%s' (%s)" % (dfile, msg))
def maybe_process_ok(ctx, _ok, _, primary_path, compare_path, just_basename, dest_path): if dest_path: logging.debug("Emptying dest path: %s" % dest_path) rmdir(dest_path) code, _msg=mkdir_p(dest_path) if code!="ok": raise Exception("Can't create path: %s" % dest_path) ### log rate limiter helper -- need to update status in context 'ctx' doOnTransition(ctx, "status_file.contents", "down", True, None) codep, primary_files=get_root_files(primary_path, strip_dirname=True) codec, compare_files=get_root_files(compare_path, strip_dirname=True) ### output some log info on transitions tm=ctx["tm"] tm.send(("pp_log", codep=="ok")) tm.send(("zp_log", codec=="ok")) ### not much to do if either path isn't accessible... if not codep.startswith("ok") or not codec.startswith("ok"): return exts=ctx["exts"] if exts is not None: primary_files=filter(filtre(exts), primary_files) compare_files=filter(filtre(exts), compare_files) def _mapper(path): bn=os.path.basename(path) return os.path.splitext(bn)[0] if just_basename: pfiles=map(_mapper, primary_files) cfiles=map(_mapper, compare_files) else: pfiles=primary_files cfiles=compare_files try: setpf=set(pfiles) setcf=set(cfiles) common=setpf.intersection(setcf) diff={ "pp": primary_path ,"zp": compare_path ,"pp-zp": list(setpf-setcf) ,"zp-pp": list(setcf-setpf) ,"common": list(common) } topic_name=ctx["topic_name"] if topic_name is not None: diff["topic"]=topic_name if ctx["just_list"]: doout(ctx, diff, dest_path) else: stdoutj(diff) stdoutf() except Exception, e: logging.error("Can't compute diff between paths: %s" % str(e))