[Python-modules-commits] [pywinrm] 01/04: Import pywinrm_0.2.2.orig.tar.gz

Scott Kitterman kitterman at moszumanska.debian.org
Sun Jan 8 06:23:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

kitterman pushed a commit to branch master
in repository pywinrm.

commit 06e70c998d02fbe051192a356638e9beb9b28c5e
Author: Scott Kitterman <scott at kitterman.com>
Date:   Sun Jan 8 01:03:07 2017 -0500

    Import pywinrm_0.2.2.orig.tar.gz
---
 PKG-INFO                                 | 184 +++++++++++----
 pywinrm.egg-info/PKG-INFO                | 278 +++++++++++++++++++++++
 pywinrm.egg-info/SOURCES.txt             |  22 ++
 pywinrm.egg-info/dependency_links.txt    |   1 +
 pywinrm.egg-info/requires.txt            |  10 +
 pywinrm.egg-info/top_level.txt           |   1 +
 setup.cfg                                |  18 ++
 setup.py                                 |  12 +-
 winrm/__init__.py                        |  67 +++---
 winrm/exceptions.py                      |  47 ++--
 winrm/protocol.py                        | 294 ++++++++++++++----------
 winrm/tests/conftest.py                  |  24 +-
 winrm/tests/test_integration_protocol.py |  29 ++-
 winrm/tests/test_integration_session.py  |   3 +-
 winrm/tests/test_protocol.py             |   7 +-
 winrm/tests/test_session.py              |   9 +-
 winrm/transport.py                       | 376 ++++++++++++++-----------------
 17 files changed, 936 insertions(+), 446 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index ae579fa..73dc09c 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,55 +1,72 @@
 Metadata-Version: 1.1
 Name: pywinrm
-Version: 0.0.3
+Version: 0.2.2
 Summary: Python library for Windows Remote Management
 Home-page: http://github.com/diyan/pywinrm/
 Author: Alexey Diyan
 Author-email: alexey.diyan at gmail.com
 License: MIT license
-Description: pywinrm |Build Status| |Coverage Status|
-        ========================================
+Description: pywinrm |Build Status| |AppVeyor Build Status| |Coverage Status|
+        ================================================================
         
-        pywinrm is a Python client for Windows Remote Management (WinRM). This
-        allows you to invoke commands on target Windows machines from any
-        machine that can run Python.
+        pywinrm is a Python client for the Windows Remote Management (WinRM)
+        service. It allows you to invoke commands on target Windows machines
+        from any machine that can run Python.
         
-        WinRM allows you to call native objects in Windows. This includes, but
-        is not limited to, running batch scripts, powershell scripts and
-        fetching WMI variables. For more information on WinRM, please visit
-        `Microsoft's WinRM
+        WinRM allows you to perform various management tasks remotely. These
+        include, but are not limited to: running batch scripts, powershell
+        scripts, and fetching WMI variables.
+        
+        Used by `Ansible <https://www.ansible.com/>`__ for Windows support.
+        
+        For more information on WinRM, please visit `Microsoft's WinRM
         site <http://msdn.microsoft.com/en-us/library/aa384426.aspx>`__.
         
         Requirements
         ------------
         
         -  Linux, Mac OS X or Windows
-        -  CPython 2.6, 2.7, 3.2, 3.3 or PyPy 1.9
-        -  `python-kerberos <http://pypi.python.org/pypi/kerberos>`__ is
-           optional
+        -  CPython 2.6-2.7, 3.3-3.5 or PyPy2
+        -  `requests-kerberos <http://pypi.python.org/pypi/requests-kerberos>`__
+           and
+           `requests-credssp <https://github.com/jborean93/requests-credssp>`__
+           is optional
         
         Installation
         ------------
         
-        To install pywinrm, simply
-        ~~~~~~~~~~~~~~~~~~~~~~~~~~
+        To install pywinrm with support for basic, certificate, and NTLM auth, simply
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         
         .. code:: bash
         
-            $ pip install http://github.com/diyan/pywinrm/archive/master.zip
+            $ pip install pywinrm
         
-        To use Kerberos authentication you need optional dependency
-        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        To use Kerberos authentication you need these optional dependencies
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         
         .. code:: bash
         
+            # for Debian/Ubuntu/etc:
             $ sudo apt-get install python-dev libkrb5-dev
-            $ pip install kerberos
+            $ pip install pywinrm[kerberos]
+        
+            # for RHEL/CentOS/etc:
+            $ sudo yum install gcc krb5-devel krb5-workstation
+            $ pip install pywinrm[kerberos]
+        
+        To use CredSSP authentication you need these optional depdencies
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        .. code:: bash
+        
+            pip install pywinrm[credssp]
         
         Example Usage
         -------------
         
