def init(): configfile = assistant.SF("%s/filecrawler.conf" % (os.path.dirname(__file__))) print os.path.dirname(__file__) config = pysmartac.configer.openconfiger(configfile) #configer conf.pidfile = config.getstr("system", "pidfile", conf.pidfile) conf.threadCount = config.getint("system", "threadCount", conf.threadCount) conf.logLevel = config.getstr("system", "logLevel", conf.logLevel) conf.ftpServerMovieSource = config.getstr("system", "ftpServerMovieSource", conf.ftpServerMovieSource) conf.ftpServerAppSource = config.getstr("system", "ftpServerAppSource", conf.ftpServerAppSource) conf.ftpServerUser = config.getstr("system", "ftpServerUser", conf.ftpServerUser) conf.ftpServerPwd = config.getstr("system", "ftpServerPwd", conf.ftpServerPwd) conf.ftpJsonOutputPath = config.getstr("system", "ftpJsonOutputPath", conf.ftpJsonOutputPath) conf.movieOutputFile = config.getstr("system", "movieOutputFile", conf.movieOutputFile) conf.appOutputFile = config.getstr("system", "appOutputFile", conf.appOutputFile) conf.checkInterval = config.getint("system", "checkInterval", conf.checkInterval) config.save() #log settings PLOG.setlevel(conf.logLevel) PLOG.enableFilelog( assistant.SF("%s/log/FLCRAWLER_$(Date8)_$(filenumber2).log" % (os.path.dirname(__file__))))
def load(self): config = ConfigParser.ConfigParser() conf1 = assistant.SF("%s/alwayson.conf" % (os.path.dirname(__file__))) conf2 = assistant.SF("%s/alwayson.conf" % (os.getcwd())) conf3 = "/etc/alwayson.conf" if os.path.isfile(conf1): conf = conf1 elif os.path.isfile(conf2): conf = conf2 else: conf = conf3 PLOG.info("using configer file:%s" % conf) config.readfp(open(conf1, "rb")) checkinterval = config.getint("alwayson", "interval") for section in config.sections(): try: if section == "alwayson": continue name = section newprog = program(name) newprog.command = config.get(section, "command") newprog.runpath = config.get(section, "runpath") # newprog.matchingregular=config.get(section, "matchingregular") newprog.matchingstring = config.get(section, "matchingstring") newprog.pidfile = config.get(section, "pidfile") newprog.bootwait = config.getint(section, "bootwait") newprog.rebootwait = config.getint(section, "rebootwait") newprog.enabled = config.getboolean(section, "enabled") newprog.init(self) PLOG.info("confim:%s" % name) except: PLOG.error("read configerfile failed!program=%s,Pass!" % name) continue self.programlist.append(newprog)
def init(): configfile = assistant.SF("%s/filecrawler.conf" % (os.path.dirname(__file__))) print os.path.dirname(__file__) config = pysmartac.configer.openconfiger(configfile) #configer conf.pidfile = config.getstr("system", "pidfile", conf.pidfile) conf.threadCount = config.getint("system", "threadCount", conf.threadCount) conf.logLevel = config.getstr("system", "logLevel", conf.logLevel) conf.httpServerSite = config.getstr("system", "httpserversite", conf.httpServerSite) conf.movieDir = config.getstr("system", "movieDir", conf.movieDir) conf.appDir = config.getstr("system", "appDir", conf.appDir) conf.movieOutputFile = config.getstr("system", "movieOutputFile", conf.movieOutputFile) conf.appOutputFile = config.getstr("system", "appOutputFile", conf.appOutputFile) conf.checkInterval = config.getint("system", "checkInterval", conf.checkInterval) config.save() #log settings PLOG.setlevel(conf.logLevel) PLOG.enableFilelog("%s/log/FLCRAWLER_$(Date8)_$(filenumber2).log" % (os.path.dirname(__file__)))
def init(): configfile=assistant.SF("%s/filecrawler.conf"%(os.path.dirname(__file__))) print os.path.dirname(__file__) config=pysmartac.configer.openconfiger(configfile) #configer conf.logLevel=config.getstr("system","logLevel",conf.logLevel) conf.httpServerSite=config.getstr("system","httpserversite",conf.httpServerSite) conf.movieDir=config.getstr("system","movieDir",conf.movieDir) conf.iosDir=config.getstr("system","iosDir",conf.iosDir) conf.androidDir=config.getstr("system","androidDir",conf.androidDir) conf.movieOutputFile=config.getstr("system","movieOutputFile",conf.movieOutputFile) conf.iosOutputFile=config.getstr("system","iosOutputFile",conf.iosOutputFile) conf.androidOutputFile=config.getstr("system","androidOutputFile",conf.androidOutputFile) config.save() #log settings PLOG.setlevel(conf.logLevel) PLOG.enableFilelog("%s/log/FLCRAWLER_$(Date8)_$(filenumber2).log"%(os.path.dirname(__file__)))
def init(): configfile = assistant.SF("%s/radiusCheck.conf" % (os.path.dirname(__file__))) print os.path.dirname(__file__) config = pysmartac.configer.openconfiger(configfile) #configer conf.logLevel = config.getstr("system", "logLevel", conf.logLevel) conf.clientPath = config.getstr("system", "clientPath", conf.clientPath) conf.logDir = config.getstr("system", "logDir", conf.logDir) conf.radiusIP = config.getstr("system", "radiusIP", conf.radiusIP) conf.reponseTimeout = config.getint("system", "reponseTimeout", conf.reponseTimeout) conf.secret = config.getstr("system", "secret", conf.secret) config.save() #log settings PLOG.setlevel(conf.logLevel) PLOG.enableFilelog("%s/log/RADCK_$(Date8).log" % (os.path.dirname(__file__)))
def loadconfig(): config = ConfigParser.ConfigParser() configfile = assistant.SF("%s/SAPeakData.conf" % (os.path.dirname(__file__))) PLOG.info("Load configer file:%s" % configfile) config.readfp(open(configfile, "rb")) SAPeakDataPublic.st.loglevel = config.get("system", "loglevel") SAPeakDataPublic.st.queryunit = config.getint("system", "queryunit") SAPeakDataPublic.st.queryrepeattimes = config.getint( "system", "queryrepeattimes") if 24 % SAPeakDataPublic.st.queryunit != 0: PLOG.debug("queryunit is invalid,please check config!") sys.exit(2) SAPeakDataPublic.sadb.host = config.get("system", "datasource") SAPeakDataPublic.sadb.dbuser = config.get("system", "dbuser") SAPeakDataPublic.sadb.dbpwd = config.get("system", "dbpwd") SAPeakDataPublic.sadb.dbname = config.get("system", "dbname") SAPeakDataPublic.sadb.tablename = config.get("system", "tablename")
PLOG.info("report runing status:\n%s" % ret) elif msg == "stop": pass return ret class CF: pass if __name__ == "__main__": conf = CF() conf.host = "127.0.0.1" conf.port = 24001 PLOG.trace( assistant.SF("%s/log/ALS_$(Date8)_$(filenumber2).log" % (os.path.dirname(__file__)))) PLOG.enableFilelog("%s/log/ALS_$(Date8)_$(filenumber2).log" % (os.path.dirname(__file__))) try: parentpid = os.getppid() except: print "no parent id!" sys.exit(1) s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: s.bind((conf.host, conf.port)) s.settimeout(1) except Exception, e: print("绑定UDP端口失败,Host=%s,Port=%d,err=%s" % (conf.host, conf.port, e)) sys.exit(1)
except Exception, e: print "restart dog failed!err=%s" % e sys.exit(3) time.sleep(3) def status(): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.sendto("status", ("127.0.0.1", 24001)) msg, _ = s.recvfrom(65500) print msg if __name__ == "__main__": conf = "" conf1 = assistant.SF("%s/alwayson.conf" % (os.path.dirname(__file__))) conf2 = assistant.SF("%s/alwayson.conf" % (os.getcwd())) conf3 = "/smartac/alwayson/alwayson.conf" if os.path.isfile(conf1): conf = conf1 elif os.path.isfile(conf2): conf = conf2 else: conf = conf3 print("alwayson config file is:%s" % conf) config = pysmartac.configer.openconfiger(conf) #configer pidfile = os.path.join(os.path.dirname(conf), "alwayson.py.pid") dog = os.path.join(os.path.dirname(conf), "alwayson_dog.py") daemon = AlwaysonDaemon(pidfile) try: if len(sys.argv) == 2: