def child(): observer = Observer() stream = Stream(callback, ".", file_events=True) observer.schedule(stream) observer.start()
def __init__(self, root_dirs, worker, log): WatcherBase.__init__(self, worker, log) self.stream = Stream(self.notify, *(x.encode('utf-8') for x in root_dirs), file_events=True) self.wait_queue = Queue()
]) print "compile gss %s to %s " % (infile, outfile) if (path.endswith(".touch_index")): update_index_html() if (update_index): global_update_index = True os.utime("%s.touch_index" % root, None) def callback(e): name = e.name cookie = e.cookie mask = e.mask processor(name) for subdir, dir, files in os.walk(root): for file in files: path = "%s/%s" % (subdir, file) processor(path) update_index_html() try: observer = Observer() stream = Stream(callback, root, file_events=True) observer.schedule(stream) observer.run() except: observer.stop()
syncer.lock() syncer.sync(config["path_source"], args.from_server) syncer.release() else: logging.critical("--init needs --from-server or --from-local") syncer.cleanup(True) sys.exit(5) # CTRL+Z will force a full sync : signal.signal(signal.SIGTSTP, syncer.sig_handler) observer.start() logging.info("------- FS WATCHING %s -------" % config["path_source"]) logging.info("(CTRL+z to force a full sync)") logging.debug("Interval %ssec", args.interval) os.chdir(config["path_source"]) stream = Stream(syncer.callback, config["path_source"]) try: observer.schedule(stream) observer.join() logging.info("Schedule finished") except KeyboardInterrupt: logging.warning("CTRL+c") finally: logging.info("Stopping observer...") observer.stop() logging.debug("Cleanup threads ...") syncer.cleanup(True) logging.info("Finished.")
def __init__(self, root_dirs, server, log): WatcherBase.__init__(self, server, log) self.stream = Stream(self.notify, *(x.encode('utf-8') for x in root_dirs), file_events=True)
def __init__(self, path='', recursive=False, listen_to=None): self.path = path self.recursive = recursive self.listen_to = listen_to self.stream = Stream(self._on_event, self.path, file_events=True)
lasttime = timestamp j = json.loads((last_song[last_song.find('{') : last_song.find('}') + 1])) if (not j['playId'] in g_dict): g_dict[j['playId']] = j print(j['songName']) print(j['musicurl']) if os.path.exists("../mp3/" + j['artistName'].replace('/', "/") + "_" +j['albumName'].replace('/', "/") + "/" + j['songName'] + ".mp3"): print("file already exists") return if not os.path.exists("../mp3/" + j['artistName'].replace('/', "/") + "_" +j['albumName'].replace('/', "/")): os.makedirs("../mp3/" + j['artistName'].replace('/', "/") + "_" +j['albumName'].replace('/', "/")) res = requests.get(j['musicurl']) f = open("../mp3/" + j['artistName'].replace('/', "/") + "_" +j['albumName'].replace('/', "/")+ "/" + j['songName'] + ".mp3", 'wb') for chunk in res.iter_content(100000): f.write(chunk) res = requests.get(j['url']) f = open("../mp3/" + j['artistName'].replace('/', "/") + "_" +j['albumName'].replace('/', "/")+ "/cover.jpg", 'wb') for chunk in res.iter_content(100000): f.write(chunk) f.close() if __name__ == "__main__": observer = Observer() stream = Stream(callback, "/Users/zhoubing/Library/Containers/com.netease.163music/Data/Documents/storage/Logs", file_events=True) observer.start() observer.schedule(stream)
def startListening(self): self.observer.start() self.stream = Stream(callback, *self.paths, file_events=True) self.observer.schedule(self.stream)
def observe(self, path, excludelist=[]): stream = Stream(self.listener, path, file_events=True) self.exclude = excludelist self.schedule(stream)
return elif fileEvent.mask == 2: do_action() def do_action(): is_starting = True more_action = False os.system('git add -A') os.system('git commit --amend --reuse-message=HEAD') print time.strftime('%H:%M:%S', time.localtime(time.time())) print '----------------------------------------------------' time.sleep(30) if (more_action): do_action() else: is_starting = False # dirty date os.system('echo ' + str(time.strftime('%H:%M:%S', time.localtime(time.time()))) + ' > update.f**k') os.system('git add -A') os.system('git commit -m \" update by watch \"') observer = Observer() stream = Stream(callback, '.', file_events=True) observer.schedule(stream) observer.start()
def __init__(self): self.obs = Observer() self.stream = Stream(self.callback, SOURCE_PATH, file_events=True)