def __init__(self, file_path=""): LOG.info(u"session path:{}".format(file_path)) self.file_path = file_path self.session = {} if self.file_path == "": LOG.error("session file path is empty which shouldn't happen") elif os.path.isfile(self.file_path): with open(self.file_path, "rb") as f: self.session = cPickle.load(f)
def __init__(self, file_path=None, file_type="json"): LOG.info(u"cfg path:{}".format(file_path)) self.path = file_path self.type = file_type if self.path is None: LOG.error("cfg file path is None which shouldn't happen") elif not os.path.isfile(self.path): with open(self.path, "w") as f: if "json" == file_type: json.dump(CFG_JSON, f, sort_keys=True, indent=4, separators=(',', ': ')) elif "ini" == file_type: f.write(CFG_INI)