Example #1
0
 def __init__(self, idnum):
     self.__id = idnum
     self.__url_addr = []
     self.__file_name = []
     self.__pic_type = []
     self.__logger = wtclib.create_logging(
         '../log/downfilelog/thread%d.log' % idnum)
     threading.Thread.__init__(self)
Example #2
0
 def __init__(self):
     self.__logger = wtclib.create_logging(
         '../log/leddisplog/udpserver.log')
     while True:
         (_cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
         if None != _cur:
             break
         else:
             self.__logger.info(err)
             time.sleep(20)
     self.__cur = _cur
     del _cur
     threading.Thread.__init__(self)
Example #3
0
            "slot_bitmap": sql[7]
        }

    return info


if __name__ == '__main__':
    global mylogger
    if not os.path.isdir("../log/downfilelog"):
        try:
            os.mkdir("../log/downfilelog")
        except Exception, e:
            print e
            os._exit()
    #mylogger = create_logging("downfilelog/Mthread.log")
    mylogger = wtclib.create_logging("../log/downfilelog/Mthread.log")
    mylogger.info("start running")
    if not os.path.isdir(DIRECTION_SAVE_FILES):
        try:
            os.mkdir(DIRECTION_SAVE_FILES)
        except Exception, e:
            print e
            mylogger.error(str(e))
            os._exit()

    (val, err) = get_ucmq_url()
    if 0 == val:
        mylogger.error("can not get ucmq url return " + err)
        os._exit()
    del val, err
    (Aimq, Remq) = get_a_rabbitmq_channel()
Example #4
0
    addr = socket.inet_ntoa(fcntl.ioctl(s.fileno(), \
                                        0x8915, \
                                        struct.pack('256s', ifname[:15]))[20:24])
    return addr


if __name__ == '__main__':
    global mylogger
    if not os.path.isdir("../log/udplog"):
        try:
            os.mkdir("../log/udplog")
        except Exception, e:
            print e
            os._exit()
    addr = get_ip_addr("eth0")
    mylogger = wtclib.create_logging("../log/udplog/udpbroadtest.log")
    mylogger.info("start running")
    cnt = 10
    while True:
        struct_time = time.localtime()
        time_str = '%d-%02d-%02d %02d:%02d:%02d' % (
            struct_time.tm_year, struct_time.tm_mon, struct_time.tm_mday,
            struct_time.tm_hour, struct_time.tm_min, struct_time.tm_sec)
        time_strF = str(time.time())
        msg = {"AISERVERIP": "192.168.7.19", "AIport": RECEIVE_PORT, "timenow": time_str, "timstr":time_strF, \
               "sec":Encrypt(time_strF), "AIsn":"1710460123", "AIHW":"AIBC", "VERSION":"1.00"}
        Udp_broadcast(msg, UDP_BROADCAST_PORT)
        time.sleep(3)
        cnt -= 1
        if cnt < 0:
            cnt = 100
Example #5
0
        dirs = cf.get("file_save", "root_dir")
        return dirs
    except Exception, e:
        #mylog.error(str(e) + ' get file_save')
        return None


