-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME
41 lines (32 loc) · 1.04 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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()