Exemplo n.º 1
0
    def main(self, run_list, mtp=3):
        runq_obj = run_queries.RunQueries()
        conf_ini_d = usersettings.UserSettings().get_conf_dict(
        )  # make this just once

        if mtp == 3:  # if a regular request Nulstar type 3
            asyncio_run(runq_obj.run_queries_m(mtp, run_list,
                                               conf_ini_d))  # starts event
Exemplo n.º 2
0
    def asyncStart(
        self,
        mode,
        step_to_fixed_delay,
        voltage,
        devices_selection,
    ):
        if sys.version_info >= (3, 7):
            from asyncio import run as asyncio_run
        else:
            loop = asyncio.new_event_loop()
            asyncio.set_event_loop(loop)
            asyncio_run = loop.run_until_complete

        asyncio_run(
            self.handle(
                mode=mode,
                step_to_fixed_delay=step_to_fixed_delay,
                voltage=voltage,
                devices_selection=devices_selection,
            ))

        if sys.version_info < (3, 7):
            loop.close()
            scheme: str = urlparse(url=url).scheme.lower()

            try:
                SupportedScheme(value=scheme)
            except ValueError:
                return parser.error(message=(
                    f'Unsupported scheme: "{scheme}". '
                    f'Supported schemes: {", ".join(sorted(mode.value for mode in SupportedScheme))}.'
                ))

            setattr(namespace, 'url', url)


async def main():
    args = NTLMTargetInformationArgumentParser().parse_args()

    LOG.addHandler(hdlr=ColoredLogHandler())
    LOG.setLevel(level=WARNING)

    try:
        print(
            text_align_delimiter(text=str(await ntlm_target_information(
                url=args.url, timeout=args.timeout)),
                                 delimiter=': '))
    except:
        LOG.exception('Unexpected error.')


if __name__ == '__main__':
    asyncio_run(main())
Exemplo n.º 4
0
    def format_commands(self, ctx: Context, formatter: HelpFormatter):
        """Display commands passed directly to the Vault client below the
        manually defined commands in the help text."""
        super().format_commands(ctx, formatter)

        asyncio_run(self._get_forwarded_commands(formatter))
Exemplo n.º 5
0
 def __init__(self):
     asyncio_run(self.__run())
Exemplo n.º 6
0
    empty string.
    """
    try:
        async with session.get(url) as response:
            try:
                return await response.text()
            except UnicodeDecodeError:
                # there is an issue with an underpinning library not always
                # decoding properly. Observed it decoding utf-8 as something
                # else
                return await response.text("utf-8")
    except InvalidURL:
        logger.exception("Invalid URL %s", url)
    except ClientError:
        logger.exception("Connection Error %s", url)
    return ""


def transform(results: List[SiteData]) -> list:
    """Transforms a list of sitedata to something compatible with jsons for
    output.

    Composed of lists, dictionaries, strings and integers."""
    return [asdict(res) for res in results]


if __name__ == "__main__":
    print("Please type in the urls to scrape and press enter. An empty line "
          "will terminate the input and trigger writing to the json.")
    asyncio_run(run_from_stdin())
Exemplo n.º 7
0
from .       import Bot
from .config import Config, load as config_load

async def main(config: Config):
    bot = Bot(config)

    host, port, tls      = config.server
    sasl_user, sasl_pass = config.sasl

    params = ConnectionParams(
        config.nickname,
        host,
        port,
        tls,
        username=config.username,
        realname=config.realname,
        password=config.password,
        sasl=SASLUserPass(sasl_user, sasl_pass)
    )
    await bot.add_server(host, params)
    await bot.run()

if __name__ == "__main__":
    parser = ArgumentParser(description="grant it mate")
    parser.add_argument("config")
    args   = parser.parse_args()

    config = config_load(args.config)
    asyncio_run(main(config))