예제 #1
0
파일: plugin.py 프로젝트: bbcf/bs
 def index(self, ordered=False):
     """
     Get all plugins available
     @param ordered: if you want a nested json based on
     plugins paths
     """
     user = util.get_user(tg.request)
     if user.is_service:
         d = {'plugins': operations.get_plugins_path(service=user, ordered=ordered)}
     else:
         d = {'plugins': operations.get_plugins_path(ordered=ordered)}
     return d
예제 #2
0
파일: plugin.py 프로젝트: yjarosz/bs
 def index(self, ordered=False):
     """
     Get all plugins available
     @param ordered: if you want a nested json based on
     plugins paths
     """
     user = util.get_user(tg.request)
     if user.is_service:
         d = {
             'plugins':
             operations.get_plugins_path(service=user, ordered=ordered)
         }
     else:
         d = {'plugins': operations.get_plugins_path(ordered=ordered)}
     return d
예제 #3
0
파일: job.py 프로젝트: bbcf/bs
    def statistics(self):
        jobs = DBSession.query(Job).join(PluginRequest).order_by(asc(PluginRequest.date_done)).all()

        # get number of jobs / month, days, ...
        d = {'months' : [0] * 12, 
            'days': [0] * 7,
            'hours': [0] * 24,
            'users': {},
            'plugins': {}
            }
        # set all users to prevent looking if user alrady set for each jobs
        users = DBSession.query(User).all()
        for user in users:
             d['users'][user.name] = 1
        # do the same for all plugin
        plugs = operations.get_plugins_path(ordered=False)
        for plug in plugs:
            d['plugins'][plug['info']['title']] = 1

        # now look at each jobs one by one
        for job in jobs:
            dd = job.request.date_done.strftime('%m %w %H').split()         
            currentday = int(dd[1])
            d['months'][int(dd[0]) - 1] += 1
            d['days'][currentday] += 1
            d['hours'][int(dd[2])] += 1
            d['users'][job.request.user.name] += 1
            try:
                d['plugins'][job.request.plugin.info['title']] += 1
            except KeyError:
                pass
        d['users'] = [{'name': k, 'value': v} for k, v in d['users'].iteritems()]
        return {'jobs': json.dumps(d)}
예제 #4
0
파일: direct.py 프로젝트: bbcf/bs
 def status(self):
     jobs = DBSession.query(Job).all()
     plugins = operations.get_plugins_path()
     mapping = {'plugins': plugins, 'nbplugins': len(plugins), 'total': len(jobs), 'running': 0, 'failure': 0, 'pending': 0, 'success': 0}
     for job in jobs:
         mapping[job.status.lower()] += 1
     return mapping
예제 #5
0
파일: root.py 프로젝트: bbcf/bs
 def index(self, *args, **kw):
     jobs = DBSession.query(Job).all()
     plugins = operations.get_plugins_path()
     mapping = {'plugins': plugins,
                'ordered': operations.get_plugins_path(ordered=True),
                'nbplugins': len(plugins),
                'total': len(jobs),
                'started': 0,
                'failure': 0,
                'pending': 0,
                'success': 0}
     for job in jobs:
         if job.status.lower() not in mapping:
             mapping['started'] += 1
         else:
             mapping[job.status.lower()] += 1
     return mapping
예제 #6
0
파일: direct.py 프로젝트: yjarosz/bs
 def status(self):
     jobs = DBSession.query(Job).all()
     plugins = operations.get_plugins_path()
     mapping = {
         'plugins': plugins,
         'nbplugins': len(plugins),
         'total': len(jobs),
         'running': 0,
         'failure': 0,
         'pending': 0,
         'success': 0
     }
     for job in jobs:
         mapping[job.status.lower()] += 1
     return mapping
예제 #7
0
    def stats(self):
        jobs = DBSession.query(Job).join(PluginRequest).order_by(
            asc(PluginRequest.date_done)).all()

        # get number of jobs / month, days, ...
        d = {
            'months': [0] * 12,
            'days': [0] * 7,
            'hours': [0] * 24,
            'users': {},
            'remotes': {},
            'plugins': {}
        }
        # set all users to prevent looking if user alrady set for each jobs
        users = DBSession.query(User).all()
        for user in users:
            d['users'][user.name] = 1
            if user.name == 'anonymous':
                d['remotes'][user.remote] = 1
        # do the same for all plugin
        plugs = operations.get_plugins_path(ordered=False)
        for plug in plugs:
            d['plugins'][plug['info']['title']] = 1

        # now look at each jobs one by one
        for job in jobs:
            dd = job.request.date_done.strftime('%m %w %H').split()
            currentday = int(dd[1])
            d['months'][int(dd[0]) - 1] += 1
            d['days'][currentday] += 1
            d['hours'][int(dd[2])] += 1
            d['users'][job.request.user.name] += 1
            if job.request.user.name == 'anonymous':
                d['remotes'][job.request.user.remote] += 1
            try:
                d['plugins'][job.request.plugin.info['title']] += 1
            except KeyError:
                pass
        d['users'] = [{
            'name': k,
            'value': v
        } for k, v in d['users'].iteritems()]
        d['remotes'] = [{
            'name': k,
            'value': v
        } for k, v in d['remotes'].iteritems()]
        return {'jobs': json.dumps(d)}