Projects STRLCPY geneva Commits 78324a6d
🤬
  • Bug in argument parsing fixed, added port binding to correct interface

  • Loading...
  • Ubuntu committed 4 years ago
    78324a6d
    1 parent a5adc945
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    plugins/http/server.py
    1 1  import argparse
    2 2  import logging
     3 +import netifaces
    3 4  import os
    4 5  import tempfile
    5 6  import subprocess
    skipped 38 lines
    44 45   """
    45 46   Initializes the HTTP server.
    46 47   """
     48 + interface = args.get("interface")
     49 + bind_cmd = []
     50 + if interface:
     51 + bind_addr = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr']
     52 + bind_cmd = ["--bind", bind_addr]
     53 + 
    47 54   # Create a temporary directory to run out of so we're not hosting files
    48 55   self.tmp_dir = tempfile.TemporaryDirectory()
    49 56   
    skipped 5 lines
    55 62   stdout, stderr = None, None
    56 63   
    57 64   # Start the server
     65 + cmd = ["python3", "-m", "http.server", str(args.get('port'))]
     66 + cmd += bind_cmd
    58 67   try:
    59  - subprocess.check_call(["python3", "-m", "http.server", str(args.get('port'))], stderr=stderr, stdout=stdout, cwd=self.tmp_dir.name)
     68 + subprocess.check_call(cmd, stderr=stderr, stdout=stdout, cwd=self.tmp_dir.name)
    60 69   except subprocess.CalledProcessError as exc:
    61 70   logger.debug("Server exited: %s", str(exc))
    62 71   
    skipped 8 lines
  • ■ ■ ■ ■
    plugins/plugin_server.py
    skipped 44 lines
    45 45   choices=("debug", "info", "warning", "critical", "error"),
    46 46   help="Sets the log level")
    47 47   parser.add_argument('--port', action='store', type=int, help='port to run this server on')
    48  - parser.add_argument('--interface', action='store_true', help='interface to run the engine on for server-side training')
     48 + parser.add_argument('--interface', action='store', help='interface to run the engine on for server-side training')
    49 49   
    50 50   parser.add_argument('--external-server', action='store_true', help="use an external server for testing.")
    51 51   
    skipped 159 lines
Please wait...
Page is in error, reload to recover