示例#1
0
 def get_summary_update_time(self):
     """Return the last time the summaries were changed (Unix time)."""
     check_access_priv(self, 'state-totals')
     self.report('get_state_summary_update_time')
     if not self.first_update_completed:
         raise SuiteStillInitialisingError()
     return self._summary_update_time
示例#2
0
 def get_summary_update_time(self):
     """Return the last time the summaries were changed (Unix time)."""
     check_access_priv(self, 'full-read')
     self.report('get_state_summary_update_time')
     if not self.first_update_completed:
         raise SuiteStillInitialisingError()
     return self._summary_update_time
示例#3
0
    def put(self, event_message, event_id):
        """Server-side external event trigger interface."""

        check_access_priv(self, 'full-control')
        self.report("ext_trigger")
        self.queue.put((event_message, event_id))
        return (True, 'event queued')
    def get(self, task_id=None):
        """Retrieve all broadcast variables that target a given task ID."""
        check_access_priv(self, 'full-read')
        self.report('broadcast_get')
        if task_id == "None":
            task_id = None
        if not task_id:
            # all broadcast settings requested
            return self.settings
        try:
            name, point_string = TaskID.split(task_id)
        except ValueError:
            raise Exception("Can't split task_id %s" % task_id)

        ret = {}
        # The order is:
        #    all:root -> all:FAM -> ... -> all:task
        # -> tag:root -> tag:FAM -> ... -> tag:task
        for cycle in self.ALL_CYCLE_POINTS_STRS + [point_string]:
            if cycle not in self.settings:
                continue
            for namespace in reversed(self.linearized_ancestors[name]):
                if namespace in self.settings[cycle]:
                    self._addict(ret, self.settings[cycle][namespace])
        return ret
示例#5
0
    def get_tasks_by_state(self):
        """Returns a dictionary containing lists of tasks by state in the form:
        {state: [(most_recent_time_string, task_name, point_string), ...]}."""
        check_access_priv(self, 'state-totals')

        # Get tasks.
        ret = {}
        for task in self.task_summary:
            state = self.task_summary[task]['state']
            if state not in ret:
                ret[state] = []
            times = [0]
            for time_field in self.TIME_FIELDS:
                if (time_field in self.task_summary[task] and
                        self.task_summary[task][time_field]):
                    times.append(self.task_summary[task][time_field])
            task_name, point_string = task.rsplit('.', 1)
            ret[state].append((max(times), task_name, point_string,))

        # Trim down to no more than six tasks per state.
        for state in ret:
            ret[state].sort(reverse=True)
            if len(ret[state]) < 7:
                ret[state] = ret[state][0:6]
            else:
                ret[state] = ret[state][0:5] + [
                    (None, len(ret[state]) - 5, None,)]

        return ret
示例#6
0
    def put(self, event_message, event_id):
        """Server-side external event trigger interface."""

        check_access_priv(self, 'full-control')
        self.report("ext_trigger")
        self.queue.put((event_message, event_id))
        return (True, 'event queued')
示例#7
0
 def get_state_summary(self):
     """Return the global, task, and family summary data structures."""
     check_access_priv(self, 'full-read')
     self.report('get_state_summary')
     if not self.first_update_completed:
         raise SuiteStillInitialisingError()
     return (self.global_summary, self.task_summary, self.family_summary)
示例#8
0
 def get_state_summary(self):
     """Return the global, task, and family summary data structures."""
     check_access_priv(self, 'full-read')
     self.report('get_state_summary')
     if not self.first_update_completed:
         raise SuiteStillInitialisingError()
     return (self.global_summary, self.task_summary, self.family_summary)
示例#9
0
    def get(self, task_id=None):
        """Retrieve all broadcast variables that target a given task ID."""
        check_access_priv(self, 'full-read')
        self.report('broadcast_get')
        if task_id == "None":
            task_id = None
        if not task_id:
            # all broadcast settings requested
            return self.settings
        try:
            name, point_string = TaskID.split(task_id)
        except ValueError:
            raise Exception("Can't split task_id %s" % task_id)

        ret = {}
        # The order is:
        #    all:root -> all:FAM -> ... -> all:task
        # -> tag:root -> tag:FAM -> ... -> tag:task
        for cycle in self.ALL_CYCLE_POINTS_STRS + [point_string]:
            if cycle not in self.settings:
                continue
            for namespace in reversed(self.linearized_ancestors[name]):
                if namespace in self.settings[cycle]:
                    self._addict(ret, self.settings[cycle][namespace])
        return ret
