예제 #1
0
def on_arrival(reg, nat):
    if reg in region_names:
        with rlocks[reg]:
            regions[reg].add(nat)
            try:
                entry = zombie_scan.scan_nation(nat)
            except zombie_scan.ZombiesCloaked:
                entry = zombie_init.init_nation(nat)
            with dblock:
                db[nat] = entry
        rcache.pop(reg, None)
예제 #2
0
def on_arrival(reg, nat):
    if reg in region_names:
        with rlocks[reg]:
            regions[reg].add(nat)
            try:
                entry = zombie_scan.scan_nation(nat)
            except zombie_scan.ZombiesCloaked:
                entry = zombie_init.init_nation(nat)
            with dblock:
                db[nat] = entry
        rcache.pop(reg, None)
예제 #3
0
if os.path.isfile("zombies.json"):
    db = json.load(open('zombies.json','r'))
    hour_ago = time.gmtime(time.time()-3600)
    for nat in db:
        if "ts" in db[nat]:
            db[nat]["ts"] = time.gmtime(db[nat]["ts"])
        else:
            db[nat]["ts"] = hour_ago
    zcloak = False
    for nat in set.union(*regions.values()) - frozenset(db.keys()):
        if not zcloak:
            try:
                entry = zombie_scan.scan_nation(nat)
            except zombie_scan.ZombiesCloaked:
                zcloak = True
                entry = zombie_init.init_nation(nat)
        else:
            entry = zombie_init.init_nation(nat)
        db[nat] = entry
else:
    ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f %Z")
    print "{0} Initializing zombie data for the regions {1} (this may take a while)".format(ts, list(region_names))
    db = zombie_init.initialize_nations(set.union(*regions.values()))
    ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f %Z")
    print "{0} Initialized zombie data, saving to zombies.json".format(ts)
    save()
    ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f %Z")
    print "{0} Saved initial zombie data to zombies.json".format(ts)

def on_arrival(reg, nat):
    if reg in region_names:
예제 #4
0
if os.path.isfile("zombies.json"):
    db = json.load(open('zombies.json', 'r'))
    hour_ago = time.gmtime(time.time() - 3600)
    for nat in db:
        if "ts" in db[nat]:
            db[nat]["ts"] = time.gmtime(db[nat]["ts"])
        else:
            db[nat]["ts"] = hour_ago
    zcloak = False
    for nat in set.union(*regions.values()) - frozenset(db.keys()):
        if not zcloak:
            try:
                entry = zombie_scan.scan_nation(nat)
            except zombie_scan.ZombiesCloaked:
                zcloak = True
                entry = zombie_init.init_nation(nat)
        else:
            entry = zombie_init.init_nation(nat)
        db[nat] = entry
else:
    ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f %Z")
    print "{0} Initializing zombie data for the regions {1} (this may take a while)".format(
        ts, list(region_names))
    db = zombie_init.initialize_nations(set.union(*regions.values()))
    ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f %Z")
    print "{0} Initialized zombie data, saving to zombies.json".format(ts)
    save()
    ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f %Z")
    print "{0} Saved initial zombie data to zombies.json".format(ts)