Beispiel #1
0
def updated_as_timestamp(updated):
    import re
    from vyperlogix.lists.ListWrapper import ListWrapper
    try:
        _reOtherDate = re.compile(r"(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])T((([0]?[1-9]|1[0-2])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?))\+(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?)")
        if (not isinstance(updated,datetime.datetime)):
            matches = _reOtherDate.search(updated)
            try:
                return _utils.getFromDateStr(updated.split('+')[0].strip(),format=_utils.formatMetaHeaderExpiresOn()) if (not matches) else _utils.getFromDateStr(updated.split('+')[0],format=_utils._formatTimeStr())
            except:
                return _utils.getFromDateStr(updated,format=_utils.formatMetaHeaderExpiresOnZ())
    except Exception, e:
        #info_string = _utils.formattedException(details=e)
        try:
            return _utils.getFromDateStr(updated.split('+')[0].strip(),format=_utils._formatTimeStr())
        except:
            fmt = make_sense_of_time_string(updated)
            try:
                return _utils.getFromDateStr(updated,format=fmt)
            except Exception, e:
                info_string = _utils.formattedException(details=e)
                toks_fmt = fmt.split()
                toks = updated.split()
                if (toks_fmt[-1] == '%Z'):
                    del toks_fmt[-1]
                    del toks[-1]
                    updated = ' '.join(toks)
                    fmt = ' '.join(toks_fmt)
                try:
                    return _utils.getFromDateStr(updated,format=fmt)
                except Exception, e:
                    info_string = _utils.formattedException(details=e)
                    #logging.warning(info_string)
                pass
Beispiel #2
0
    for job in jobs:
        job.runnable = so.reason.lower() != 'success'
        logger.info('(2) Job %s is %s' % (so.id, so.reason))
        job.save()
        __cache__[job.taskid] = job.runnable

jobs = ScheduledJob.objects.all()

for job in jobs:
    job.delete()

job = ScheduledJob()
job.taskid = 1
job.taskname = 'Job_%s' % (job.taskid)
job.created_at = job.modified_at = _utils.today_localtime()
job.run_at = _utils.getFromNativeTimeStamp(_utils.getAsDateTimeStrFromTimeSeconds(_utils.today_localtime_as_seconds()+11),format=_utils._formatTimeStr())
job.info = '''
    print "TESTING..."
'''
job.runnable = True
job.save()

jobs = ScheduledJob.objects.all()

for job in jobs:
    print job.details()
    __cache__[job.taskid] = job.runnable
    
__scheduler__.logger = logger
__scheduler__.db_callback = db_callback
__scheduler__.callback = callback