예제 #1
0
def open_statuses(location):
    if os.path.isfile(location):
        with open(location, 'r') as input_file:
            return json.load(input_file)

    components = urlparse.urlparse(location)
    cookie_stuff = serverconfig.config_dict()['data']

    return get_json(components.netloc, components.path,
                    use_https=True,
                    cookie_file=cookie_stuff.get('cookie_file'),
                    cookie_pem=cookie_stuff.get('cookie_pem'),
                    cookie_key=cookie_stuff.get('cookie_key'))
예제 #2
0
def open_statuses(location):
    if os.path.isfile(location):
        with open(location, 'r') as input_file:
            return json.load(input_file)

    components = urlparse.urlparse(location)
    cookie_stuff = serverconfig.config_dict()['data']

    return get_json(components.netloc,
                    components.path,
                    use_https=True,
                    cookie_file=cookie_stuff.get('cookie_file'),
                    cookie_pem=cookie_stuff.get('cookie_pem'),
                    cookie_key=cookie_stuff.get('cookie_key'))
예제 #3
0
    def cluster(self):
        """
        The function is only accessible to someone with a verified account.

        Navigating to ``https://localhost:8080/cluster``
        causes the server to regenerate the clusters that it has stored.
        This is useful when the history database of past errors has been
        updated with relevant errors since the server has been started or
        this function has been called.

        :returns: a confirmation page
        :rtype: str
        """
        data = serverconfig.config_dict()['data']
        self.clusterer = clusterworkflows.get_clusterer(
            data['workflow_history'], data['all_errors'])
        return render('complete.html')
예제 #4
0
    def update(self):

        self.lock.acquire()
        self.workflows = {}

        try:
            for workflow in statuses.get_manual_workflows(
                    serverconfig.config_dict()['data']['all_errors']):
                self.get(workflow)

            self.prepids = {
                prepid: workflowinfo.PrepIDInfo(prepid)
                for prepid in
                [info.get_prep_id() for info in self.workflows.values()]
            }

            self.update_statuses()

        finally:
            self.lock.release()
예제 #5
0
    def reportaction(self):
        """
        A POST request to ``https://localhost:8080/reportaction``
        tells the WorkflowWebTools that a set of workflows has been acted on by Unified.
        The body of the POST request must include a JSON with the passphrase
        under ``"key"`` and a list of workflows under ``"workflows"``.

        An example of making this POST request is provided in the file
        ``WorkflowWebTools/test/report_action.py``,
        which relies on ``WorkflowWebTools/test/key.json``.

        :returns: A JSON summarizing results of the request. Keys and values include:

                  - `'valid_key'` - If this is false, the passphrase passed was wrong,
                                    and no action is changed
                  - `'valid_format'` - If false, the input format is unexpected
                  - `'success'` - List of actions that have been marked as acted on
                  - `'already_reported'` - List of workflows that were already removed
                  - `'does_not_exist'` - List of workflows that the database does not know

        :rtype: JSON
        """

        input_json = cherrypy.request.json

        # Is the input good?
        goodkey = (
            input_json['key'] == serverconfig.config_dict()['actions']['key'])
        goodformat = isinstance(input_json['workflows'], list)

        output = {'valid_key': goodkey, 'valid_format': goodformat}

        if goodkey and goodformat:
            # This output is added to by passing reference to manageactions.report_actions
            manageactions.report_actions(input_json['workflows'], output)

        return output