예제 #1
0
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    if not options.mobile:
        usage()
        exit(1)
    execute(options.mobile)
예제 #2
0
파일: send_sms.py 프로젝트: jcsy521/ydws
def main():
    ConfHelper.load("../conf/global.conf")
    parse_command_line()
    if not "send" in options:
        usage()
        exit(1)

    # domain for ydcws
    # content = ':DOMAIN www.ydcws.com:10025'
    # content = ':DOMAIN 211.139.215.236:10025'

    # domain for ichebao.net
    # content = ':DOMAIN 124.193.174.42:10025'
    # content = ':DOMAIN www.ichebao.net:10025'
    # content = ':DOMAIN 54.208.46.49:10027'

    # for Xi'an
    # content = ':DOMAIN 222.91.127.162:10024'

    # for  CIQ
    # content = ':DOMAIN 59.37.56.145:10024'

    # content = ':CQ test' # restart terminal

    # content = ':CQ' # restart terminal
    # content = ':REBOOT' # restart terminal

    # content = ':UPDATE' # update script

    # content = ':EVAL' # test script whether works well

    # content = ':JB'
    # content = ':SIM 13922256008:13751803006'
    # content = ':SIM 18823511110:14715437523'
    content = ":SIM 13600124555:14715437523"
    # content = ':DW'
    # content = 'test it'
    # content = 'SET QQ 3*c*15241589576'
    # content = u'尊敬的客户:您的定位器“14778471700”基站定位成功,地址:浙江省嘉兴市海盐县城北西路178-8号,红太阳药店附近,时间:2013-12-27,15:03:33。点击 http://www.ydcws.com/tl/nI3mUb 查看定位器位置。'
    content = u"尊敬的客户:您的定位器“粤T7A711”发生震动,请关注定位器状态,地址:广东省中山市市辖 区起湾南道71,华凯花园附近,时间:2014-01-03,07:56:12。如需取消短信提醒,请执行撤防操作。点击http://www.ydcws.com/tl/Fj2MRz 查看定位器位置。onent = 尊敬的客户,您之前参加的手机阅读精品阅读包0元打折体验优惠将于本月底到期,如需退订请发送QXJPYDB到10658080、或登录手机阅读网站/客户端进行退订操作。若不退订,下月起按正常资费(5元/月)收取。精品阅读包书单详见wap.cmread.com/iread/m/M6060282 手机阅读、给你好看,感谢您的支持。中国移动"
    content = "test....."

    if options.send.lower() == "all":
        send_all(content)
    elif options.send.lower() == "one":
        if not "mobile" in options:
            usage()
            exit(1)
        elif not options.mobile:
            usage()
            exit(1)
        # mobiles=[13703041084,13703041147,13703041294,13703041346]
        # import time
        # for mobile in mobiles:
        #     send(content, mobile)
        #     time.sleep(1)
        send(content, options.mobile)
    else:
        usage()
        exit(1)
예제 #3
0
파일: server.py 프로젝트: jcsy521/ydws
def main():
    tornado.options.parse_command_line()
    if not ('port' in options and 'conf' in options):
        import sys
        usage()
        sys.exit(1)

    if options.mode.lower() == "debug":
        debug_mode = True
    else:
        debug_mode = False

    http_server = None
    worker_pool = None
    try:
        ConfHelper.load(options.conf)
        app = Application(debug=debug_mode)

        worker_pool = WorkerPool(app.queue, int(ConfHelper.LBMP_CONF.workers))

        http_server = tornado.httpserver.HTTPServer(app, xheaders=True)
        http_server.listen(options.port)
        logging.warn("[lbmp] running on: localhost:%d", options.port)
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        logging.error("Ctrl-C is pressed.")
    except:
        logging.exception("[lbmp] Exit Exception")
    finally:
        logging.warn("[lbmp] shutdown...")
        shutdown(worker_pool, http_server)
        logging.warn("[lbmp] stopped. Bye!")
