コード例 #1
0
 def print_chgsets(self, db, print_meta=False):
     for c in db.chgsets_find(state=[
             db.STATE_CLOSED, db.STATE_OPEN, db.STATE_ANALYZING2,
             db.STATE_REANALYZING, db.STATE_DONE
     ]):
         cid = c['cid']
         meta = db.chgset_get_meta(cid)
         info = db.chgset_get_info(cid)
         #print 'cset=', pprint.pprint(data)
         if 'comment' in meta['tag'].keys():
             comment = meta['tag']['comment']
         else:
             comment = '-no comment-'
         if 'source' in meta['tag'].keys():
             source = "source='" + meta['tag']['source'] + "'"
         else:
             source = ''
         timestamp = oc.Changeset.get_timestamp(meta)[1]
         htimestamp = HumanTime.date2human(timestamp)
         print u"  {} \'{}\' {} ('{}') '{}' state={}".format(
             cid, meta['user'], htimestamp, timestamp, comment,
             info['state']).encode('ascii', 'backslashreplace')
         if print_meta:
             for k, v in meta.items():
                 print u' {0}:{1}'.format(k,
                                          v).encode('ascii',
                                                    'backslashreplace'),
             for k, v in meta.get('tags', {}).items():
                 print u' {0}:{1}'.format(k,
                                          v).encode('ascii',
                                                    'backslashreplace'),
             print
コード例 #2
0
def cset_check_drop_old(config, db, cset=None, cid=None):
    if not cset:
        cset = db.chgset_get(cid)
        if not cset:
            return True
    horizon_s = config.get('horizon_hours', 'tracker') * 3600
    if horizon_s > 0:
        now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
        dt = now - datetime.timedelta(seconds=horizon_s)
        if cset['updated'] < dt:
            logger.info('Cset {} ready to be dropped, updated {}'.format(
                cset['cid'], HumanTime.date2human(dt)))
            return True
    logger.debug('Cset {} not ready to be dropped, updated {}'.format(
        cset['cid'], cset['updated']))
    return False
コード例 #3
0
def cset_ready_for_reprocessing(config,
                                db,
                                cset=None,
                                cid=None,
                                refresh_period=0):
    if not cset:
        cset = db.chgset_get(cid)
        if not cset:
            return True
    if refresh_period > 0:
        now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
        dt = now - datetime.timedelta(minutes=refresh_period)
        if cset['refreshed'] < dt:
            logger.debug('Cset {} ready for refresh, refreshed {}'.format(
                cset['cid'], HumanTime.date2human(dt)))
            return True
    logger.debug(
        'Cset {} not ready for refresh, refreshed {}, refresh period {}'.
        format(cset['cid'], cset['refreshed'], refresh_period))
    return False
コード例 #4
0
 def print_chgsets(self, db, print_meta=False):
     for c in db.chgsets_find(state=[db.STATE_CLOSED, db.STATE_OPEN, db.STATE_ANALYZING2,
                                     db.STATE_REANALYZING, db.STATE_DONE]):
         cid = c['cid']
         meta = db.chgset_get_meta(cid)
         info = db.chgset_get_info(cid)
         #print 'cset=', pprint.pprint(data)
         if 'comment' in meta['tag'].keys():
             comment = meta['tag']['comment']
         else:
             comment = '-no comment-'
         if 'source' in meta['tag'].keys():
             source = "source='"+meta['tag']['source']+"'"
         else:
             source = ''
         timestamp = oc.Changeset.get_timestamp(meta)[1]
         htimestamp = HumanTime.date2human(timestamp)
         print u"  {} \'{}\' {} ('{}') '{}' state={}".format(cid, meta['user'], htimestamp, timestamp, comment, info['state']).encode('ascii','backslashreplace')
         if print_meta:
             for k,v in meta.items():
                 print u' {0}:{1}'.format(k,v).encode('ascii','backslashreplace'),
             for k,v in meta.get('tags',{}).items():
                 print u' {0}:{1}'.format(k,v).encode('ascii','backslashreplace'),
             print