def fill_mock(curtime=None): import re re_proddir = re.compile(r"(?P<reftime>\d+-\d+)-(?P<simclogname>.+)") if curtime is None: curtime = utcnow() max_reftime = curtime if max_reftime.hour > 12: max_reftime = max_reftime.replace(hour=12, minute=0, second=0, microsecond=0) else: max_reftime = max_reftime.replace(hour=0, minute=0, second=0, microsecond=0) simclog_models = {} for name, info in settings.MMIXER_DSMAP.items(): simclog_models[name] = m = Model.objects.create( name=info["simclogname"], description="test {} {}".format(name, info["simclogname"]), wiki="") for fn in os.listdir(settings.MMIXER_PRODUCT_DIR): mo = re_proddir.match(fn) if not mo: continue reftime = datetime.datetime.strptime(mo.group("reftime"), "%Y%m%d-%H").replace(tzinfo=utc) if m.name.replace(";", "-") != mo.group("simclogname"): continue Import.objects.create( entity=m, reftime=reftime, timestamp=reftime + datetime.timedelta(minutes=14, seconds=42), message="", ctime=reftime + datetime.timedelta(minutes=14, seconds=53)) return simclog_models
def list_runs(ts_now=None): """ Enumerate timestamps for possible runs in the last 24 hours """ if ts_now is None: ts_now = utcnow() # Starting point, multiple of 12 hours start = ts_now - datetime.timedelta(hours=25) if start.hour < 12: start = start.replace(hour=12, minute=0, second=0, microsecond=0) else: start = (start + datetime.timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0) while start < ts_now: # FIXME: temporarily disable 12:00 runs, until the rest of the # toolchain can be updated to handle them if start.hour != 12: yield start start += datetime.timedelta(hours=12)