예제 #4
0
파일: mysiserver.py 프로젝트: jcsy521/ydws
    def __init__(self, conf_file):
        ConfHelper.load(conf_file)
        for i in ('port', 'count'):
            ConfHelper.SI_SERVER_CONF[i] = int(ConfHelper.SI_SERVER_CONF[i])
        self.db = None 
        self.redis = None
        # RabbitMQ
        self.rabbitmq_connection = None
        self.rabbitmq_channel = None
        self.exchange = 'ydws_exchange'
        self.gw_queue = 'ydws_gw_requests_queue@' +\
                        ConfHelper.GW_SERVER_CONF.host + ':' +\
                        str(ConfHelper.GW_SERVER_CONF.port)
        self.si_queue = 'ydws_si_requests_queue@' +\
                        ConfHelper.SI_SERVER_CONF.host + ':' +\
                        str(ConfHelper.SI_SERVER_CONF.port)
        self.gw_binding = 'ydws_gw_requests_binding@' +\
                          ConfHelper.GW_SERVER_CONF.host + ':' +\
                          str(ConfHelper.GW_SERVER_CONF.port)
        self.si_binding = 'ydws_si_requests_binding@' +\
                          ConfHelper.SI_SERVER_CONF.host + ':' +\
                          str(ConfHelper.SI_SERVER_CONF.port)

        self.heart_beat_queues = {} 
        self.heartbeat_threads = {} 

        self.connections = {}
        self.addresses = {}
        self.listen_fd, self.epoll_fd = self.get_socket()
        self.rabbitmq_connection, self.rabbitmq_channel = self.__connect_rabbitmq(ConfHelper.RABBITMQ_CONF.host)
        logging.info("[SI] Create SI request queue: %s, binding: %s",
                     self.si_queue, self.si_binding)
예제 #5
0
파일: server.py 프로젝트: jcsy521/ydws
def main():
    parse_command_line()
    if options.mode.lower() == "debug":
        debug_mode = True
    else:
        debug_mode = False

    http_server = None
    try:
        ConfHelper.load(options.conf)
        app = Application(debug=debug_mode)
        http_server = tornado.httpserver.HTTPServer(app, xheaders=True)

        thread.start_new_thread(add_sms_to_queue_thread, (app.queue,))

        worker_pool = WorkerPool(app.queue, int(ConfHelper.SMS_CONF.workers))


        http_server.listen(options.port)
        logging.warn("[SMS] running on: localhost:%d", options.port)
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        logging.error("Ctrl-C is pressed.")
    except:
        logging.exception("[SMS] exit exception")
    finally:
        logging.warn("[SMS] shutdown...")
        if http_server:
            shutdown(worker_pool, http_server)
        logging.warn("[SMS] Stopped. Bye!")
예제 #6
0
파일: server.py 프로젝트: jcsy521/ydws
def main():
    tornado.options.parse_command_line()
    if not ('conf' in options):
        import sys
        usage()
        sys.exit(1)

    # if options.mode.lower() == "debug":
    #     debug_mode = True
    # else:
    #     debug_mode = False

    ConfHelper.load(options.conf)

    try:
        logging.warn("[CK] running on: localhost. Parent process: %s", os.getpid())
        # run terminal
        thread.start_new_thread(check_terminal_status, ())
        thread.start_new_thread(check_service, ())
        thread.start_new_thread(simulator_terminal, ())
        thread.start_new_thread(simulator_terminal_test, ())
        thread.start_new_thread(check_db, ())
        while True:
            time.sleep(60)
         
    except KeyboardInterrupt:
        logging.error("Ctrl-C is pressed.")
    except:
        logging.exception("[checker] Exit Exception")
    finally:
        logging.warn("[CK] shutdown...")
        logging.warn("[CK] stopped. Bye!")
예제 #7
0
파일: server.py 프로젝트: jcsy521/ydws
def main():
    tornado.options.parse_command_line()
    if not ('port' in options and 'conf' in options):
        import sys
        usage()
        sys.exit(1)

    if options.mode.lower() == "debug":
        debug_mode = True
    else:
        debug_mode = False

    http_server = None
    try:
        ConfHelper.load(options.conf)

        http_server = tornado.httpserver.HTTPServer(Application(debug=debug_mode), xheaders=True)
        http_server.listen(options.port)
        #thread.start_new_thread(start_log_syncer, ())
        logging.warn("[LOG] running on: localhost:%d", options.port)
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt: # todo: SystemExit?
        logging.error("Ctrl-C is pressed.")
    except:
        logging.exception("[LOG] Exit Exception")
    finally:
        logging.warn("[LOG] shutdown...")
        if http_server is not None:
            shutdown(http_server)
        logging.warn("[LOG] stopped. Bye!")
