def save(conf): raw = const.CONF_HEADER data = { "DNSOMATIC":{"username":conf.uname, 'password':base64.b64encode(conf.password), 'hosts':conf.host}, "DINO":{'updelay':conf.updelay} } for section in data.keys(): raw += "\n[%s]\n" %section for key in data[section].keys(): raw += "%s=%s\n" %(key, data[section][key]) if os.getuid(): if not lib.savefile(const.CONF_FILE_TMP, raw): return(False) if subprocess.call([const.CONF_SAVETOETC], shell=True ): return(False) else: if not lib.savefile(const.CONF_FILE, raw): return(False) return(True)
def save(self): # raw = "#This is POG Configuration File" raw += "\n\n["+const.OPT_OPENDNS_KEY+"]" raw += self.createNode(const.OPT_OPENDNS_KEY, const.OPT_OPENDNS_UNAME) raw += self.createNode(const.OPT_OPENDNS_KEY, const.OPT_OPENDNS_PASS) raw += self.createNode(const.OPT_OPENDNS_KEY, const.OPT_OPENDNS_NETWORK) raw += "\n\n["+const.OPT_POG_KEY+"]" raw += self.createNode(const.OPT_POG_KEY, const.OPT_POG_UPDELAY) if not lib.savefile(self.__file, raw): return(False) os.chmod(self.__file, stat.S_IRUSR | stat.S_IWUSR) return(True)
def save(delay): newRaw = "" isFound = False raw = lib.getfile(const.CRONTAB_FILE) if not raw: return(False) for line in raw.splitlines(): if line.find(const.CRONTAB_ENTRY_SIGN) <> -1: isFound = True if int(delay) <> 0: newRaw += const.CRONTAB_ENTRY %(delay) else: newRaw += line+"\n" if not isFound and int(delay) <> 0: newRaw += const.CRONTAB_ENTRY %(delay) if not lib.savefile(const.CRONTAB_FILE, newRaw): return(False) return(True)