示例#10
0
 def put(self, command, *command_args):
     if 'stop' in command:
         check_access_priv(self, 'shutdown')
     else:
         check_access_priv(self, 'full-control')
     self.report(command)
     self.queue.put((command, command_args))
     return (True, 'Command queued')
示例#11
0
 def put(self, command, *command_args):
     if 'stop' in command:
         check_access_priv(self, 'shutdown')
     else:
         check_access_priv(self, 'full-control')
     self.report(command)
     self.queue.put((command, command_args))
     return (True, 'Command queued')
示例#12
0
 def get(self, command, *command_args):
     if ('ping' in command or 'version' in command):
         # Free info.
         pass
     elif 'suite' in command and 'info' in command:
         # Suite title and description only.
         check_access_priv(self, 'description')
     else:
         check_access_priv(self, 'full-read')
     self.report(command)
     return self.commands[command](*command_args)
示例#13
0
 def get(self, command, *command_args):
     if ('ping' in command or 'version' in command):
         # Free info.
         pass
     elif 'suite' in command and 'info' in command:
         # Suite title and description only.
         check_access_priv(self, 'description')
     else:
         check_access_priv(self, 'full-read')
     self.report(command)
     return self.commands[command](*command_args)
示例#14
0
 def _put(self, command, command_args, command_kwargs=None):
     if command_args is None:
         command_args = tuple()
     if command_kwargs is None:
         command_kwargs = {}
     if 'stop' in command:
         check_access_priv(self, 'shutdown')
     else:
         check_access_priv(self, 'full-control')
     self.report(command)
     self.queue.put((command, command_args, command_kwargs))
     return (True, 'Command queued')
示例#15
0
 def _put(self, command, command_args, command_kwargs=None):
     if command_args is None:
         command_args = tuple()
     if command_kwargs is None:
         command_kwargs = {}
     if 'stop' in command:
         check_access_priv(self, 'shutdown')
     else:
         check_access_priv(self, 'full-control')
     self.report(command)
     self.queue.put((command, command_args, command_kwargs))
     return (True, 'Command queued')
示例#16
0
    def put(self, point_strings, namespaces, settings):
        """Add new broadcast settings (server side interface).

        Return a tuple (modified_settings, bad_options) where:
          modified_settings is list of modified settings in the form:
            [("20200202", "foo", {"command scripting": "true"}, ...]
          bad_options is as described in the docstring for self.clear().
        """
        check_access_priv(self, 'full-control')
        self.report('broadcast_put')
        modified_settings = []
        bad_point_strings = []
        bad_namespaces = []

        with self.lock:
            for setting in settings:
                for point_string in point_strings:
                    # Standardise the point and check its validity.
                    bad_point = False
                    try:
                        point_string = standardise_point_string(point_string)
                    except Exception as exc:
                        if point_string != '*':
                            bad_point_strings.append(point_string)
                            bad_point = True
                    if not bad_point and point_string not in self.settings:
                        self.settings[point_string] = {}
                    for namespace in namespaces:
                        if namespace not in self.linearized_ancestors:
                            bad_namespaces.append(namespace)
                        elif not bad_point:
                            if namespace not in self.settings[point_string]:
                                self.settings[point_string][namespace] = {}
                            self._addict(
                                self.settings[point_string][namespace],
                                setting)
                            modified_settings.append(
                                (point_string, namespace, setting))

        # Log the broadcast
        self._append_db_queue(modified_settings)
        self.log.info(get_broadcast_change_report(modified_settings))

        bad_options = {}
        if bad_point_strings:
            bad_options["point_strings"] = bad_point_strings
        if bad_namespaces:
            bad_options["namespaces"] = bad_namespaces
        return modified_settings, bad_options