예제 #8
0
파일: server.py 프로젝트: jcsy521/ydws
def main():
    tornado.options.parse_command_line()
    if not ('conf' in options):
        import sys
        usage()
        sys.exit(1)

    if options.mode.lower() == "debug":
        debug_mode = True
    else:
        debug_mode = False

    ConfHelper.load(options.conf)
    redis = MyRedis()
    db = DBConnection().db

    siserver = None
    try:
        logging.warn("[siserver] running on: localhost")
        siserver = MySIServer(options.conf)
        siserver.redis = redis
        siserver.db = db
        siserver.handle_si_connections()

    except KeyboardInterrupt:
        logging.error("Ctrl-C is pressed.")
    except:
        logging.exception("[siserver] Exit Exception")
    finally:
        logging.warn("[siserver] shutdown...")
        shutdown(siserver)
        logging.warn("[siserver] stopped. Bye!")
예제 #9
0
파일: des.py 프로젝트: jcsy521/ydws
 def __init__(self, data):
     ConfHelper.load(options.conf)
     data = safe_utf8(data)
     length = str(len(data))
     bytes = struct.pack(length + 's', data)
     des_key = ConfHelper.SMS_CONF.des_key
     k = des(des_key, CBC, des_key, pad=None, padmode=PAD_PKCS5)
     self.result = k.encrypt(bytes)
예제 #10
0
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    
    while True:
        check_ncdl()
        time.sleep(1)
        check_zsonline()
        time.sleep(300)
예제 #11
0
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    
    headers = login()

    while True:
        check_req_to_nginx(headers)
        time.sleep(1)
        check_req_to_uweb(headers)
        time.sleep(30)
예제 #12
0
파일: test_redis.py 프로젝트: jcsy521/ydws
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()

    t = Test()

    #test_mileage() 
    #t.test_acc_status() 
    #t.test_alarm_info()
    #t.test_terminal_info() 
    #t.test_location() 
    t.test_expire() 
예제 #13
0
파일: base.py 프로젝트: jcsy521/ydws
    def __init__(self, conf_file):
        ConfHelper.load(conf_file)
        for i in ('port', 'retry_interval', 'retry_count', 'recv_retry_count'):
            ConfHelper.GF_CONF[i] = int(ConfHelper.GF_CONF[i])

        self.__sock = None
        self.is_alive = False
        self.send_queue = None
        self.wait_response_queue = None
        self.last_check_time = None

        self.login()
예제 #14
0
def main():
    ConfHelper.load("../conf/global.conf")
    parse_command_line()
    if not "excel" in options:
        usage()
        exit(1)

    fname = options.excel
    extension = os.path.splitext(fname)[1]
    if extension not in [".xlsx", ".xls"]:
        print "ivalid excel file........."
    else:
        batch_import(fname)
예제 #15
0
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    if not 'excel' in options:
        usage()
        exit(1)

    fname = options.excel
    extension = os.path.splitext(fname)[1]
    if extension not in ['.xlsx', '.xls']:
        print 'ivalid excel file.........'
    else:
        batch_import(fname) 
예제 #16
0
파일: mydb.py 프로젝트: jcsy521/ydws
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    db = DBConnection().db
    redis = MyRedis() 

    #tid = '35A60002B3'
    tid = '36E24006A6'
    location = db.get("SELECT id, speed, timestamp, category, name,"
                      "  degree, type, latitude, longitude, clatitude, clongitude,"
                      "  timestamp, locate_error"
                      "  FROM T_LOCATION"
                      "  WHERE tid = %s"
                      "    AND type = 0"
                      "    AND NOT (latitude = 0 AND longitude = 0)"
                      "    ORDER BY timestamp DESC"
                      "    LIMIT 1",
                      tid)
    print 'location:', location
