def start_cli(): alt_ip = ip or get_accessible_ips()[0][1] alt_port = port or get_random_available_port(alt_ip) app.config['LOCALADDR'] = alt_ip app.config['CLI_OR_DEPLOY'] = True app.config['QUIET'] = quiet click.echo( click.style( f'FQM {VERSION} is running on http://{alt_ip}:{alt_port}', bold=True, fg='green')) click.echo('') click.echo( click.style('Press Control-c to stop', blink=True, fg='black', bg='white')) try: monkey.patch_socket() pywsgi.WSGIServer( (str(alt_ip), int(alt_port)), app, log=None if quiet else 'default').serve_forever() except KeyboardInterrupt: stop_tasks()
def interface(cli, quiet, ip, port): app = bundle_app() if cli: ip = ip or get_accessible_ips()[0][1] port = port or get_random_available_port(ip) app.config['LOCALADDR'] = ip click.echo( click.style(f'FQM {VERSION} is running on http://{ip}:{port}', bold=True, fg='green')) click.echo('') click.echo( click.style('Press Control-c to stop', blink=True, fg='black', bg='white')) monkey.patch_socket() pywsgi.WSGIServer( (str(ip), int(port)), app, log=None if quiet else 'default').serve_forever() else: gui_process = QApplication(sys.argv) window = MainWindow( app) # NOTE: has to be decleared in a var to work properly QCoreApplication.processEvents() gui_process.exec_()
def get_ports(self): ip = self.select_ips_ports_change()[1].split(',')[1] default_ports = ['5000', '8080', '3000', '80', '9931'] returned_ports = [port for port in default_ports if is_port_available(ip, port)] while 10 > len(returned_ports): returned_ports.append(get_random_available_port(ip)) self.select_port.clear() self.select_port.addItems([str(port) for port in returned_ports])