示例#17
0
    def put(self, point_strings, namespaces, settings):
        """Add new broadcast settings (server side interface).

        Return a tuple (modified_settings, bad_options) where:
          modified_settings is list of modified settings in the form:
            [("20200202", "foo", {"command scripting": "true"}, ...]
          bad_options is as described in the docstring for self.clear().
        """
        check_access_priv(self, 'full-control')
        self.report('broadcast_put')
        modified_settings = []
        bad_point_strings = []
        bad_namespaces = []

        with self.lock:
            for setting in settings:
                for point_string in point_strings:
                    # Standardise the point and check its validity.
                    bad_point = False
                    try:
                        point_string = standardise_point_string(point_string)
                    except Exception as exc:
                        if point_string != '*':
                            bad_point_strings.append(point_string)
                            bad_point = True
                    if not bad_point and point_string not in self.settings:
                        self.settings[point_string] = {}
                    for namespace in namespaces:
                        if namespace not in self.linearized_ancestors:
                            bad_namespaces.append(namespace)
                        elif not bad_point:
                            if namespace not in self.settings[point_string]:
                                self.settings[point_string][namespace] = {}
                            self._addict(
                                self.settings[point_string][namespace],
                                setting)
                            modified_settings.append(
                                (point_string, namespace, setting))

        # Log the broadcast
        self._append_db_queue(modified_settings)
        self.log.info(get_broadcast_change_report(modified_settings))

        bad_options = {}
        if bad_point_strings:
            bad_options["point_strings"] = bad_point_strings
        if bad_namespaces:
            bad_options["namespaces"] = bad_namespaces
        return modified_settings, bad_options
示例#18
0
 def _put(self, command, command_args, command_kwargs=None):
     if command_args is None:
         command_args = tuple()
     if command_kwargs is None:
         command_kwargs = {}
     if ('ping' in command or 'version' in command):
         # Free info.
         pass
     elif 'suite' in command and 'info' in command:
         # Suite title and description only.
         check_access_priv(self, 'description')
     else:
         check_access_priv(self, 'full-read')
     self.report(command)
     return self.commands[command](*command_args, **command_kwargs)
示例#19
0
 def _put(self, command, command_args, command_kwargs=None):
     if command_args is None:
         command_args = tuple()
     if command_kwargs is None:
         command_kwargs = {}
     if ('ping' in command or 'version' in command):
         # Free info.
         pass
     elif 'suite' in command and 'info' in command:
         # Suite title and description only.
         check_access_priv(self, 'description')
     else:
         check_access_priv(self, 'full-read')
     self.report(command)
     return self.commands[command](*command_args, **command_kwargs)
示例#20
0
    def get_err_content(self, prev_size=0, max_lines=100):
        """Return the content and new size of the error file."""

        check_access_priv(self, 'full-read')
        self.report("get_err_content")
        if not self._get_err_has_changed(prev_size):
            return [], prev_size
        try:
            f = open(self.err_file, "r")
            f.seek(prev_size)
            new_content = f.read()
            f.close()
            size = self._get_err_size()
        except (IOError, OSError) as e:
            self.log.warning("Could not read suite err log file: %s" % e)
            return "", prev_size
        new_content_lines = new_content.splitlines()[-max_lines:]
        return "\n".join(new_content_lines), size
示例#21
0
文件: suite_log.py 项目: aosprey/cylc
    def get_err_content(self, prev_size=0, max_lines=100):
        """Return the content and new size of the error file."""

        check_access_priv(self, 'full-read')
        self.report("get_err_content")
        if not self._get_err_has_changed(prev_size):
            return [], prev_size
        try:
            f = open(self.err_file, "r")
            f.seek(prev_size)
            new_content = f.read()
            f.close()
            size = self._get_err_size()
        except (IOError, OSError) as e:
            self.log.warning("Could not read suite err log file: %s" % e)
            return "", prev_size
        new_content_lines = new_content.splitlines()[-max_lines:]
        return "\n".join(new_content_lines), size
示例#22
0
 def get_err_content(self, prev_size, max_lines):
     """Return the content and new size of the error file."""
     check_access_priv(self, 'full-read')
     self.report("get_err_content")
     prev_size = int(prev_size)
     max_lines = int(max_lines)
     if not self._get_err_has_changed(prev_size):
         return [], prev_size
     try:
         handle = open(self.err_file, "r")
         handle.seek(prev_size)
         new_content = handle.read()
         handle.close()
         size = self._get_err_size()
     except (IOError, OSError) as exc:
         self._warn_read_err(exc)
         return "", prev_size
     new_content_lines = new_content.splitlines()[-max_lines:]
     return "\n".join(new_content_lines), size