예제 #17
0
파일: server.py 프로젝트: jcsy521/ydws
def main():
    tornado.options.parse_command_line()
    if not ('port' in options and 'conf' in options):
        import sys
        usage()
        sys.exit(1)

    if options.mode.lower() == "debug":
        debug_mode = True
    else:
        debug_mode = False

    http_server = None
    # creat 2 work_pool, handle diferent package.
    position_worker_pool = None
    report_worker_pool = None
    try:
        ConfHelper.load(options.conf)
        app = Application(debug=debug_mode)
        
        position_worker_pool = WorkerPool(app.position_queue,
                                          int(ConfHelper.EVENTER_CONF.workers),
                                          name=EVENTER.INFO_TYPE.POSITION)
        report_worker_pool = WorkerPool(app.report_queue,
                                        int(ConfHelper.EVENTER_CONF.workers),
                                        name=EVENTER.INFO_TYPE.REPORT)

        http_server = tornado.httpserver.HTTPServer(app, xheaders=True)
        http_server.listen(options.port)
        logging.warn("[eventer] running on: localhost:%d", options.port)
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        logging.error("Ctrl-C is pressed.")
    except:
        logging.exception("[eventer] Exit Exception")
    finally:
        logging.warn("[eventer] shutdown...")
        shutdown(position_worker_pool, None)
        shutdown(report_worker_pool, http_server)
        logging.warn("[eventer] Stopped. Bye!")
예제 #18
0
파일: test_sms.py 프로젝트: jcsy521/ydws
def insert_sms():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    db = DBConnection().db
    redis = MyRedis() 

    msgid=str(int(time.time() * 1000))[-9:]
    mobile = '18310505991'
    insert_time = int(time.time() * 1000)
    category = 2 # SMS.CATEGORY.MT
    #send_status = -1 # SMS.SENDSTATUS.PREPARING
    send_status = 0 # SMS.SENDSTATUS.SUCCESS
    count = 3

    for i in xrange(500):
        content= 'test sms'
        content = content + 'seq: %s' % i
        db.execute("INSERT INTO T_SMS(msgid, mobile, content, "
                   " insert_time, category, send_status) "
                   "  VALUES(%s, %s, %s, %s, %s, %s)",
                   msgid, mobile, content, insert_time,
                   category, send_status) 
예제 #19
0
파일: server.py 프로젝트: jcsy521/ydws
def main():
    tornado.options.parse_command_line()
    if options.mode.lower() == "debug":
        debug_mode = True
    else:
        debug_mode = False

    http_server = None
    try:
        ConfHelper.load(options.conf)
        application = Application(debug=debug_mode)
        http_server = tornado.httpserver.HTTPServer(application, xheaders=True)
        # create mt thread
        thread.start_new_thread(run_send_mt_thread, ())
        
        ## create send failed mt thread
        #thread.start_new_thread(run_send_failed_mt_thread, ())
        #
        ## create user receive status thread
        #thread.start_new_thread(run_user_receive_status_thread, ())
        #
        ## create get mo thread
        #thread.start_new_thread(run_get_mo_from_gateway_thread, ())
        #
        ## create send mo thread
        #thread.start_new_thread(run_send_mo_to_acb_thread, ())
        
        http_server.listen(options.port)
        logging.warn("[ACB SMS] running on: localhost:%d", options.port)
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        logging.error("Ctrl-C is pressed.")
    except:
        logging.exception("[ACB SMS] exit exception")
    finally:
        logging.warn("[ACB SMS] shutdown...")
        if http_server:
            shutdown(http_server)
        logging.warn("[ACB SMS] Stopped. Bye!")
예제 #20
0
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    if not 'send' in options:
        usage()
        exit(1)

    content = 'SET GROUP 10657061138902'
    content = 'SET SIM 18242608998'
    content = 'SET SMS 10657'
    #content = 'BIND 13693675352:13417738440'
    content = 'SET SKYS 0800 1130 1300 1531 1111100'
    #content = 'LQ 30'
    #content = 'DEL SKYS'
    #content = 'SET QQ 1*爸爸*13693675352 2** 3** 4**'
    #content = 'SET HFCC'
    #content = 'SET SMS 10657061'
    #content = 'SSDW'
    #content = 'RELOGIN'
    #content = 'SET TIME 20140721162811'
    #content = 'SET QQ 1*爸爸*13693675352 2*妈妈*13693675352'
    #content = 'SET QQ 3*姐姐*13464077667 4*大姨*15042020333'

    if options.send.lower() == 'all':
        send_all(content)
    elif options.send.lower() == 'one':
        if not 'mobile' in options:
            usage()
            exit(1)
        elif not options.mobile:
            usage()
            exit(1)
        send(content, options.mobile)
    else:
        usage()
        exit(1)
