def main(is_restart=False): """CLI main.""" options, args = parse_commandline(is_restart) if not args: # Auto-registration: "cylc run" (no args) in source dir. try: reg = SuiteSrvFilesManager().register() except SuiteServiceFileError as exc: sys.exit(exc) # Replace this process with "cylc run REG ..." for 'ps -f'. os.execv(sys.argv[0], [sys.argv[0]] + [reg] + sys.argv[1:]) # Check suite is not already running before start of host selection. try: SuiteSrvFilesManager().detect_old_contact_file(args[0]) except SuiteServiceFileError as exc: sys.exit(exc) # Create auth files if needed. On a shared FS if the suite host changes # this may (will?) renew the ssl.cert to reflect the change in host name. SuiteSrvFilesManager().create_auth_files(args[0]) # Check whether a run host is explicitly specified, else select one. if not options.host: try: host = HostAppointer().appoint_host() except EmptyHostList as exc: if cylc.flags.debug: raise else: sys.exit(str(exc)) if is_remote_host(host): if is_restart: base_cmd = ["restart"] + sys.argv[1:] else: base_cmd = ["run"] + sys.argv[1:] # Prevent recursive host selection base_cmd.append("--host=localhost") return remote_cylc_cmd(base_cmd, host=host) if remrun(set_rel_local=True): # State localhost as above. sys.exit() try: SuiteSrvFilesManager().get_suite_source_dir(args[0], options.owner) except SuiteServiceFileError: # Source path is assumed to be the run directory SuiteSrvFilesManager().register( args[0], glbl_cfg().get_derived_host_item(args[0], 'suite run directory')) try: scheduler = Scheduler(is_restart, options, args) except SuiteServiceFileError as exc: sys.exit(exc) scheduler.start()
def main(is_restart=False): """CLI main.""" options, args = parse_commandline(is_restart) if not args: # Auto-registration: "cylc run" (no args) in source dir. try: reg = SuiteSrvFilesManager().register() except SuiteServiceFileError as exc: sys.exit(exc) # Replace this process with "cylc run REG ..." for 'ps -f'. os.execv(sys.argv[0], [sys.argv[0]] + [reg] + sys.argv[1:]) # Check suite is not already running before start of host selection. try: SuiteSrvFilesManager().detect_old_contact_file(args[0]) except SuiteServiceFileError as exc: sys.exit(exc) # Create auth files if needed. SuiteSrvFilesManager().create_auth_files(args[0]) # Check whether a run host is explicitly specified, else select one. if not options.host: try: host = HostAppointer().appoint_host() except EmptyHostList as exc: if cylc.flags.debug: raise else: sys.exit(str(exc)) if is_remote_host(host): if is_restart: base_cmd = ["restart"] + sys.argv[1:] else: base_cmd = ["run"] + sys.argv[1:] # Prevent recursive host selection base_cmd.append("--host=localhost") return remote_cylc_cmd(base_cmd, host=host) if remrun(set_rel_local=True): # State localhost as above. sys.exit() try: SuiteSrvFilesManager().get_suite_source_dir(args[0], options.owner) except SuiteServiceFileError: # Source path is assumed to be the run directory SuiteSrvFilesManager().register( args[0], glbl_cfg().get_derived_host_item(args[0], 'suite run directory')) try: scheduler = Scheduler(is_restart, options, args) except SuiteServiceFileError as exc: sys.exit(exc) scheduler.start()
def test_ioerror_is_ignored(self, mocked_suite_srv_files_mgr): """Test that IOError's are ignored when closing Scheduler logs. When a disk errors occurs, the scheduler.close_logs method may result in an IOError. This, combined with other variables, may cause an infinite loop. So it is better that it is ignored.""" options = Options() args = ["suiteA"] scheduler = Scheduler(is_restart=False, options=options, args=args) handler = mock.MagicMock() handler.close.side_effect = IOError LOG.addHandler(handler) scheduler.close_logs() self.assertEqual(1, handler.close.call_count)
def test_ioerror_is_ignored(self, mocked_suite_srv_files_mgr, mocked_suite_db_mgr, mocked_broadcast_mgr): """Test that IOError's are ignored when closing Scheduler logs. When a disk errors occurs, the scheduler.close_logs method may result in an IOError. This, combined with other variables, may cause an infinite loop. So it is better that it is ignored.""" mocked_suite_srv_files_mgr.return_value\ .get_suite_source_dir.return_value = "." options = Options() args = ["suiteA"] scheduler = Scheduler(is_restart=False, options=options, args=args) handler = mock.MagicMock() handler.close.side_effect = IOError handler.level = logging.INFO LOG.addHandler(handler) scheduler.close_logs() self.assertEqual(1, handler.close.call_count) LOG.removeHandler(handler)
def main(is_restart=False): """CLI main.""" options, args = parse_commandline(is_restart) scheduler = Scheduler(is_restart, options, args) scheduler.start()