def checkcache(itemname, filename='importvars/asn.cache', incachedir='importvars/mycache'): ''' checks cached asns; else, does a new query and stores result in cache''' retval = '?' cachedir = df.rightdir(df.getdir(__file__) + incachedir) if len(itemname) >= 7 and '.' in itemname: tmpfname = cachedir + itemname.split('.')[0] + '.cache' data = defaultdict(str, df.pjsonin(tmpfname)) tmpval = data[itemname] if df.isint(tmpval) or tmpval == 'NA': retval = tmpval elif tmpval == str(): asn = None try: asn = af.asn_lookup(itemname) except: pass if asn is None: data[itemname] = '?' else: data[itemname] = asn retval = asn df.pjsonout(tmpfname, dict(data), 'w') return retval
################################################################## import logging import logging.config logging.config.fileConfig('logging.conf', disable_existing_loggers=False) # create logger logger = logging.getLogger(__name__) logger.debug(__name__ + "logger loaded") ################################################################## # GLOBAL AND SETUP ################################################################## # paths basedir = df.getdir(__file__) + '../' statedir = df.rightdir(basedir + 'state/') rawdirlist = df.getlines(basedir + 'state/datapaths.list') datafiles = df.listfiles(basedir + rawdirlist[0], fullpath=True) plotsdir = df.rightdir(basedir + "plots/") ################################################################## # CODE ################################################################## def get_ansset_sizes(start_time, fname="", **kwas): ''' :param start_time: int indicating the earliest query the window should include :param **kwas: keyword arguments for vv.get_svl() :return: (m) matrix of client pairs vs domains,