Exemplo n.º 1
0
 def startup(self) -> None:
     self.core = Server(
         ctx=self,
         host=self.host,
         port=self.port,
         title=self.title,
         description=self.description,
         dependencies=self.dependencies,
         log_config=self.log_config,
         asgi_debug=self.asgi_debug,
         debug=self.fast_api_debug,
     )
class NetworkManager(QObject, nmap.PortScanner):
    appendToLogFile = pyqtSignal(str, str, name='appendToLogFile')
    updateProgressBar = pyqtSignal(str, int, name='updateProgressBar')

    def __init__(self):
        QObject.__init__(self)
        nmap.PortScanner.__init__(self)
        self.server = Server(self)
        self.server.open_connection()

    def get_hosts_list(self, known_list_ip=None):
        list_ip = known_list_ip if known_list_ip else '192.168.0.1-255'
        enable_hosts = self.scan(hosts=list_ip, ports='22')
        ip = enable_hosts['scan'].keys()
        host_names = [enable_hosts['scan'][i]['hostnames'] for i in ip]
        name = [hostname[0]['name'] if len(hostname) else '' for hostname in host_names]
        status = ['up' if i in self.server.connections else 'down' for i in ip]
        return list(zip(name, ip, status))

    def run_installers_on_hosts(self, hosts, installers):
        self.server.send_data(hosts, installers)
Exemplo n.º 3
0
class Controller:
    def __init__(
        self,
        host: str = "127.0.0.1",
        port: int = 8080,
        title: str = "",
        description: str = "",
        dependencies: Optional[list] = None,
        log_config=None,
        fast_api_debug: bool = False,
        asgi_debug: bool = False,
        loop: Optional[AbstractEventLoop] = None,
    ) -> None:
        self.loop = loop or self._loop()
        self.host = host
        self.port = port
        self.title = title
        self.description = description
        self.dependencies = dependencies
        self.log_config = log_config
        self.fast_api_debug = fast_api_debug
        self.asgi_debug = asgi_debug
        self.core: Optional[Server] = None

    @staticmethod
    def _loop() -> AbstractEventLoop:
        return asyncio.get_event_loop()

    @staticmethod
    def __console() -> Console:
        return Console()

    def startup(self) -> None:
        self.core = Server(
            ctx=self,
            host=self.host,
            port=self.port,
            title=self.title,
            description=self.description,
            dependencies=self.dependencies,
            log_config=self.log_config,
            asgi_debug=self.asgi_debug,
            debug=self.fast_api_debug,
        )

    def start(self) -> None:
        try:
            self.__console().show_banner(True)
            self.__console().print_xen_hostnames(True)
            asyncio.ensure_future(self.core.make_process(), loop=self.loop)
            self.loop.run_forever()
        except TypeError:
            pass
 def __init__(self):
     QObject.__init__(self)
     nmap.PortScanner.__init__(self)
     self.server = Server(self)
     self.server.open_connection()