-        Run process on remote host
-        ~~~~~~~~~~~~~~~~~~~~~~~~~~
+        Run a process on a remote host
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         
         .. code:: python
         
@@ -70,7 +87,8 @@ Description: pywinrm |Build Status| |Coverage Status|
             ...
             >>> r.std_err
         
-        NOTE pywirnm with try guess correct endpoint url from various formats:
+        NOTE: pywinrm will try and guess the correct endpoint url from the
+        following formats:
         
         -  windows-host -> http://windows-host:5985/wsman
         -  windows-host:1111 -> http://windows-host:1111/wsman
@@ -78,8 +96,8 @@ Description: pywinrm |Build Status| |Coverage Status|
         -  http://windows-host:1111 -> http://windows-host:1111/wsman
         -  http://windows-host:1111/wsman -> http://windows-host:1111/wsman
         
-        Run Powershell on remote host
-        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        Run Powershell script on remote host
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         
         .. code:: python
         
@@ -101,56 +119,138 @@ Description: pywinrm |Build Status| |Coverage Status|
         
             >>> r.std_err
         
-        Powershell script will be base64 UTF16 little endian encoded prior to
-        sending to Windows host. Error messages are converted from the
+        Powershell scripts will be base64 UTF16 little-endian encoded prior to
+        sending to the Windows host. Error messages are converted from the
         Powershell CLIXML format to a human readable format as a convenience.
         
-        Run process with low-level API
-        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        Run process with low-level API with domain user, disabling HTTPS cert validation
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         
         .. code:: python
         
             from winrm.protocol import Protocol
         
             p = Protocol(
-                endpoint='http://windows-host:5985/wsman',
-                transport='plaintext',
-                username='john.smith',
-                password='secret')
+                endpoint='https://windows-host:5986/wsman',
+                transport='ntlm',
+                username=r'somedomain\someuser',
+                password='secret',
+                server_cert_validation='ignore')
             shell_id = p.open_shell()
             command_id = p.run_command(shell_id, 'ipconfig', ['/all'])
             std_out, std_err, status_code = p.get_command_output(shell_id, command_id)
             p.cleanup_command(shell_id, command_id)
             p.close_shell(shell_id)
         
-        Enable WinRM on remote host
-        ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        Valid transport options
+        ~~~~~~~~~~~~~~~~~~~~~~~
+        
+        pywinrm supports various transport methods in order to authenticate with
+        the WinRM server. The options that are supported in the ``transport``
+        parameter are; \* ``basic``: Basic auth only works for local Windows
+        accounts not domain accounts. Credentials are base64 encoded when
+        sending to the server. \* ``plaintext``: Same as basic auth. \*
+        ``certificate``: Authentication is done through a certificate that is
+        mapped to a local Windows account on the server. \* ``ssl``: When used
+        in conjunction with ``cert_pem`` and ``cert_key_pem`` it will use a
+        certificate as above. If not will revert to basic auth over HTTPS. \*
+        ``kerberos``: Will use Kerberos authentication for domain accounts which
+        only works when the client is in the same domain as the server and the
+        required dependencies are installed. Currently a Kerberos ticket needs
+        to be initiliased outside of pywinrm using the kinit command. \*
+        ``ntlm``: Will use NTLM authentication for both domain and local
+        accounts. Currently no support for NTLMv2 auth and other features
+        included in that version (WIP). \* ``credssp``: Will use CredSSP
+        authentication for both domain and local accounts. Allows double hop
+        authentication. This only works over a HTTPS endpoint and not HTTP.
+        
+        HTTP or HTTPS endpoint
+        ~~~~~~~~~~~~~~~~~~~~~~
+        
+        While either a HTTP or HTTPS endpoint can be used as the transport
+        method, using HTTPS is prefered as the messages are encrypted using SSL.
+        To use HTTPS either a self signed certificate or one from a CA can be
+        used. You can use this
+        `guide <http://www.joseph-streeter.com/?p=1086>`__ to set up a HTTPS
+        endpoint with a self signed certificate.
+        
+        If you still wish to use a HTTP endpoint and loose confidentiality in
+        your messages you will need to enable unencrypted messages in the server
+        by running the following command
+        
+        ::
+        
+            # from cmd:
+            winrm set winrm/config/service @{AllowUnencrypted="true"}
+        
+        As a repeat this should definitely not be used as your credentials and
+        messages will allow anybody to see what is sent over the wire.
         
-        -  Enable basic WinRM authentication (good only for troubleshooting, for
-           hosts in domain better to use Kerberos authentication)
-        -  Allow unencrypted message passing over WinRM (not secure for hosts in
-           domain but this feature is not implemented so far)
+        There are plans in place to allow message encryption for messages sent
+        with Kerberos or NTLM messages in the future.
+        
+        Enabling WinRM on remote host
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        Enable WinRM over HTTP and HTTPS with self-signed certificate (includes
+        firewall rules):
+        
+        ::
+        
+            # from powershell:
+            Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))
+        
+        Enable WinRM over HTTP for test usage (includes firewall rules):
         
         ::
         
-            winrm set winrm/config/client/auth @{Basic="true"}
+            winrm quickconfig
+        
+        Enable WinRM basic authentication. For domain users, it is necessary to
+        use NTLM, Kerberos or CredSSP authentication (Kerberos and NTLM
+        authentication are enabled by default CredSSP isn't).
+        
+        ::
+        
+            # from cmd:
             winrm set winrm/config/service/auth @{Basic="true"}
-            winrm set winrm/config/service @{AllowUnencrypted="true"}
+        
+        Enable WinRM CredSSP authentication. This allows double hop support so
+        you can authenticate with a network service when running command son the
+        remote host. This command is run in Powershell.
+        
+        .. code:: powershell
+        
+            Enable-WSManCredSSP -Role Server -Force
+            Set-Item -Path "WSMan:\localhost\Service\Auth\CredSSP" -Value $true
         
         Contributors (alphabetically)
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         
         -  Alessandro Pilotti
+        -  Alexey Diyan
+        -  Chris Church
         -  David Cournapeau
         -  Gema Gomez
+        -  Jijo Varghese
+        -  Jordan Borean
+        -  Juan J. Martinez
+        -  Lukas Bednar
+        -  Manuel Sabban
         -  Matt Clark
+        -  Matt Davis
+        -  Maxim Kovgan
+        -  Nir Cohen
         -  Patrick Dunnigan
+        -  Reina Abolofia
         
         Want to help - send a pull request. I will accept good pull requests for
         sure.
         
         .. |Build Status| image:: https://travis-ci.org/diyan/pywinrm.png
            :target: https://travis-ci.org/diyan/pywinrm
+        .. |AppVeyor Build Status| image:: https://ci.appveyor.com/api/projects/status/github/diyan/pywinrm
+           :target: https://ci.appveyor.com/project/diyan/pywinrm
         .. |Coverage Status| image:: https://coveralls.io/repos/diyan/pywinrm/badge.png
            :target: https://coveralls.io/r/diyan/pywinrm
         
@@ -167,8 +267,10 @@ Classifier: Programming Language :: Python :: 2
 Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
 Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
 Classifier: Topic :: System :: Clustering
diff --git a/pywinrm.egg-info/PKG-INFO b/pywinrm.egg-info/PKG-INFO
new file mode 100644
index 0000000..73dc09c
--- /dev/null
+++ b/pywinrm.egg-info/PKG-INFO
@@ -0,0 +1,278 @@
+Metadata-Version: 1.1
+Name: pywinrm
+Version: 0.2.2
+Summary: Python library for Windows Remote Management
+Home-page: http://github.com/diyan/pywinrm/
+Author: Alexey Diyan
+Author-email: alexey.diyan at gmail.com
+License: MIT license
+Description: pywinrm |Build Status| |AppVeyor Build Status| |Coverage Status|
+        ================================================================
+        
+        pywinrm is a Python client for the Windows Remote Management (WinRM)
+        service. It allows you to invoke commands on target Windows machines
+        from any machine that can run Python.
+        
+        WinRM allows you to perform various management tasks remotely. These
+        include, but are not limited to: running batch scripts, powershell
+        scripts, and fetching WMI variables.
+        
+        Used by `Ansible <https://www.ansible.com/>`__ for Windows support.
+        
+        For more information on WinRM, please visit `Microsoft's WinRM
+        site <http://msdn.microsoft.com/en-us/library/aa384426.aspx>`__.
+        
+        Requirements
+        ------------
+        
+        -  Linux, Mac OS X or Windows
+        -  CPython 2.6-2.7, 3.3-3.5 or PyPy2
+        -  `requests-kerberos <http://pypi.python.org/pypi/requests-kerberos>`__
+           and
+           `requests-credssp <https://github.com/jborean93/requests-credssp>`__
+           is optional
+        
+        Installation
+        ------------
+        
+        To install pywinrm with support for basic, certificate, and NTLM auth, simply
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        .. code:: bash
+        
+            $ pip install pywinrm
+        
+        To use Kerberos authentication you need these optional dependencies
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        .. code:: bash
+        
+            # for Debian/Ubuntu/etc:
+            $ sudo apt-get install python-dev libkrb5-dev
+            $ pip install pywinrm[kerberos]
+        
+            # for RHEL/CentOS/etc:
+            $ sudo yum install gcc krb5-devel krb5-workstation
+            $ pip install pywinrm[kerberos]
+        
+        To use CredSSP authentication you need these optional depdencies
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        .. code:: bash
+        
+            pip install pywinrm[credssp]
+        
+        Example Usage
+        -------------
+        
+        Run a process on a remote host
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        .. code:: python
+        
+            import winrm
+        
+            s = winrm.Session('windows-host.example.com', auth=('john.smith', 'secret'))
+            r = s.run_cmd('ipconfig', ['/all'])
+            >>> r.status_code
+            0
+            >>> r.std_out
+            Windows IP Configuration
+        
+               Host Name . . . . . . . . . . . . : WINDOWS-HOST
+               Primary Dns Suffix  . . . . . . . :
+               Node Type . . . . . . . . . . . . : Hybrid
+               IP Routing Enabled. . . . . . . . : No
+               WINS Proxy Enabled. . . . . . . . : No
+            ...
+            >>> r.std_err
+        
+        NOTE: pywinrm will try and guess the correct endpoint url from the
+        following formats:
+        
+        -  windows-host -> http://windows-host:5985/wsman
+        -  windows-host:1111 -> http://windows-host:1111/wsman
+        -  http://windows-host -> http://windows-host:5985/wsman
+        -  http://windows-host:1111 -> http://windows-host:1111/wsman
+        -  http://windows-host:1111/wsman -> http://windows-host:1111/wsman
+        
+        Run Powershell script on remote host
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        .. code:: python
+        
+            import winrm
+        
+            ps_script = """$strComputer = $Host
+            Clear
+            $RAM = WmiObject Win32_ComputerSystem
+            $MB = 1048576
+        
+            "Installed Memory: " + [int]($RAM.TotalPhysicalMemory /$MB) + " MB" """
+        
+            s = winrm.Session('windows-host.example.com', auth=('john.smith', 'secret'))
+            r = s.run_ps(ps_script)
+            >>> r.status_code
+            0
+            >>> r.std_out
+            Installed Memory: 3840 MB
+        
+            >>> r.std_err
+        
+        Powershell scripts will be base64 UTF16 little-endian encoded prior to
+        sending to the Windows host. Error messages are converted from the
+        Powershell CLIXML format to a human readable format as a convenience.
+        
+        Run process with low-level API with domain user, disabling HTTPS cert validation
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        .. code:: python
+        
+            from winrm.protocol import Protocol
+        
+            p = Protocol(
+                endpoint='https://windows-host:5986/wsman',
+                transport='ntlm',
+                username=r'somedomain\someuser',
+                password='secret',
+                server_cert_validation='ignore')
+            shell_id = p.open_shell()
+            command_id = p.run_command(shell_id, 'ipconfig', ['/all'])
+            std_out, std_err, status_code = p.get_command_output(shell_id, command_id)
+            p.cleanup_command(shell_id, command_id)
+            p.close_shell(shell_id)
+        
+        Valid transport options
+        ~~~~~~~~~~~~~~~~~~~~~~~
+        
+        pywinrm supports various transport methods in order to authenticate with
+        the WinRM server. The options that are supported in the ``transport``
+        parameter are; \* ``basic``: Basic auth only works for local Windows
+        accounts not domain accounts. Credentials are base64 encoded when
+        sending to the server. \* ``plaintext``: Same as basic auth. \*
+        ``certificate``: Authentication is done through a certificate that is
+        mapped to a local Windows account on the server. \* ``ssl``: When used
+        in conjunction with ``cert_pem`` and ``cert_key_pem`` it will use a
+        certificate as above. If not will revert to basic auth over HTTPS. \*
+        ``kerberos``: Will use Kerberos authentication for domain accounts which
+        only works when the client is in the same domain as the server and the
+        required dependencies are installed. Currently a Kerberos ticket needs
+        to be initiliased outside of pywinrm using the kinit command. \*
+        ``ntlm``: Will use NTLM authentication for both domain and local
+        accounts. Currently no support for NTLMv2 auth and other features
+        included in that version (WIP). \* ``credssp``: Will use CredSSP
+        authentication for both domain and local accounts. Allows double hop
+        authentication. This only works over a HTTPS endpoint and not HTTP.
+        
+        HTTP or HTTPS endpoint
+        ~~~~~~~~~~~~~~~~~~~~~~
+        
+        While either a HTTP or HTTPS endpoint can be used as the transport
+        method, using HTTPS is prefered as the messages are encrypted using SSL.
+        To use HTTPS either a self signed certificate or one from a CA can be
+        used. You can use this
+        `guide <http://www.joseph-streeter.com/?p=1086>`__ to set up a HTTPS
+        endpoint with a self signed certificate.
+        
+        If you still wish to use a HTTP endpoint and loose confidentiality in
+        your messages you will need to enable unencrypted messages in the server
+        by running the following command
+        
+        ::
+        
+            # from cmd:
+            winrm set winrm/config/service @{AllowUnencrypted="true"}
+        
+        As a repeat this should definitely not be used as your credentials and
+        messages will allow anybody to see what is sent over the wire.
+        
+        There are plans in place to allow message encryption for messages sent
+        with Kerberos or NTLM messages in the future.
+        
+        Enabling WinRM on remote host
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        Enable WinRM over HTTP and HTTPS with self-signed certificate (includes
+        firewall rules):
+        
+        ::
+        
+            # from powershell:
+            Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))
+        
+        Enable WinRM over HTTP for test usage (includes firewall rules):
+        
+        ::
+        
+            winrm quickconfig
+        
+        Enable WinRM basic authentication. For domain users, it is necessary to
+        use NTLM, Kerberos or CredSSP authentication (Kerberos and NTLM
+        authentication are enabled by default CredSSP isn't).
+        
+        ::
+        
+            # from cmd:
+            winrm set winrm/config/service/auth @{Basic="true"}
+        
+        Enable WinRM CredSSP authentication. This allows double hop support so
+        you can authenticate with a network service when running command son the
+        remote host. This command is run in Powershell.
+        
+        .. code:: powershell
+        
+            Enable-WSManCredSSP -Role Server -Force
+            Set-Item -Path "WSMan:\localhost\Service\Auth\CredSSP" -Value $true
+        
+        Contributors (alphabetically)
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        
+        -  Alessandro Pilotti
+        -  Alexey Diyan
+        -  Chris Church
+        -  David Cournapeau
+        -  Gema Gomez
+        -  Jijo Varghese
+        -  Jordan Borean
+        -  Juan J. Martinez
+        -  Lukas Bednar
+        -  Manuel Sabban
+        -  Matt Clark
+        -  Matt Davis
+        -  Maxim Kovgan
+        -  Nir Cohen
+        -  Patrick Dunnigan
+        -  Reina Abolofia
+        
+        Want to help - send a pull request. I will accept good pull requests for
+        sure.
+        
+        .. |Build Status| image:: https://travis-ci.org/diyan/pywinrm.png
+           :target: https://travis-ci.org/diyan/pywinrm
+        .. |AppVeyor Build Status| image:: https://ci.appveyor.com/api/projects/status/github/diyan/pywinrm
+           :target: https://ci.appveyor.com/project/diyan/pywinrm
+        .. |Coverage Status| image:: https://coveralls.io/repos/diyan/pywinrm/badge.png
+           :target: https://coveralls.io/r/diyan/pywinrm
+        
+Keywords: winrm,ws-man,devops,ws-management
+Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Environment :: Console
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: System Administrators
+Classifier: Natural Language :: English
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: System :: Clustering
+Classifier: Topic :: System :: Distributed Computing
+Classifier: Topic :: System :: Systems Administration
diff --git a/pywinrm.egg-info/SOURCES.txt b/pywinrm.egg-info/SOURCES.txt
new file mode 100644
index 0000000..1f8e650
--- /dev/null
+++ b/pywinrm.egg-info/SOURCES.txt
@@ -0,0 +1,22 @@
+setup.cfg
+setup.py
+pywinrm.egg-info/PKG-INFO
+pywinrm.egg-info/SOURCES.txt
+pywinrm.egg-info/dependency_links.txt
+pywinrm.egg-info/requires.txt
+pywinrm.egg-info/top_level.txt
+winrm/__init__.py
+winrm/exceptions.py
+winrm/protocol.py
+winrm/transport.py
+winrm/tests/__init__.py
+winrm/tests/conftest.py
+winrm/tests/sample_script.ps1
+winrm/tests/test_cmd.py
+winrm/tests/test_integration_protocol.py
+winrm/tests/test_integration_session.py
+winrm/tests/test_nori_type_casting.py
+winrm/tests/test_powershell.py
+winrm/tests/test_protocol.py
+winrm/tests/test_session.py
+winrm/tests/test_wql.py
\ No newline at end of file
diff --git a/pywinrm.egg-info/dependency_links.txt b/pywinrm.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/pywinrm.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/pywinrm.egg-info/requires.txt b/pywinrm.egg-info/requires.txt
new file mode 100644
index 0000000..9f80b3e
--- /dev/null
+++ b/pywinrm.egg-info/requires.txt
@@ -0,0 +1,10 @@
+xmltodict
+requests>=2.9.1
+requests_ntlm>=0.3.0
+six
+
+[credssp]
+requests-credssp>=0.0.1
+
+[kerberos]
+requests-kerberos>=0.10.0
diff --git a/pywinrm.egg-info/top_level.txt b/pywinrm.egg-info/top_level.txt
new file mode 100644
index 0000000..e6681c3
--- /dev/null
+++ b/pywinrm.egg-info/top_level.txt
@@ -0,0 +1 @@
+winrm
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..a70392e
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,18 @@
+[bdist_rpm]
+requires = python-xmltodict
+
+[bdist_wheel]
+universal = 1
+
+[pytest]
+norecursedirs = .git .idea env
+pep8ignore = tests/*.py E501
+
+[metadata]
+description-file = README.md
+
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
index 9d29f50..6e777d4 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
-from distutils.core import setup
+from setuptools import setup
 
-__version__ = '0.0.3'
+__version__ = '0.2.2'
 project_name = 'pywinrm'
 
 # PyPi supports only reStructuredText, so pandoc should be installed
@@ -11,7 +11,6 @@ try:
 except ImportError:
     long_description = ''
 
-
 setup(
     name=project_name,
     version=__version__,
@@ -24,7 +23,8 @@ setup(
     license='MIT license',
     packages=('winrm', 'winrm.tests'),
     package_data={'winrm.tests': ['*.ps1']},
-    install_requires=['xmltodict', 'isodate'],
+    install_requires=['xmltodict', 'requests>=2.9.1', 'requests_ntlm>=0.3.0', 'six'],
+    extras_require = dict(kerberos=['requests-kerberos>=0.10.0'], credssp=['requests-credssp>=0.0.1']),
     classifiers=[
         'Development Status :: 4 - Beta',
         'Environment :: Console',
@@ -37,8 +37,10 @@ setup(
         'Programming Language :: Python :: 2.6',
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.2',
         'Programming Language :: Python :: 3.3',
+        'Programming Language :: Python :: 3.4',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
         'Programming Language :: Python :: Implementation :: PyPy',
         'Topic :: Software Development :: Libraries :: Python Modules',
         'Topic :: System :: Clustering',
diff --git a/winrm/__init__.py b/winrm/__init__.py
index 6f5458d..56e5541 100644
--- a/winrm/__init__.py
+++ b/winrm/__init__.py
@@ -1,9 +1,17 @@
+from __future__ import unicode_literals
 import re
-import base64
+from base64 import b64encode
 import xml.etree.ElementTree as ET
 
 from winrm.protocol import Protocol
 
+# Feature support attributes for multi-version clients.
+# These values can be easily checked for with hasattr(winrm, "FEATURE_X"),
+# "'auth_type' in winrm.FEATURE_SUPPORTED_AUTHTYPES", etc for clients to sniff features
+# supported by a particular version of pywinrm
+FEATURE_SUPPORTED_AUTHTYPES=['basic', 'certificate', 'ntlm', 'kerberos', 'plaintext', 'ssl', 'credssp']
+FEATURE_READ_TIMEOUT=True
+FEATURE_OPERATION_TIMEOUT=True
 
 class Response(object):
     """Response from a remote command execution"""
@@ -11,20 +19,21 @@ class Response(object):
         self.std_out, self.std_err, self.status_code = args
 
     def __repr__(self):
-        #TODO put tree dots at the end if out/err was truncated
+        # TODO put tree dots at the end if out/err was truncated
         return '<Response code {0}, out "{1}", err "{2}">'.format(
             self.status_code, self.std_out[:20], self.std_err[:20])
 
 
 class Session(object):
-    #TODO implement context manager methods
-    def __init__(self, target, auth, transport='plaintext'):
+    # TODO implement context manager methods
+    def __init__(self, target, auth, **kwargs):
         username, password = auth
-        self.url = self._build_url(target, transport)
-        self.protocol = Protocol(self.url, transport=transport, username=username, password=password)
+        self.url = self._build_url(target, kwargs.get('transport', 'plaintext'))
+        self.protocol = Protocol(self.url,
+                                 username=username, password=password, **kwargs)
 
     def run_cmd(self, command, args=()):
-        #TODO optimize perf. Do not call open/close shell every time
+        # TODO optimize perf. Do not call open/close shell every time
         shell_id = self.protocol.open_shell()
         command_id = self.protocol.run_command(shell_id, command, args)
         rs = Response(self.protocol.get_command_output(shell_id, command_id))
@@ -32,30 +41,31 @@ class Session(object):
         self.protocol.close_shell(shell_id)
         return rs
 
-
     def run_ps(self, script):
-        """base64 encodes a Powershell script and executes the powershell encoded script command"""
-
+        """base64 encodes a Powershell script and executes the powershell
+        encoded script command
+        """
         # must use utf16 little endian on windows
-        base64_script = base64.b64encode(script.encode("utf_16_le"))
-        rs = self.run_cmd("powershell -encodedcommand %s" % (base64_script))
+        encoded_ps = b64encode(script.encode('utf_16_le')).decode('ascii')
+        rs = self.run_cmd('powershell -encodedcommand {0}'.format(encoded_ps))
         if len(rs.std_err):
-            # if there was an error message, clean it it up and make it human readable
-            rs.std_err = self.clean_error_msg(rs.std_err)
+            # if there was an error message, clean it it up and make it human
+            # readable
+            rs.std_err = self._clean_error_msg(rs.std_err)
         return rs
 
-
-    def clean_error_msg(self, msg):
-        """converts a Powershell CLIXML message to a more human readable string"""
-
+    def _clean_error_msg(self, msg):
+        """converts a Powershell CLIXML message to a more human readable string
+        """
+        # TODO prepare unit test, beautify code
         # if the msg does not start with this, return it as is
         if msg.startswith("#< CLIXML\r\n"):
-            # for proper xml, we need to remove the CLIXML part (the first line)
+            # for proper xml, we need to remove the CLIXML part
+            # (the first line)
             msg_xml = msg[11:]
-            print(">%s<" % msg_xml)
             try:
                 # remove the namespaces from the xml for easier processing
-                msg_xml = self.strip_namespace(msg_xml)
+                msg_xml = self._strip_namespace(msg_xml)
                 root = ET.fromstring(msg_xml)
                 # the S node is the error message, find all S nodes
                 nodes = root.findall("./S")
@@ -63,11 +73,13 @@ class Session(object):
                 for s in nodes:
                     # append error msg string to result, also
                     # the hex chars represent CRLF so we replace with newline
-                    new_msg += s.text.replace("_x000D__x000A_","\n")
+                    new_msg += s.text.replace("_x000D__x000A_", "\n")
             except Exception as e:
                 # if any of the above fails, the msg was not true xml
                 # print a warning and return the orignal string
-                print("Warning: there was a problem converting the Powershell error message: %s" % (e))
+                # TODO do not print, raise user defined error instead
+                print("Warning: there was a problem converting the Powershell"
+                      " error message: %s" % (e))
             else:
                 # if new_msg was populated, that's our error message
                 # otherwise the original error message will be used
@@ -76,8 +88,7 @@ class Session(object):
                     msg = new_msg.strip()
         return msg
 
-
-    def strip_namespace(self, xml):
+    def _strip_namespace(self, xml):
         """strips any namespaces from an xml string"""
         try:
             p = re.compile("xmlns=*[\"\"][^\"\"]*[\"\"]")
@@ -88,14 +99,14 @@ class Session(object):
         except Exception as e:
             raise Exception(e)
 
-
     @staticmethod
     def _build_url(target, transport):
         match = re.match(
-            '(?i)^((?P<scheme>http[s]?)://)?(?P<host>[0-9a-z-_.]+)(:(?P<port>\d+))?(?P<path>(/)?(wsman)?)?', target)
+            '(?i)^((?P<scheme>http[s]?)://)?(?P<host>[0-9a-z-_.]+)(:(?P<port>\d+))?(?P<path>(/)?(wsman)?)?', target)  # NOQA
         scheme = match.group('scheme')
         if not scheme:
-            scheme = 'https' if transport == 'ssl' else 'http'  # TODO do we have anything other than HTTP/HTTPS
+            # TODO do we have anything other than HTTP/HTTPS
+            scheme = 'https' if transport == 'ssl' else 'http'
         host = match.group('host')
         port = match.group('port')
         if not port:
diff --git a/winrm/exceptions.py b/winrm/exceptions.py
index a95562f..acf4b9d 100644
--- a/winrm/exceptions.py
+++ b/winrm/exceptions.py
@@ -1,41 +1,30 @@
-import re
+from __future__ import unicode_literals
 
 
-class WinRMWebServiceError(Exception):
-    """Generic WinRM SOAP Error"""
-    pass
-
-
-class WinRMAuthorizationError(Exception):
-    """Authorization Error"""
-    pass
-
-
-class WinRMWSManFault(Exception):
-    """A Fault returned in the SOAP response. The XML node is a WSManFault"""
-    pass
-
+class WinRMError(Exception):
+    """"Generic WinRM error"""
+    code = 500
 
 class WinRMTransportError(Exception):
-    """"Transport-level error"""
+    """WinRM errors specific to transport-level problems (unexpcted HTTP error codes, etc)"""
     code = 500
 
-    def __init__(self, transport, message):
-        self.transport = transport
-        self.message = message
-
-    def __str__(self):
-        return '{0} {1}. {2}'.format(self.code, re.sub('Error$', '', self.__class__.__name__), self.message)
+class WinRMOperationTimeoutError(Exception):
+    """
+    Raised when a WinRM-level operation timeout (not a connection-level timeout) has occurred. This is
+    considered a normal error that should be retried transparently by the client when waiting for output from
+    a long-running process.
+    """
+    code = 500
 
-    def __repr__(self):
-        return "{0}(code={1}, transport='{2}', message='{3}')".format(
-            self.__class__.__name__, self.code, self.transport, self.message)
+class AuthenticationError(WinRMError):
+    """Authorization Error"""
+    code = 401
 
 
-class UnauthorizedError(WinRMTransportError):
-    """Raise if the user is not authorized"""
-    code = 401
+class BasicAuthDisabledError(AuthenticationError):
+    message = 'WinRM/HTTP Basic authentication is not enabled on remote host'
 
 
-class TimeoutError(WinRMTransportError):
+class InvalidCredentialsError(AuthenticationError):
     pass
\ No newline at end of file
diff --git a/winrm/protocol.py b/winrm/protocol.py
index 73c238e..70ff2f6 100644
--- a/winrm/protocol.py
+++ b/winrm/protocol.py
@@ -1,98 +1,127 @@
+"""Contains client side logic of WinRM SOAP protocol implementation"""
+from __future__ import unicode_literals
 import base64
-from datetime import timedelta
 import uuid
+
 import xml.etree.ElementTree as ET
-from isodate.isoduration import duration_isoformat
 import xmltodict
-from winrm.transport import HttpPlaintext, HttpKerberos, HttpSSL
 
+from six import text_type, binary_type
+
+from winrm.transport import Transport
+from winrm.exceptions import WinRMError, WinRMOperationTimeoutError
 
 class Protocol(object):
+    """This is the main class that does the SOAP request/response logic. There
+    are a few helper classes, but pretty much everything comes through here
+    first.
     """
-    This is the main class that does the SOAP request/response logic. There are a few helper classes, but pretty
-    much everything comes through here first.
-    """
-    DEFAULT_TIMEOUT = 'PT60S'
+    DEFAULT_READ_TIMEOUT_SEC = 30
+    DEFAULT_OPERATION_TIMEOUT_SEC = 20
     DEFAULT_MAX_ENV_SIZE = 153600
     DEFAULT_LOCALE = 'en-US'
 
-    def __init__(self, endpoint, transport='plaintext', username=None, password=None, realm=None, service=None, keytab=None, ca_trust_path=None, cert_pem=None, cert_key_pem=None):
+    def __init__(
+            self, endpoint, transport='plaintext', username=None,
+            password=None, realm=None, service=None, keytab=None,
+            ca_trust_path=None, cert_pem=None, cert_key_pem=None,
+            server_cert_validation='validate',
+            kerberos_delegation=False,
+            read_timeout_sec=DEFAULT_READ_TIMEOUT_SEC,
+            operation_timeout_sec=DEFAULT_OPERATION_TIMEOUT_SEC,
+            kerberos_hostname_override=None,
+        ):
         """
         @param string endpoint: the WinRM webservice endpoint
-        @param string transport: transport type, one of 'kerberos' (default), 'ssl', 'plaintext'
+        @param string transport: transport type, one of 'plaintext' (default), 'kerberos', 'ssl', 'ntlm', 'credssp'  # NOQA
         @param string username: username
         @param string password: password
-        @param string realm: the Kerberos realm we are authenticating to
+        @param string realm: unused
         @param string service: the service name, default is HTTP
         @param string keytab: the path to a keytab file if you are using one
         @param string ca_trust_path: Certification Authority trust path
-        @param string cert_pem: client authentication certificate file path in PEM format
-        @param string cert_key_pem: client authentication certificate key file path in PEM format
+        @param string cert_pem: client authentication certificate file path in PEM format  # NOQA
+        @param string cert_key_pem: client authentication certificate key file path in PEM format  # NOQA
+        @param string server_cert_validation: whether server certificate should be validated on Python versions that suppport it; one of 'validate' (default), 'ignore' #NOQA
+        @param bool kerberos_delegation: if True, TGT is sent to target server to allow multiple hops  # NOQA
+        @param int read_timeout_sec: maximum seconds to wait before an HTTP connect/read times out (default 30). This value should be slightly higher than operation_timeout_sec, as the server can block *at least* that long. # NOQA
+        @param int operation_timeout_sec: maximum allowed time in seconds for any single wsman HTTP operation (default 20). Note that operation timeouts while receiving output (the only wsman operation that should take any significant time, and where these timeouts are expected) will be silently retried indefinitely. # NOQA
+        @param string kerberos_hostname_override: the hostname to use for the kerberos exchange (defaults to the hostname in the endpoint URL)
         """
-        self.endpoint = endpoint
-        self.timeout = Protocol.DEFAULT_TIMEOUT
+
+        if operation_timeout_sec >= read_timeout_sec or operation_timeout_sec < 1:
+            raise WinRMError("read_timeout_sec must exceed operation_timeout_sec, and both must be non-zero")
+
... 1018 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pywinrm.git



More information about the Python-modules-commits mailing list