cournape / aio-winrm

A python 3.5+ async library for the WinRM protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python 3.5+ library implementing the WinRM protocol on top of asyncio. Work in
progress: no TLS (plain text only), API not stable.

aio-winrm is licensed under the APACHE 2.0 license.

Sync API:

    from aiowinrm.sync import run_cmd

    host = "192.168.1.1"
    auth = ("user", "password")
    response = run_cmd(host, auth, "ipconfig", ("/all",))

Tentative async API:

    import asyncio
    from aiowinrm import run_cmd

    def callback_factory(host):
        """ Returns a callback that prefix every output line by host.
        """
        def callback(s):
            output = "\n".join(
                host + ":" + line
                for line in s.splitlines()
            )
            print(output)

        return callback

    host = "172.17.5.2"
    auth = ("vagrant", "vagrant")
    loop = asyncio.get_event_loop()
    loop.run_until_complete(
        run_cmd(
            host, auth, "ipconfig", ("/All",),
            stdout_callback=callback_factory(host),
            stderr_callback=callback_factory(host),
        )
    )
    loop.close()

About

A python 3.5+ async library for the WinRM protocol

License:Other


Languages

Language:Python 100.0%