2016-05-06 13 views
0

私はpywinrmモジュールの使い方を理解するための世界を作っていました。私は解決できないエラーに遭遇しました。pywinrmをリモートのWindowsマシンに接続するにはどうすればよいですか?

私はバージョン0.1.1と0.0.3の両方を使ってみましたが、Windows 7のボックスでPython 3.4.3を使用しています。

これはプログラムです:

私はgithubの上の使用例からコピーされ、この出力を得た
import pywinrm 

s = winrm.Session('windows-myhostname', auth=('myusername', 'mypassword')) 

r = s.run_cmd('ipconfig', ['/all']) 

print (r.status_code) 
print (r.std_out) 

Traceback (most recent call last): 
    File "My_program_path_here.py", line 18, in <module> 
     r = s.run_cmd('ipconfig', ['/all']) 
    File "C:\Python34\lib\site-packages\winrm\__init__.py", line 29, in run_cmd 
     shell_id = self.protocol.open_shell() 
    File "C:\Python34\lib\site-packages\winrm\protocol.py", line 121, in open_shell 
     rs = self.send_message(xmltodict.unparse(rq)) 
    File "C:\Python34\lib\site-packages\winrm\protocol.py", line 193, in send_message 
     return self.transport.send_message(message) 
    File "C:\Python34\lib\site-packages\winrm\transport.py", line 108, in send_message 
     response = self.opener.open(request, timeout=self.timeout) 
    File "C:\Python34\lib\urllib\request.py", line 461, in open 
     req = meth(req) 
    File "C:\Python34\lib\urllib\request.py", line 1112, in do_request_ 
     raise TypeError(msg) 
    TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str. 

ソース:https://github.com/diyan/pywinrm

答えて

関連する問題