if __name__ == '__main__':

    if not os.path.isdir("../log/leddisplog"):
        try:
            os.mkdir("../log/leddisplog")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    mylog = wtclib.create_logging("../log/leddisplog/ledplayer.log")
    mylog.info("start")

    while True:
        (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
        if None != cur:
            break
        else:
            mylog.info(err)
            time.sleep(20)
    create_qld_db(cur)
    mylog.warning(cur.connection)
    mylog.warning(cur.messages)
    if None == cur:
        mylog.error("connect to db fail")
        os._exit()
Example #6
0
import ConfigParser
import json
import os
import time

import pika

from bin import wtclib

if not os.path.isdir("../log/airet"):
    try:
        os.mkdir("../log/airet")
    except Exception, e:
        print e
        os._exit()
mylogger = wtclib.create_logging("../log/airet/ai2getyuv.log")
mylogger.info("start running")
while True:
    (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
    if None != cur:
        break
    else:
        mylogger.info("can not connect to db and sleep 20")
        time.sleep(20)


def msg_consumer(channel, method, header, body):
        #channel.basic_ack(delivery_tag=method.delivery_tag)
        global cur, mylogger
        #test = cur.execute("select * from ScreenConfigTable")
        _dic_info = json.loads(body)
Example #7
0
import ConfigParser
import json
import os
import time

import pika

from bin import wtclib

if not os.path.isdir("../log/airet"):
    try:
        os.mkdir("../log/airet")
    except Exception, e:
        print e
        os._exit()
mylogger = wtclib.create_logging("../log/airet/ai2led.log")
mylogger.info("start running")
while True:
    (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
    if None != cur:
        break
    else:
        mylogger.info("can not connect to db and sleep 20")
        time.sleep(20)


def msg_consumer(channel, method, header, body):
    #channel.basic_ack(delivery_tag=method.delivery_tag)
    global cur, mylogger
    #test = cur.execute("select * from ScreenConfigTable")
    _dic_info = json.loads(body)
Example #8
0
    return {
        "ret": 1,
        "root_dir": root_dir,
        "fullsizeD": fullsize_days,
        "aisizeD": aisize_days
    }


if __name__ == '__main__':
    if not os.path.isdir("rmfilelog"):
        try:
            os.mkdir("rmfilelog")
        except Exception, e:
            print e
            os._exit()
    mylogger = wtclib.create_logging("rmfilelog/rmfile.log")
    mylogger.info("start running")
    conf = get_save_days()
    if 0 == conf["ret"]:
        root_dir = os.environ["HOME"] + "/hvpd/"
        fullsize_days = 10
        aisize_days = 30
    else:
        root_dir = conf["root_dir"]
        if not os.path.isabs(root_dir):
            root_dir = os.environ["HOME"] + '/' + root_dir
        fullsize_days = conf["fullsizeD"]
        aisize_days = conf["aisizeD"]
    timet = time.time()
    local = time.localtime(timet)
    #dirs = os.listdir(os.getcwd())
Example #9
0
import time
import json
import urllib
import urllib2
import os, sys
import requests
from bin import wtclib
import ConfigParser

if not os.path.isdir("../log/airet"):
    try:
        os.mkdir("../log/airet")
    except Exception, e:
        print str(e) + " in line: " + str(sys._getframe().f_lineno)
        os._exit()
mylogger = wtclib.create_logging("../log/airet/ai2filter.log")
mylogger.info("start running")
while True:
    (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
    if None != cur:
        break
    else:
        mylogger.info("can not connect to db and sleep 20")
        time.sleep(20)

_cf = ConfigParser.ConfigParser()
try:
    _cf.read("../conf/conf.conf")
except Exception, e:
    mylogger.error(str(e))
    os._exit(0)
Example #10
0
        filename = a1[4]
        ret = http_download_file_device(filename, ctrlTable, "upgrade")
        if 200 == ret:
            strInfo = "delete from AIChangeMQ where id=%d" % a1[0]
            cur.execute(strInfo)


if __name__ == '__main__':
    global mylogger
    if not os.path.isdir("../log/sqlmqlog"):
        try:
            os.mkdir("../log/sqlmqlog")
        except Exception, e:
            print e
            os._exit()
    mylogger = wtclib.create_logging("../log/sqlmqlog/checksql.log")
    mylogger.info("start running")
    cur = connect_2_sql()
    if None == cur:
        mylogger.error("can not get db")
        sys.exit()
    cnt = 100
    while True:
        #print time.clock()
        check_sqlMQ_LAMP_msg(cur)
        check_sql_rephoto_msg(cur)
        check_sql_parkingline_msg(cur)
        check_sql_upgrade_msg(cur)
        #print time.clock()
        time.sleep(0.5)
        cnt -= 1
Example #11
0
import urllib, urllib2, time, json
import os,sys
import socket
import pika
import MySQLdb
import Queue
import threading
from bin import wtclib
import ConfigParser
import math

mylogger = wtclib.create_logging("NewDeviceSetup.log")
mylogger.info("start running")

def ucmq_get_msg(ucmq_url):
    global mylogger
    while True:
        while True:
            try:
                res_data = urllib2.urlopen(ucmq_url)
                break
            except urllib2.URLError, e:
                print str(e) + " in line: " + str(sys._getframe().f_lineno)
                mylogger.info(str(e))
                time.sleep(20)
                continue
        res = res_data.read()
        mq_str = res.split('\n')
        #print mq_str[0]
        ret_str = mq_str[0].rstrip('\r')
        if (ret_str != "UCMQ_HTTP_OK"):
Example #12
0
                continue
            cur.execute(
                "update HvpdUpgradeTable set ReNewFlag=0, end_time=now()")
            time.sleep(0.5)
    except:
        pass


if __name__ == '__main__':
    if not os.path.isdir("../log/upgradelog"):
        try:
            os.mkdir("../log/upgradelog")
        except Exception, e:
            print str(e) + " in line: " + str(sys._getframe().f_lineno)
            os._exit()
    mylogger = wtclib.create_logging("../log/upgradelog/upgrade.log")
    mylogger.info("start running")
    while True:
        (cur, err) = wtclib.get_a_sql_cur("../conf/conf.conf")
        if None == cur:
            time.sleep(20)
        else:
            break

    _pid = os.getpid()
    try:
        cur.execute(
            "insert into WatchdogTable(pid, runCMD,watchSeconds,renewTimet)values(%d, "
            "'python %s &', 130, %d)" % (_pid, __file__, int(time.time())))
    except Exception, e:
        mylogger.error(str(e) + time.asctime())