コード例 #1
0
def main():
    parser = argparse.ArgumentParser(description="HTTP Server")
    parser.add_argument("-p",
                        "--port",
                        type=int,
                        default=8000,
                        help="Port number to serve at")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        help="Print debug information")
    parser.add_argument(
        "-s",
        "--secure",
        action="store_true",
        default=False,
        help="Secure server using SSL",
    )
    parser.add_argument(
        "--wasm-stream",
        action="store_true",
        default=True,
        help="Enable streaming Web Assembly [DEFAULT]",
    )
    parser.add_argument(
        "--no-wasm-stream",
        action="store_true",
        default=False,
        help="Disable streaming Web Assembly",
    )
    parser.add_argument("--directory",
                        type=str,
                        default=".",
                        help="Run the server at directory")

    args = parser.parse_args()

    # change to working directory
    current_dir = os.getcwd()
    if not os.path.isdir(args.directory):
        sys.stderr.write(f"Invalid directory: '{args.directory}'\n")
        exit(1)
    os.chdir(args.directory)

    server = IWPAServer(
        PORT=args.port,
        verbose=args.verbose,
        wasm_stream=(args.wasm_stream and not args.no_wasm_stream),
        secure=args.secure,
    )

    try:
        server.start()
        while server.isRunning():
            time.sleep(2)
    except KeyboardInterrupt:
        server.stop()

    # change back
    os.chdir(current_dir)
コード例 #2
0
def signal_handler(sig, frame):
    global server
    global MRC
    
    server.stop()
    rmr.rmr_close(MRC)
    sys.exit(0)
コード例 #3
0
ファイル: test_client.py プロジェクト: metthal/ulocal
def mock_server():
    test_name = os.environ['PYTEST_CURRENT_TEST'].split(':')[-1].split(' ')[0]
    server = MockServer(test_name)
    server.start()
    try:
        yield server
    finally:
        server.stop()
コード例 #4
0
def shutdownHandler(sig, frame):
    logger('Signal received, shutting down...')
    global server
    global scanner
    server.stop()
    scanner.stop()
    logger("scanner stopped, we're done here")
    sys.exit(0)
コード例 #5
0
ファイル: test_flow.py プロジェクト: shoonoise/gns
def _send_recv_event(event):
    opener = urllib.request.build_opener()
    server = _ShotServer(event["echo_host"], event["echo_port"])
    server.start()
    try:
        # To save events had not numbered sequentially. Check that everything works to increase counter.
        opener.open(_make_event_request({ "_stub": None }))
        opener.open(_make_event_request(event))
        return json.loads(server.wait_for_result().decode())
    finally:
        server.stop()
コード例 #6
0
def serve(stop_signal):
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    lock_pb2_grpc.add_GLOCKServicer_to_server(GlockServer(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    print("RPC Server Started")

    while not stop_signal.isSet():
        sleep(_ONE_DAY_IN_SECONDS)
        continue
    print("rpcserver stop")
    server.stop(0)
コード例 #7
0
ファイル: httpserver.py プロジェクト: nilcolor/web.py3
def runsimple(func, server_address=("0.0.0.0", 8080)):
    """
    Runs [CherryPy][cp] WSGI server hosting WSGI app `func`. 
    The directory `static/` is hosted statically.

    [cp]: http://www.cherrypy.org
    """
    func = StaticMiddleware(func)
    func = LogMiddleware(func)
    
    server = WSGIServer(server_address, func)

    print("http://%s:%d/" % server_address)
    try:
        server.start()
    except KeyboardInterrupt:
        server.stop()
コード例 #8
0
def creationBoutons(root, server):
    '''Creer une liste de boutons et de labbels
	Params : root (object tkinter) = la fenetre principale
	Return : listButtons (list(Button))
	'''
    listButtons = []
    root.protocol("WM_DELETE_WINDOW", lambda: [server.stop(), root.destroy()])
    listButtons.append(
        Button(root, text='START', command=lambda: server.startAndStop()))
    listButtons.append(
        Button(root,
               text='Quitter',
               command=lambda: [server.stop(), root.destroy()]))
    listButtons.append(Label(root, text=""))
    listButtons.append(
        Label(root, text="Status : Off", fg="blue", font=("Helvetica", 10)))
    listButtons.append(
        Label(root, text="Erreur", fg="red", font=("Helvetica", 16)))
    return listButtons
コード例 #9
0
ファイル: server.py プロジェクト: SkyFox277/face-rec-tools
def main():
    args = args_parse()

    cfg = config.Config(args.config)

    if args.logfile:
        logfile = args.logfile
    else:
        logfile = cfg.get_path('server', 'log_file')

    log.initLogger(logfile)

    try:
        server = FaceRecServer(cfg)
        log.info("Face rec server up.")
        server.serve_forever()
    except KeyboardInterrupt:
        server.stop(False)
        server.status()
        server.server_close()
        log.info("Face rec server down.")
コード例 #10
0
 def test_proxy_qop_auth_int_works_or_throws_urlerror(self):
     server = self._make_server("auth-int")
     self.add_teardown(lambda: server.stop())
     self.proxy_digest_handler.add_password(self.REALM, self.URL, self.USER,
                                            self.PASSWD)
     try:
         result = self.opener.open(self.URL)
     except mechanize.URLError:
         # It's okay if we don't support auth-int, but we certainly
         # shouldn't receive any kind of exception here other than
         # a URLError.
         result = None
     if result:
         while result.read():
             pass
         result.close()
コード例 #11
0
# Parse command line arguments
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-r", "--remote-ip", default="192.168.0.1", help="Router IP address")
parser.add_argument("-l", "--local-ip", default="192.168.0.2", help="This computers IP address")
parser.add_argument("-p", "--port", type=int, default=8000, help="Port local server serving file is using")
parser.add_argument("-f", "--file", required=True, help="File to upload")
parser.add_argument("-n", "--name", default="upload", help="Filename after upload")
parser.add_argument("-e", "--executable", action="store_true", default=False, help="Should file be marked as executable after upload")
parser.add_argument("-x", "--run", action="store_true", default=False, help="Should file be run after upload")
args = parser.parse_args()

# Start webserver serving the files in the current dictionary
server = Server(args.port)
server.start()

# Run command on router to download file from webserver
run_command("wget -O /tmp/{} http://{}:{}/{}".format(args.name, args.local_ip, args.port, args.file))

if args.executable:
    # Mark downloaded file executable
    run_command("chmod +x /tmp/{}".format(args.name))

if args.run:
    # Execute downloaded file
    run_command("./tmp/{}".format(args.name))

# Stop webserver
server.stop()
server.join()
コード例 #12
0
def httpd():
    server = Httpd()
    server.start()
    yield
    server.stop()
コード例 #13
0
ファイル: S2-045_rce.py プロジェクト: m4udSec/S2-045-RCE
def serverShutdown(server):
    server = struts(options)
    server.stop()
    print("Shutting Server down!")
コード例 #14
0
def run(command, port):
    server = Server(command, port)
    threading.Thread(target=server.start).start()
    signal.signal(signal.SIGTERM, lambda signum, frame: server.stop())