예제 #21
0
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()

    block_test() 
예제 #22
0
파일: msubscriber.py 프로젝트: jcsy521/ydws
def main():
    ConfHelper.load('../../../conf/global.conf')
    ins = MSubscriber()
    ins.retrieve()
예제 #23
0
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    wash_location() 
예제 #24
0
파일: uweb_unit.py 프로젝트: jcsy521/ydws
                    logging.info("[UWEB_TEST] Lastposition nginx request conent is none.")
            else: 
                logging.info("[UWEB_TEST] Lastposition nginx request failed.")
        except Exception as e:
            logging.exception("[UWEB_TEST] nginx request failed")
            send("Access url:%s by nginx failed" % url,  
                 alert_mobile)

    def test(self):
        """
        """
        logging.info("[UWEB_TEST] Test single start.")
    
        cookie = 'bdshare_firstime=1397892175624; USERCURRENTROLE=enterprise; ACBUWEB=Qz0xMzAxMTI5MjIxNzpPPWR1bW15X29pZDpVPTEzMDExMjkyMjE3OlQ9MTMyMTEyOTIyMTg6VFQ9MTMyMTEyOTIyMTg=|1402906411|05e677cb8b0d8ddd89fa5688881ee88fb8022e36'
        headers =  {} 
        headers['Cookie'] = cookie 
        self.lastposition(headers)
        #self.logintest_android(headers)
    
def main():
    """Main method.
    """
    test = Test()
    test.test()

if __name__ == "__main__": 
    ConfHelper.load('../../conf/global.conf')
    parse_command_line()

    main()
예제 #25
0
파일: add_car.py 프로젝트: jcsy521/ydws
def main():
    ConfHelper.load("../conf/global.conf")
    parse_command_line()
    execute()
예제 #26
0
파일: mgroup.py 프로젝트: jcsy521/ydws
def main():
    ConfHelper.load('../../../conf/global.conf')
    ins = MGroup()
    ins.retrieve()
예제 #27
0
파일: status.py 프로젝트: jcsy521/ydws
 def __init__(self):
     ConfHelper.load(options.conf)
     self.db = DBConnection().db
예제 #28
0
파일: export_sms.py 프로젝트: jcsy521/ydws
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    export_sms() 
예제 #29
0
def main():
    ConfHelper.load('../conf/global.conf')
    parse_command_line()
    
    move_data()
예제 #30
0
파일: admintask.py 프로젝트: jcsy521/ydws
        logging.info("[CELERY] statistic_offline_terminal Exception:%s", e.args)

def statistic_online_terminal():
    ts = TerminalStatistic()
    ts.statistic_online_terminal(int(time.time()))

def statistic_user():
    ts = TerminalStatistic()
    ts.statistic_user(int(time.time()))
 
def statistic_misc():
    ts = TerminalStatistic()
    ts.statistic_misc()

if __name__ == '__main__':
    ConfHelper.load(options.conf)
    parse_command_line()
    #NOTE: here, you can name the date to be statisticed.
    for item in range(17,18):
        year = '2013'
        month = '08'
        day = item 
        timestamp = int(time.mktime(time.strptime("%s-%s-%s-23-59-59"%(year,month,day),"%Y-%m-%d-%H-%M-%S")))
        logging.info('[CHECKER] year: %s, month: %s, day: %s, timestamp: %s. ' , year, month, day,timestamp)
        ts = TerminalStatistic()
        #ts.statistic_online_terminal(timestamp) 
        #ts.statistic_user(timestamp) 
        #ts.statistic_offline_terminal(timestamp) 
        #ts.statistic_misc() 

else: