def __init__(self, *args, **kwargs): Runner.__init__(self, *args, **kwargs) path = os.path.dirname(os.path.dirname(sys.modules["rose"].__file__)) self.builtins_manager = SchemeHandlersManager([path], "rose.apps", ["run"], None, *args, **kwargs) self.date_time_oper = RoseDateTimeOperator()
def _get_conf(self, conf_tree, key, max_args=0): """Get a list of cycles from a configuration setting. key -- An option key in self.SECTION to locate the setting. max_args -- Maximum number of extra arguments for an item in the list. The value of the setting is expected to be split by shlex.split into a list of items. If max_args == 0, an item should be a string representing a cycle or an cycle offset. If max_args > 0, the cycle or cycle offset string can, optionally, have arguments. The arguments are delimited by colons ":". E.g.: prune-remote-logs-at=-6h -12h prune-server-logs-at=-7d prune-datac-at=-6h:foo/* -12h:'bar/* baz/*' -1d prune-work-at=-6h:t1*:*.tar -12h:t1*: -12h:*.gz -1d If max_args == 0, return a list of cycles. If max_args > 0, return a list of (cycle, [arg, ...]) """ items_str = conf_tree.node.get_value([self.SECTION, key]) if items_str is None: return [] try: items_str = env_var_process(items_str) except UnboundEnvironmentVariableError as exc: raise ConfigValueError([self.SECTION, key], items_str, exc) items = [] ref_time_point = os.getenv( RoseDateTimeOperator.TASK_CYCLE_TIME_MODE_ENV) date_time_oper = RoseDateTimeOperator(ref_time_point=ref_time_point) for item_str in shlex.split(items_str): args = item_str.split(":", max_args) offset = args.pop(0) cycle = offset if ref_time_point: if os.getenv("ROSE_CYCLING_MODE") == "integer": try: cycle = str(int(ref_time_point) + int(offset.replace("P",""))) except ValueError: pass else: try: time_point, parse_format = date_time_oper.date_parse() time_point = date_time_oper.date_shift(time_point, offset) cycle = date_time_oper.date_format( parse_format, time_point) except ValueError: pass if max_args: items.append((cycle, args)) else: items.append(cycle) return items
def __init__(self, event_handler=None, popen=None, fs_util=None, **kwargs): self.event_handler = event_handler if popen is None: popen = RosePopener(event_handler) self.popen = popen if fs_util is None: fs_util = FileSystemUtil(event_handler) self.fs_util = fs_util self.date_time_oper = RoseDateTimeOperator()
def __init__(self, event_handler=None, popen=None, fs_util=None, host_selector=None, **_): self.event_handler = event_handler if popen is None: popen = RosePopener(event_handler) self.popen = popen if fs_util is None: fs_util = FileSystemUtil(event_handler) self.fs_util = fs_util if host_selector is None: host_selector = HostSelector(event_handler, popen) self.host_selector = host_selector self.date_time_oper = RoseDateTimeOperator()
def __init__(self, popen, handle_event_func): self.popen = popen self.handle_event = handle_event_func self.date_time_oper = RoseDateTimeOperator()