Example #1
0
    'fpp_neu': {
        'ip': ip_fpp_neu,
        'port': port_fpp_neu,
        'urlpath': urlpath_fpp_neu,
        'req_data': req_fpp
    },
    'fpp_moto': {
        'ip': ip_fpp_moto,
        'port': port_fpp_moto,
        'urlpath': urlpath_fpp_moto,
        'req_data': req_fpp
    },
}

if __name__ == "__main__":
    ips_src = getIP()
    if 'wlan0' in ips_src:
        ip_src = ips_src['wlan0']
    else:
        ip_src = ips_src['eth0']

    target = targets['wpp_local']
    #target['urlpath'] = target['urlpath'].lower() # compatible with local fpp urlpath.
    # urlpath & port for cmcc mobile naviwap test.
    #target['ip'] = '112.25.187.195'
    #target['port'] = '18080'
    #target['urlpath'] = 'FPP_AD/adapter'
    #target['req_data'] = req_wpp
    url = 'http://%s:%s/%s' % (target['ip'], target['port'], target['urlpath'])
    print '\nRequesting %s from %s\n' % (url, ip_src)
    req_data = target['req_data']
Example #2
0
    # Gevent server.
    #from gevent.wsgi import WSGIServer
    #httpd = WSGIServer(('', port), wpp_handler, spawn=None)
    #httpd.backlog = 256
    #httpd.log = False
    # Meinheld server.
    from meinheld import server
    server.listen(("0.0.0.0", port))
    # Bjoern server.
    #import bjoern
    #bjoern.listen(wpp_handler, '0.0.0.0', port)
    # Gunicorn
    # $gunicorn -b :8080 -w 5 wpp_server:wpp_handler
    # $gunicorn -b :8080 -w 5 -k "egg:meinheld#gunicorn_worker" wpp_server:wpp_handler
    # $gunicorn -b :8080 -w 5 -k "egg:gunicorn#gevent" wpp_server:wpp_handler
    # $gunicorn -b :8080 -w 5 -k "egg:gevent#gunicorn_worker" wpp_server:wpp_handler

    # Get IP address.
    from wpp.util.net import getIP
    ipaddr = getIP()
    if 'wlan0' in ipaddr:
        ipaddr = ipaddr['wlan0']
    else:
        ipaddr = ipaddr['eth0']
    print 'Starting up HTTP server on %s:%d ...' % (ipaddr, port)

    # Respond to requests until process is killed
    #httpd.serve_forever() # Gevent
    #bjoern.run() # bjoern
    server.run(wpp_handler)  # Meinheld
Example #3
0
            n_inserts = doClusterIncr(fd_csv=fd_csv, wppdb=wppdb, verb=False)
            print 'AlgoData added: [%s] clusters, [%s] FPs' % (n_inserts['n_newcids'], n_inserts['n_newfps'])
        # Move rawdata without location to another table: wpp_uprecs_noloc.
        tab_rd_noloc = 'wpp_uprecs_noloc'
        strWhere = 'lat=0 or lon=0'
        sql = wppdb.sqls['SQL_INSERT_SELECT'] % ( tab_rd_noloc, '*', '%s WHERE %s'%(tab_rd,strWhere) )
        wppdb.cur.execute(sql)
        sql = wppdb.sqls['SQL_DELETE'] % (tab_rd, strWhere)
        wppdb.cur.execute(sql)
        wppdb.close()
        print 'Move noloc rawdata -> |%s|' % tab_rd_noloc
        if alerts['vers']:
            # Send alert email to admin.
            _func = sys._getframe().f_code.co_name
            subject = "[!]WPP ERROR: %s->%s, ver: [%s]" % (_file, _func, ','.join(alerts['vers']))
            body = ( errmsg['db'] % (tab_rd,'insert',alerts['details'],getIP()['eth0'],ctime()) ).decode('utf-8')
            print alerts['details']
            print subject#, body
            print 'Sending alert email -> %s' % mailcfg['to']
            sendMail(mailcfg['from'],mailcfg['userpwd'],mailcfg['to'],subject,body)

def crawlAreaLocData():
    """
    1) fetch 100 records with flag area_ok = 0.
    2) try areaLocation(laccid), if OK, then update flag area_ok =1 and quit; else goto 2).
    3) try googleAreaLocation(latlon), if OK, then get geoaddr:[province,city,district]; 
       else |wpp_uprecsinfo|.area_try += 1 and quit.
    4) search area_code for the found district, insert area location 
       (laccid,areacode,areaname_cn) into |wpp_cellarea|, and update flag area_ok = 1.
    """
    fail_history = {}
Example #4
0
             'urlpath':urlpath_fpp_neu,
            'req_data':req_fpp},
       'fpp_neu':{
                  'ip':ip_fpp_neu, 
                'port':port_fpp_neu, 
             'urlpath':urlpath_fpp_neu,
            'req_data':req_fpp},
      'fpp_moto':{
                  'ip':ip_fpp_moto, 
                'port':port_fpp_moto, 
             'urlpath':urlpath_fpp_moto,
            'req_data':req_fpp},
}

if __name__ == "__main__":
    ips_src = getIP()
    if 'wlan0' in ips_src: 
        ip_src = ips_src['wlan0']
    else: 
        ip_src = ips_src['eth0']

    target = targets['wpp_local']
    #target['urlpath'] = target['urlpath'].lower() # compatible with local fpp urlpath.
    # urlpath & port for cmcc mobile naviwap test.
    #target['ip'] = '112.25.187.195'
    #target['port'] = '18080'
    #target['urlpath'] = 'FPP_AD/adapter'
    #target['req_data'] = req_wpp
    url = 'http://%s:%s/%s' % (target['ip'], target['port'], target['urlpath'])
    print '\nRequesting %s from %s\n' % (url, ip_src)
    req_data = target['req_data']
Example #5
0
        strWhere = 'lat=0 or lon=0'
        sql = wppdb.sqls['SQL_INSERT_SELECT'] % (tab_rd_noloc, '*',
                                                 '%s WHERE %s' %
                                                 (tab_rd, strWhere))
        wppdb.cur.execute(sql)
        sql = wppdb.sqls['SQL_DELETE'] % (tab_rd, strWhere)
        wppdb.cur.execute(sql)
        wppdb.close()
        print 'Move noloc rawdata -> |%s|' % tab_rd_noloc
        if alerts['vers']:
            # Send alert email to admin.
            _func = sys._getframe().f_code.co_name
            subject = "[!]WPP ERROR: %s->%s, ver: [%s]" % (
                _file, _func, ','.join(alerts['vers']))
            body = (errmsg['db'] % (tab_rd, 'insert', alerts['details'],
                                    getIP()['eth0'], ctime())).decode('utf-8')
            print alerts['details']
            print subject  #, body
            print 'Sending alert email -> %s' % mailcfg['to']
            sendMail(mailcfg['from'], mailcfg['userpwd'], mailcfg['to'],
                     subject, body)


def crawlAreaLocData():
    """
    1) fetch 100 records with flag area_ok = 0.
    2) try areaLocation(laccid), if OK, then update flag area_ok =1 and quit; else goto 2).
    3) try googleAreaLocation(latlon), if OK, then get geoaddr:[province,city,district]; 
       else |wpp_uprecsinfo|.area_try += 1 and quit.
    4) search area_code for the found district, insert area location 
       (laccid,areacode,areaname_cn) into |wpp_cellarea|, and update flag area_ok = 1.
Example #6
0
    #from gevent.wsgi import WSGIServer
    #httpd = WSGIServer(('', port), wpp_handler, spawn=None)
    #httpd.backlog = 256
    #httpd.log = False
    # Meinheld server.
    from meinheld import server
    server.listen(("0.0.0.0", port))
    # Bjoern server.
    #import bjoern
    #bjoern.listen(wpp_handler, '0.0.0.0', port)
    # Gunicorn 
    # $gunicorn -b :8080 -w 5 wpp_server:wpp_handler
    # $gunicorn -b :8080 -w 5 -k "egg:meinheld#gunicorn_worker" wpp_server:wpp_handler
    # $gunicorn -b :8080 -w 5 -k "egg:gunicorn#gevent" wpp_server:wpp_handler
    # $gunicorn -b :8080 -w 5 -k "egg:gevent#gunicorn_worker" wpp_server:wpp_handler

    
    # Get IP address.
    from wpp.util.net import getIP
    ipaddr = getIP()
    if 'wlan0' in ipaddr:
        ipaddr = ipaddr['wlan0']
    else:
        ipaddr = ipaddr['eth0']
    print 'Starting up HTTP server on %s:%d ...' % (ipaddr, port)

    # Respond to requests until process is killed
    #httpd.serve_forever() # Gevent
    #bjoern.run() # bjoern
    server.run(wpp_handler) # Meinheld