예제 #1
0
    def index(self, req, form):
        """ Display live BibSched queue
        """
        referer = '/admin2/bibsched/'
        navtrail = ' <a class="navtrail" href=\"%s/help/admin\">Admin Area</a> ' % CFG_SITE_URL

        auth_code, auth_message = acc_authorize_action(req, 'cfgbibsched')
        if auth_code != 0:
            return page_not_authorized(req=req, referer=referer,
                                       text=auth_message, navtrail=navtrail)

        bibsched_tasks = get_bibsched_tasks()
        header = ["ID", "Name", "Priority", "User", "Time", "Status",
                  "Progress"]
        map_status_css = {'WAITING': 'task_waiting', 'RUNNING': 'task_running',
                          'DONE WITH ERRORS': 'task_error'}
        bibsched_error = False
        motd_msg = get_motd_msg()
        actions = []
        body_content = ''
        if len(motd_msg) > 0:
            body_content += '<div class="clean_error">' + motd_msg + '</div><br />'
        if 'jsondata' not in form:
            body_content = '<div id="bibsched_table">'
        if bibsched_tasks:
            for task in bibsched_tasks:
                tskid, proc, priority, user, runtime, status, progress = task
                actions.append([tskid, proc, priority, user, runtime,
                               '<span class=%s>' % (status in map_status_css and
                                map_status_css[status] or '') + (status != "" and
                                status or '') + '</span>', (progress != "" and
                                progress or '')])
                if 'ERROR' in status:
                    bibsched_error = True
            body_content += tupletotable(header=header, tuple=actions,
                                         alternate_row_colors_p=True)
        if bibsched_error:
            body_content += '<br /><img src="%s"><span class="bibsched_status"> The queue contains errors</span><br />' % ("/img/aid_reject.png")
        else:
            body_content += '<br /><img src="%s"><span class="bibsched_status"> BibSched is working without errors</span><br />' % ("/img/aid_check.png")
        body_content += '<br /><span class="mode">Mode: %s</span>' % (get_bibsched_mode())
        body_content += '<br /><br /><span class="last_updated">Last updated: %s</span>' % \
                (time.strftime("%a %b %d, %Y  %-I:%M:%S %p",
                 time.localtime(time.time())))
        if 'jsondata' in form:
            json_response = {}
            json_response.update({'bibsched': body_content})
            return json.dumps(json_response)
        else:
            body_content += '</div>'
            return page(title="BibSched live view",
                        body=body_content,
                        errors=[],
                        warnings=[],
                        metaheaderadd=get_javascript() + get_css(),
                        req=req)
예제 #2
0
파일: tasks.py 프로젝트: IFCA/lifewatch_osf
    def run(self, *args, **kwargs):
        # clean up queue
        tasks = webapi.get_bibsched_tasks()
        for t in tasks:
            task_id, proc, priority, user, runtime, status, progress = t
            if 'ERROR' in status:
                logger.info("Re-init task %s", task_id)
                cli.bibsched_set_status(task_id, "WAITING")
                cli.bibsched_set_progress(task_id, "")
                cli.bibsched_set_host(task_id, "")

        if webapi.get_bibsched_mode() != 'AUTOMATIC':
            # manual, put it back to auto
            logger.info("Putting back bibsched to auto mode")
            run_sql('UPDATE schSTATUS SET value = "" WHERE '
                    'name = "resume_after"')
            run_sql('UPDATE schSTATUS SET value = "1" WHERE '
                    'name = "auto_mode"')
예제 #3
0
파일: tasks.py 프로젝트: rsalas82/lw-daap
    def run(self, *args, **kwargs):
        # clean up queue
        tasks = webapi.get_bibsched_tasks()
        for t in tasks:
            task_id, proc, priority, user, runtime, status, progress = t
            if 'ERROR' in status:
                logger.info("Re-init task %s", task_id)
                cli.bibsched_set_status(task_id, "WAITING")
                cli.bibsched_set_progress(task_id, "")
                cli.bibsched_set_host(task_id, "")

        if webapi.get_bibsched_mode() != 'AUTOMATIC':
            # manual, put it back to auto
            logger.info("Putting back bibsched to auto mode")
            run_sql('UPDATE schSTATUS SET value = "" WHERE '
                    'name = "resume_after"')
            run_sql('UPDATE schSTATUS SET value = "1" WHERE '
                    'name = "auto_mode"')
예제 #4
0
    def index(self, req, form):
        """ Display live BibSched queue
        """
        referer = '/admin2/bibsched/'
        navtrail = ' <a class="navtrail" href=\"%s/help/admin\">Admin Area</a> ' % CFG_SITE_URL

        auth_code, auth_message = acc_authorize_action(req, 'cfgbibsched')
        if auth_code != 0:
            return page_not_authorized(req=req,
                                       referer=referer,
                                       text=auth_message,
                                       navtrail=navtrail)

        bibsched_tasks = get_bibsched_tasks()
        header = [
            "ID", "Name", "Priority", "User", "Time", "Status", "Progress"
        ]
        map_status_css = {
            'WAITING': 'task_waiting',
            'RUNNING': 'task_running',
            'DONE WITH ERRORS': 'task_error'
        }
        bibsched_error = False
        motd_msg = get_motd_msg()
        actions = []
        body_content = ''
        if len(motd_msg) > 0:
            body_content += '<div class="clean_error">' + motd_msg + '</div><br />'
        if 'jsondata' not in form:
            body_content = '<div id="bibsched_table">'
        if bibsched_tasks:
            for task in bibsched_tasks:
                tskid, proc, priority, user, runtime, status, progress = task
                actions.append([
                    tskid, proc, priority, user, runtime,
                    '<span class=%s>' %
                    (status in map_status_css and map_status_css[status] or '')
                    + (status != "" and status or '') + '</span>',
                    (progress != "" and progress or '')
                ])
                if 'ERROR' in status:
                    bibsched_error = True
            body_content += tupletotable(header=header,
                                         tuple=actions,
                                         alternate_row_colors_p=True)
        if bibsched_error:
            body_content += '<br /><img src="%s"><span class="bibsched_status"> The queue contains errors</span><br />' % (
                "/img/aid_reject.png")
        else:
            body_content += '<br /><img src="%s"><span class="bibsched_status"> BibSched is working without errors</span><br />' % (
                "/img/aid_check.png")
        body_content += '<br /><span class="mode">Mode: %s</span>' % (
            get_bibsched_mode())
        body_content += '<br /><br /><span class="last_updated">Last updated: %s</span>' % \
                (time.strftime("%a %b %d, %Y  %-I:%M:%S %p",
                 time.localtime(time.time())))
        if 'jsondata' in form:
            json_response = {}
            json_response.update({'bibsched': body_content})
            return json.dumps(json_response)
        else:
            body_content += '</div>'
            return page(title="BibSched live view",
                        body=body_content,
                        errors=[],
                        warnings=[],
                        metaheaderadd=get_javascript() + get_css(),
                        req=req)