def do_processing(ext_done, mode_dir, del_dir_dst, dir_src, dir_dst, dir_tmp): logging.debug("Processing starts...") code, dirs=getsubdirs(dir_src) if not code.startswith("ok"): raise Exception("Can't get subdirectories of: %s" % dir_src) for d in dirs: if mode_dir: bn_dir_src=os.path.basename(d) if not bn_dir_src.endswith(ext_done): continue process_dir(ext_done, mode_dir, del_dir_dst, d, bn_dir_src, dir_dst, dir_tmp) logging.debug("Processing ends...")
def run( path=None ,polling_interval=None ,topic=None ,always=None ,**_ ): code, path=resolve_path(path) if not code.startswith("ok"): raise Exception("Can't resolve path...: %s" % path) def loginfo(path, state, *_): logging.info("Path state '%s': %s" % (path, state)) ctx={"topic": topic, "path": path, "always":always} ctx["_path"]={ "previous": "ok" ,"ch": partial(loginfo, path) } tm=transition_manager(ctx) ppid=os.getppid() logging.info("Process pid: %s" % os.getpid()) logging.info("Parent pid : %s" % ppid) logging.info("Starting loop...") while True: if os.getppid()!=ppid: logging.warning("Parent terminated... exiting") break code, maybe_subdirs=getsubdirs(path) tm.send(("_path", code)) if code.startswith("ok"): process(ctx, maybe_subdirs) start_time=time.time() while True: ir, _w, _e=select.select([sys.stdin], [], [], polling_interval) if len(ir): iline=sys.stdin.readline() sys.stdout.write(iline) elapsed_time = time.time() - start_time if elapsed_time > polling_interval: break
def do_processing(delete_source, exit_error, dir_src, dir_dst, dir_tmp): logging.debug("Processing BEGINS...") code, dirs=getsubdirs(dir_src) if not code.startswith("ok"): raise Exception("Can't get subdirectories of: %s" % dir_src) for d in dirs: try: bn_dir_src=os.path.basename(d) dfile_path=process_dir(delete_source, d, bn_dir_src, dir_dst, dir_tmp) logging.info("progress: Created archive: %s" % dfile_path) except Exception,e: m="Can't process directory %s (%s)" % (d, e) if exit_error: raise Exception(m) logging.warning(m)