def __init__(self, command = "", port_space = 10, startup_wait = 0.8): super(ServerCreator, self).__init__() proxy_server.QUIET = True self.address = '' self.startup_wait = startup_wait self.temporary_folder = tempfile.mkdtemp(prefix = 'remove_me_', suffix = '_testcase_script') self.weblab_dir = os.path.join(self.temporary_folder, 'weblab') self.argv = list(sys.argv) self.exc_info = None try: start_port = new_port() # Make a port space for _ in xrange(port_space): new_port() self.shutdown_port = new_port() self.public_port = new_port() self.address = 'http://localhost:%s/weblab/' % self.public_port sys.argv = shlex.split("weblab-admin create %s --ignore-locations --quiet --not-interactive --socket-wait=%s --start-port=%s %s --http-server-port=%s" % (self.weblab_dir, self.shutdown_port, start_port, command, self.public_port)) weblab_admin() variables = {} execfile(os.path.join(self.temporary_folder, 'weblab', 'debugging.py'), variables, variables) self.ports = variables['PORTS'] self.temporal_addresses = [] for port in self.ports: self.temporal_addresses.append('http://localhost:%s/weblab/' % port) except: shutil.rmtree(self.temporary_folder) raise finally: sys.argv = self.argv
def run(self): try: if 'PYTHONPATH' in os.environ: os.environ['PYTHONPATH'] = os.pathsep.join((os.environ['PYTHONPATH'], os.path.abspath('.'))) else: os.environ['PYTHONPATH'] = os.path.abspath('.') sys.argv = shlex.split("weblab-admin start %s" % self.weblab_dir) weblab_admin() except: self.exc_info = sys.exc_info() print(self.exc_info)
def run(self): try: if 'PYTHONPATH' in os.environ: os.environ['PYTHONPATH'] = os.pathsep.join( (os.environ['PYTHONPATH'], os.path.abspath('.'))) else: os.environ['PYTHONPATH'] = os.path.abspath('.') sys.argv = shlex.split("weblab-admin start %s" % self.weblab_dir) weblab_admin() except: self.exc_info = sys.exc_info() print(self.exc_info)
def __init__(self, command="", port_space=10, startup_wait=0.8): super(ServerCreator, self).__init__() proxy_server.QUIET = True self.address = '' self.startup_wait = startup_wait self.temporary_folder = tempfile.mkdtemp(prefix='remove_me_', suffix='_testcase_script') self.weblab_dir = os.path.join(self.temporary_folder, 'weblab') self.argv = list(sys.argv) self.exc_info = None try: start_port = new_port() # Make a port space for _ in xrange(port_space): new_port() self.shutdown_port = new_port() self.public_port = new_port() self.address = 'http://localhost:%s/weblab/' % self.public_port sys.argv = shlex.split( "weblab-admin create %s --ignore-locations --quiet --not-interactive --socket-wait=%s --start-port=%s %s --http-server-port=%s" % (self.weblab_dir, self.shutdown_port, start_port, command, self.public_port)) weblab_admin() variables = {} execfile( os.path.join(self.temporary_folder, 'weblab', 'debugging.py'), variables, variables) self.ports = variables['PORTS'] self.temporal_addresses = [] for port in self.ports: self.temporal_addresses.append('http://localhost:%s/weblab/' % port) except: shutil.rmtree(self.temporary_folder) raise finally: sys.argv = self.argv