def main(): """Main function for specchio Example: specchio test/ user@host:test/ :return: None """ init_logger() if os.popen("whereis ssh").read() == "": return logger.error("Specchio need `ssh`, " "but there is no `ssh` in the system") if os.popen("whereis rsync").read() == "": return logger.error("Specchio need `rsync`, " "but there is no `rsync` in the system") if len(sys.argv) == 3: src_path = sys.argv[1].strip() dst_ssh, dst_path = sys.argv[2].strip().split(":") logger.info("Initialize Specchio") event_handler = SpecchioEventHandler( src_path=src_path, dst_ssh=dst_ssh, dst_path=dst_path ) observer = Observer() observer.schedule(event_handler, src_path, recursive=True) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join() logger.info("Specchio stopped, have a nice day :)") else: print """Usage: specchio src/ user@host:dst/"""
def main(): """Main function for specchio Example: specchio test/ user@host:test/ :return: None """ if len(sys.argv) == 3: src_path = sys.argv[1].strip() dst_ssh, dst_path = sys.argv[2].strip().split(":") init_logger() logger.info("Initialize Specchio") event_handler = SpecchioEventHandler( src_path=src_path, dst_ssh=dst_ssh, dst_path=dst_path ) observer = Observer() observer.schedule(event_handler, src_path, recursive=True) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join() else: print """Usage: specchio src/ user@host:dst/"""
def test_basic_configuration(self): init_logger() self.assertEqual(self.logger.level, logging.DEBUG) self.assertEqual(len(self.logger.handlers), 1) self.assertIsInstance(self.logger.handlers[0], logging.StreamHandler) self.assertEqual(self.logger.handlers[0].stream, sys.stdout) self.assertEqual( self.logger.handlers[0].formatter._fmt, "%(log_color)s[%(levelname)s]%(reset)s" " %(asctime)s %(name)s %(message)s") self.assertEqual(self.logger.handlers[0].formatter.datefmt, "%Y-%m-%d %H:%M:%S")
def test_basic_configuration(self): init_logger() self.assertEqual(self.logger.level, logging.DEBUG) self.assertEqual(len(self.logger.handlers), 1) self.assertIsInstance(self.logger.handlers[0], logging.StreamHandler) self.assertEqual(self.logger.handlers[0].stream, sys.stdout) self.assertEqual( self.logger.handlers[0].formatter._fmt, "%(log_color)s[%(levelname)s]%(reset)s" " %(asctime)s %(name)s %(message)s" ) self.assertEqual( self.logger.handlers[0].formatter.datefmt, "%Y-%m-%d %H:%M:%S" )
def main(): """Main function for specchio Example: specchio test/ user@host:test/ :return: None """ init_logger() _popen_str = os.popen("whereis ssh").read().strip() if _popen_str == "" or _popen_str == "ssh:": return logger.error("Specchio need `ssh`, " "but there is no `ssh` in the system") _popen_str = os.popen("whereis rsync").read().strip() if _popen_str == "" or _popen_str == "rsync:": return logger.error("Specchio need `rsync`, " "but there is no `rsync` in the system") if len(sys.argv) >= 3: src_path = sys.argv[-2].strip() dst_ssh, dst_path = sys.argv[-1].strip().split(":") option_valid = all((option in GENERAL_OPTIONS) for option in sys.argv[1:-2]) if option_valid: logger.info("Initialize Specchio") is_init_remote = "--init-remote" in sys.argv[1:-2] event_handler = SpecchioEventHandler( src_path=src_path, dst_ssh=dst_ssh, dst_path=dst_path, is_init_remote=is_init_remote ) observer = Observer() observer.schedule(event_handler, src_path, recursive=True) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join() logger.info("Specchio stopped, have a nice day :)") else: print MANUAL else: print MANUAL
def main(): """Main function for specchio Example: specchio test/ user@host:test/ :return: None """ init_logger() _popen_str = os.popen("whereis ssh").read().strip() if _popen_str == "" or _popen_str == "ssh:": return logger.error("Specchio need `ssh`, " "but there is no `ssh` in the system") _popen_str = os.popen("whereis rsync").read().strip() if _popen_str == "" or _popen_str == "rsync:": return logger.error("Specchio need `rsync`, " "but there is no `rsync` in the system") if len(sys.argv) >= 3: src_path = sys.argv[-2].strip() dst_ssh, dst_path = sys.argv[-1].strip().split(":") option_valid = all((option in GENERAL_OPTIONS) for option in sys.argv[1:-2]) if option_valid: logger.info("Initialize Specchio") is_init_remote = "--init-remote" in sys.argv[1:-2] event_handler = SpecchioEventHandler( src_path=src_path, dst_ssh=dst_ssh, dst_path=dst_path, is_init_remote=is_init_remote ) observer = Observer() observer.schedule(event_handler, src_path, recursive=True) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join() logger.info("Specchio stopped, have a nice day :)") else: print(MANUAL) else: print(MANUAL)