def get_serverID(): _dict = wtclib.get_user_config_ret_dict("../conf/id.conf", "system") if not "serverid" in _dict: _dict.update({"serverid": "1710890123"}) wtclib.set_user_config_from_dict("../conf/id.conf", "system", _dict) return _dict["serverid"]
def get_serverID(): _dict = wtclib.get_user_config_ret_dict("../conf/id.conf", "system") if not "serverid" in _dict: serverID = make_serverID() _dict.update({"serverid": serverID}) wtclib.set_user_config_from_dict("../conf/id.conf", "system", _dict) else: serverID = _dict["serverid"] return serverID
import os, time import wtclib if __name__ == '__main__': local = time.localtime() _today = "%d-%02d-%02d %02d%02d%02d -b yan" % ( local.tm_year, local.tm_mon, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec) _dic = { "createdb": "%s" % _today, "ai2filter": "%s" % _today, "ai2getyuv": "%s" % _today, "ai2lamp": "%s" % _today, "aifilter": "%s" % _today, "configfiles": "%s" % _today, "downloadpic": "%s" % _today, "ledplayer": "%s" % _today, "ai_shell": "%s" % _today, "re_shell": "%s" % _today } wtclib.set_user_config_from_dict("bin/aisoftversion.ini", "version", _dic)
str1 = "@%d"%(os.getpid()) print cmd + str1 os.system(cmd) #os.system("pause") time.sleep(10) def python_cmd_once(cmd): os.system(cmd) if __name__ == '__main__': id1 = wtclib.get_serverID() ucmq_dict = wtclib.get_user_config_ret_dict("../ucmq/conf/ucmq.ini", "server") conf_dict = wtclib.get_user_config_ret_dict("../conf/conf.conf", "ucmq") eth_addr = wtclib.get_ip_addr1("eth0") if "server_addr" in conf_dict and eth_addr != conf_dict["server_addr"]: #when set the ucmq server,ucmq is running in other pc #wtclib.set_user_config_from_dict("../ucmq/conf/ucmq.ini", "server", {"wtc":eth_addr}) #path1 = os.getcwd() #path2 = path1[0:path1.rfind('/')] #cmd1 = path2+"/ucmq/bin/ucmq -c "+path2+"/conf/ucmq.ini -d" print "ucmq is running in %s"%conf_dict["server_addr"] else: if eth_addr != ucmq_dict["http_listen_addr"]: wtclib.set_user_config_from_dict("../ucmq/conf/ucmq.ini", "server", {"http_listen_addr": eth_addr}) cmd2 = "../ucmq/bin/ucmq -c ../ucmq/conf/ucmq.ini &" thread.start_new_thread(python_cmd_once, (cmd2,)) time.sleep(0.5) print "ucmq is running in %s"%eth_addr #while True: # time.sleep(3600)
sleep 1 python createdb.pyc chmod 666 /tmp/softdog.db sleep 3\n""") if 0 != _ai_ip and '0' != _Co_server: sqlite_cur.execute("update setting set val='1' where name='Co_server'") sqlite_cur.execute("update setting set val='%s' where name='ai_ip'" % (_ai_ip)) _localt = time.localtime() _dst = 'conf.%d%02d%02d.%02d%02d%02d' % ( _localt.tm_year, _localt.tm_mon, _localt.tm_mday, _localt.tm_hour, _localt.tm_min, _localt.tm_sec) shutil.copy('../../../hvpd/prog/conf/conf.conf', '../../../hvpd/prog/conf/%s' % _dst) wtclib.set_user_config_from_dict('../../../hvpd/prog/conf/conf.conf', 'ucmq', {'server_addr': _ai_ip}) wtclib.set_user_config_from_dict('../../../hvpd/prog/conf/conf.conf', 'db', {'location': _ai_ip}) else: sqlite_cur.execute("update setting set val='0' where name='Co_server'") sqlite_cur.execute("update setting set val='0' where name='ai_ip'") wtclib.set_user_config_from_dict('../../../hvpd/prog/conf/conf.conf', 'ucmq', {'server_addr': ''}) wtclib.set_user_config_from_dict('../../../hvpd/prog/conf/conf.conf', 'db', {'location': ''}) fp.write("python udpbroad0.pyc &\n") if '1' != _ai_f: sqlite_cur.execute("update setting set val='0' where name='ai_f'") fp.write("python amqp_consumer.pyc &\n") else: