示例#1
0
def main(args=None):
    # Parse arguments
    if args is None:
        args = sys.argv[1:]
    args = parse_args(args)

    # Assert config file exists
    assert os.path.isfile(
        "./config.yaml"
    ), 'Config file not found. Please do not rename or move!'

    # Check config
    with open("./config.yaml", 'r') as f:
        check_config(yaml.safe_load(f))

    detector = Detector(args)
    detector.run()
 def get(self):
     link_open = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
     urllib2.install_opener( link_open )
     
     login_params = "data={\"username\":\"Spring\", \"password\":\"[email protected]\", \"mechanism\":\"plain\"}"
     login_result = link_open.open( config.base_url + config.login_url, login_params )
     login_data = login_result.read()
     logging.info("Receive data " + login_data)
     print login_data
     login_json = json.loads(login_data)
     login_result.close()
     self.response.headers['Content-Type'] = 'text/plain'
     #save sessionid for this connection
     sessionid = login_json["sessionid"]
     
     fetchor = Detector( 5, sessionid, login_json['deviceid'] )
     fetchor.start()
     fetchor.run()
     fetchor.join()
    def get(self):
        link_open = urllib2.build_opener(urllib2.HTTPCookieProcessor())
        urllib2.install_opener(link_open)

        login_params = "data={\"username\":\"Spring\", \"password\":\"[email protected]\", \"mechanism\":\"plain\"}"
        login_result = link_open.open(config.base_url + config.login_url,
                                      login_params)
        login_data = login_result.read()
        logging.info("Receive data " + login_data)
        print login_data
        login_json = json.loads(login_data)
        login_result.close()
        self.response.headers['Content-Type'] = 'text/plain'
        #save sessionid for this connection
        sessionid = login_json["sessionid"]

        fetchor = Detector(5, sessionid, login_json['deviceid'])
        fetchor.start()
        fetchor.run()
        fetchor.join()