示例#23
0
 def get_err_content(self, prev_size, max_lines):
     """Return the content and new size of the error file."""
     check_access_priv(self, 'full-read')
     self.report("get_err_content")
     prev_size = int(prev_size)
     max_lines = int(max_lines)
     if not self._get_err_has_changed(prev_size):
         return [], prev_size
     try:
         handle = open(self.err_file, "r")
         handle.seek(prev_size)
         new_content = handle.read()
         handle.close()
         size = self._get_err_size()
     except (IOError, OSError) as exc:
         self._warn_read_err(exc)
         return "", prev_size
     new_content_lines = new_content.splitlines()[-max_lines:]
     return "\n".join(new_content_lines), size
示例#24
0
    def get_tasks_by_state(self):
        """Returns a dictionary containing lists of tasks by state in the form:
        {state: [(most_recent_time_string, task_name, point_string), ...]}."""
        check_access_priv(self, 'state-totals')

        # Get tasks.
        ret = {}
        for task in self.task_summary:
            state = self.task_summary[task]['state']
            if state not in ret:
                ret[state] = []
            times = [0]
            for time_field in self.TIME_FIELDS:
                if (time_field in self.task_summary[task]
                        and self.task_summary[task][time_field]):
                    times.append(self.task_summary[task][time_field])
            task_name, point_string = task.rsplit('.', 1)
            ret[state].append((
                max(times),
                task_name,
                point_string,
            ))

        # Trim down to no more than six tasks per state.
        for state in ret:
            ret[state].sort(reverse=True)
            if len(ret[state]) < 7:
                ret[state] = ret[state][0:6]
            else:
                ret[state] = ret[state][0:5] + [(
                    None,
                    len(ret[state]) - 5,
                    None,
                )]

        return ret
示例#25
0
 def get_tasks_by_state(self):
     """Returns a dictionary containing lists of tasks by state in the form:
     {state: [(most_recent_time_string, task_name, point_string), ...]}."""
     check_access_priv(self, 'state-totals')
     ret = {}
     for task in self.task_summary:
         state = self.task_summary[task]['state']
         if state not in ret:
             ret[state] = []
         time_strings = ['1970-01-01T00:00:00Z']  # Default time string.
         for time_string in self.TIME_STRINGS:
             if (time_string in self.task_summary[task] and
                     self.task_summary[task][time_string]):
                 time_strings.append(self.task_summary[task][time_string])
         task_name, point_string = task.rsplit('.', 1)
         ret[state].append((max(time_strings), task_name, point_string,))
     for state in ret:
         ret[state].sort(reverse=True)
         if len(ret[state]) < 7:
             ret[state] = ret[state][0:6]
         else:
             ret[state] = ret[state][0:5] + [
                 (None, len(ret[state]) - 5, None,)]
     return ret
示例#26
0
 def put(self, task_id, priority, message):
     check_access_priv(self, 'full-control')
     self.report('task_message')
     self.queue.put((task_id, priority, str(message)))
     return 'Message queued'
示例#27
0
 def put(self, priority, message):
     check_access_priv(self, 'full-control')
     self.report('task_message')
     self.queue.put((priority, message))
     return (True, 'Message queued')
示例#28
0
 def put(self, task_id, priority, message):
     check_access_priv(self, 'full-control')
     self.report('task_message')
     self.queue.put((task_id, priority, str(message)))
     return 'Message queued'
示例#29
0
 def put(self, task_id, priority, message):
     check_access_priv(self, "full-control")
     self.report("task_message")
     self.queue.put((task_id, priority, message))
     return (True, "Message queued")
示例#30
0
 def put(self, priority, message):
     check_access_priv(self, 'full-control')
     self.report('task_message')
     self.queue.put((priority, message))
     return (True, 'Message queued')
示例#31
0
 def get_state_summary(self):
     """Return the global, task, and family summary data structures."""
     check_access_priv(self, 'full-read')
     self.report('get_state_summary')
     return (self.global_summary, self.task_summary, self.family_summary)
示例#32
0
 def get_summary_update_time(self):
     """Return the last time the summaries were changed (Unix time)."""
     check_access_priv(self, 'state-totals')
     self.report('get_state_summary_update_time')
     return self.summary_update_time