def run(self): """读取一个目录,遍历下面的app文件夹,每个app启动一到两条线程对此提供服 务,一条用来发推送,一条用来收feedback """ self.rds.set('ENHANCE_THREAD', 0) apps = utils.get_apps(self.app_dir) self.app_info = {} # 文件夹下面会有production,develop两个子目录,分别放不同的Key及Cert for app in apps: if app.startswith('.'): continue log.debug('getting ready for app : %s' % app) app_info = utils.get_app_info(self.app_dir, app) self.app_info[app] = app_info self.start_worker(app) start_webserver(self) self.watch_app() log.debug('just wait here,there are %d threads ' % len(self.notifiers)) while True: time.sleep(10)
def runApp(): event_queue = queue.Queue() result_queue = queue.Queue() #keyboardReaderProess = keyboard.reader.startreader( "0.0.0.0" , 9001 ) webserver.setup_webserver( event_queue , result_queue ) webserver.start_webserver() wp = wordpredictor.predictorloop.PredictorLoop( event_queue , result_queue ) wp.run() webserver.stop_webserver() keyboardReaderProess.kill()
def _local_test_inclusion(self, freq): ''' Check for RFI using a local web server @param freq: A fuzzableRequest object @return: None, everything is saved to the kb ''' # # The listen address is an empty string when I have no default route # # Only work if: # - The listen address is private and the target address is private # - The listen address is public and the target address is public # if self._listen_address == '': return is_listen_priv = is_private_site(self._listen_address) is_target_priv = is_private_site(freq.getURL().getDomain()) if (is_listen_priv and is_target_priv) or \ not (is_listen_priv or is_target_priv): om.out.debug('RFI test using local web server for URL: ' + freq.getURL()) om.out.debug('w3af is running a webserver') try: # Create file for remote inclusion self._create_file() # Start web server webroot = os.path.join(get_home_dir(), 'webroot') webserver.start_webserver(self._listen_address, self._listen_port, webroot) # Perform the real work self._test_inclusion(freq) except Exception, e: msg = 'An error occurred while running local webserver: "%s"' % str( e) om.out.error(msg) finally:
def _local_test_inclusion(self, freq): ''' Check for RFI using a local web server @param freq: A fuzzableRequest object @return: None, everything is saved to the kb ''' # # The listen address is an empty string when I have no default route # # Only work if: # - The listen address is private and the target address is private # - The listen address is public and the target address is public # if self._listen_address == '': return is_listen_priv = is_private_site(self._listen_address) is_target_priv = is_private_site(freq.getURL().getDomain()) if (is_listen_priv and is_target_priv) or \ not (is_listen_priv or is_target_priv): om.out.debug('RFI test using local web server for URL: ' + freq.getURL()) om.out.debug('w3af is running a webserver') try: # Create file for remote inclusion self._create_file() # Start web server webroot = os.path.join(get_home_dir(), 'webroot') webserver.start_webserver(self._listen_address, self._listen_port, webroot) # Perform the real work self._test_inclusion(freq) except Exception,e: msg = 'An error occurred while running local webserver: "%s"' % str(e) om.out.error( msg ) finally:
sta_if.active(True) sta_if.connect(SSID, PASSWORD) while not sta_if.isconnected(): pass print('network config:', sta_if.ifconfig()) INFO_LED.on() def push_endpoint(timer): try: resp = requests.post(ENDPOINT, headers={'content-type': 'application/json'}, data=ujson.dumps(sensors.get_sensors())) if resp.status_code != 200: print('Error : Status Code : {}. Message : {}'.format( resp.status_code, resp.text)) gc.collect() except Exception as e: print('Error: {}'.format(e)) #connect to wifi do_connect() #Clock timer TIMR = Timer(-1) TIMR.init(period=60000, mode=Timer.PERIODIC, callback=push_endpoint) #Start WebServer webserver.start_webserver()