Skip to content

Commit

Permalink
Merge pull request #106 from DMTF/Remove-Python2
Browse files Browse the repository at this point in the history
Removed Python2 support
  • Loading branch information
mraineri authored Feb 19, 2021
2 parents 08b7c4a + 0a63f06 commit 0040081
Show file tree
Hide file tree
Showing 29 changed files with 285 additions and 263 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: python
cache:
- pip
python:
- '2.7'
- '3.4'
- '3.5'
- '3.6'
Expand Down
52 changes: 28 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ python-redfish-library
.. image:: https://travis-ci.org/DMTF/python-redfish-library.svg?branch=master
:target: https://travis-ci.org/DMTF/python-redfish-library
.. image:: https://img.shields.io/pypi/v/redfish.svg?maxAge=2592000
:target: https://pypi.python.org/pypi/redfish
:target: https://pypi.python.org/pypi/redfish
.. image:: https://img.shields.io/github/release/DMTF/python-redfish-library.svg?maxAge=2592000
:target: https://github.com/DMTF/python-redfish-library/releases
:target: https://github.com/DMTF/python-redfish-library/releases
.. image:: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg
:target: https://raw.githubusercontent.com/DMTF/python-redfish-library/master/LICENSE
:target: https://raw.githubusercontent.com/DMTF/python-redfish-library/master/LICENSE
.. image:: https://img.shields.io/pypi/pyversions/redfish.svg?maxAge=2592000
:target: https://pypi.python.org/pypi/redfish
:target: https://pypi.python.org/pypi/redfish
.. image:: https://api.codacy.com/project/badge/Grade/1283adc3972d42b4a3ddb9b96660bc07
:target: https://www.codacy.com/app/rexysmydog/python-redfish-library?utm_source=github.com&utm_medium=referral&utm_content=DMTF/python-redfish-library&utm_campaign=Badge_Grade
:target: https://www.codacy.com/app/rexysmydog/python-redfish-library?utm_source=github.com&utm_medium=referral&utm_content=DMTF/python-redfish-library&utm_campaign=Badge_Grade


.. contents:: :depth: 1
Expand All @@ -21,6 +21,8 @@ python-redfish-library
Description
-----------

As of version 3.0.0, Python2 is no longer supported. If Python2 is required, ``redfish<3.0.0`` can be specified in a requirements file.

REST (Representational State Transfer) is a web based software architectural style consisting of a set of constraints that focuses on a system's resources. The Redfish library performs the basic HTTPS operations GET, POST, PUT, PATCH and DELETE on resources using the HATEOAS (Hypermedia as the Engine of Application State) Redfish architecture. API clients allow you to manage and interact with the system through a fixed URL and several URIs. Go to the `wiki <../../wiki>`_ for more details.


Expand All @@ -29,17 +31,17 @@ Installing

.. code-block:: console
pip install redfish
pip install redfish
Building from zip file source
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: console
python setup.py sdist --formats=zip (this will produce a .zip file)
cd dist
pip install redfish-x.x.x.zip
python setup.py sdist --formats=zip (this will produce a .zip file)
cd dist
pip install redfish-x.x.x.zip
Requirements
Expand All @@ -63,7 +65,7 @@ For Redfish compliant application:

.. code-block:: python
import redfish
import redfish
Create a Redfish Object
Expand All @@ -75,7 +77,7 @@ To crete a Redfish Object, call the redfish_client method:

.. code-block:: python
REDFISH_OBJ = redfish.redfish_client(base_url=login_host, username=login_account, \
REDFISH_OBJ = redfish.redfish_client(base_url=login_host, username=login_account, \
password=login_password, default_prefix='/redfish/v1')
Expand All @@ -86,7 +88,7 @@ The login operation is performed when creating the REDFISH_OBJ. You can continue

.. code-block:: python
REDFISH_OBJ.login(auth="session")
REDFISH_OBJ.login(auth="session")
Perform a GET operation
Expand All @@ -97,7 +99,7 @@ An example of rawget operation on the path "/redfish/v1/systems/1" is shown belo

.. code-block:: python
response = REDFISH_OBJ.get("/redfish/v1/systems/1", None)
response = REDFISH_OBJ.get("/redfish/v1/systems/1", None)
Perform a POST operation
Expand All @@ -108,8 +110,8 @@ An example of a POST operation on the path "/redfish/v1/systems/1/Actions/Comput

.. code-block:: python
body = {"ResetType": "GracefulShutdown"}
response = REDFISH_OBJ.post("/redfish/v1/systems/1/Actions/ComputerSystem.Reset", body=body)
body = {"ResetType": "GracefulShutdown"}
response = REDFISH_OBJ.post("/redfish/v1/systems/1/Actions/ComputerSystem.Reset", body=body)
Working with Tasks
Expand All @@ -121,8 +123,8 @@ An example of a POST operation with a possible Task is shown below.

.. code-block:: python
body = {"ResetType": "GracefulShutdown"}
response = REDFISH_OBJ.post("/redfish/v1/systems/1/Actions/ComputerSystem.Reset", body=body)
body = {"ResetType": "GracefulShutdown"}
response = REDFISH_OBJ.post("/redfish/v1/systems/1/Actions/ComputerSystem.Reset", body=body)
if(response.is_processing):
task = response.monitor(context)
Expand All @@ -140,7 +142,7 @@ Make sure you logout every session you create as it will remain alive until it t

.. code-block:: python
REDFISH_OBJ.logout()
REDFISH_OBJ.logout()
A logout deletes the current sesssion from the system. The redfish_client object destructor includes a logout statement.
Expand Down Expand Up @@ -168,16 +170,18 @@ Contributing
Release Process
---------------

1. Update `CHANGELOG.md` with the list of changes since the last release
2. Update the ``__version__`` variable in ``src/redfish/__init__.py``, and ``setup.py`` to reflect the new library version
3. Push changes to Github
4. Create a new release in Github
5. Push the new library version to pypi.org: ``python setup.py sdist && twine upload dist/*``
Run the `release.sh` script to publish a new version.

.. code-block:: shell
sh release.sh <NewVersion>
Enter the release notes when prompted; an empty line signifies no more notes to add.

Copyright and License
---------------------

Copyright Notice:
Copyright 2016-2019 DMTF. All rights reserved.
Copyright 2016-2021 DMTF. All rights reserved.
License: BSD 3-Clause License. For full text see link: `https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md <https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md>`_
5 changes: 3 additions & 2 deletions examples/context_manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md
# Copyright 2016-2021 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link:
# https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md

import sys
import redfish
Expand Down
5 changes: 3 additions & 2 deletions examples/discover.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md
# Copyright 2016-2021 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link:
# https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md

import redfish

Expand Down
7 changes: 4 additions & 3 deletions examples/quickstart.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md
# Copyright 2016-2021 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link:
# https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md

import sys
import redfish
Expand All @@ -12,7 +13,7 @@
login_password = "password"

## Create a REDFISH object
REDFISH_OBJ = redfish.redfish_client(base_url=login_host, username=login_account, \
REDFISH_OBJ = redfish.redfish_client(base_url=login_host, username=login_account,
password=login_password, default_prefix='/redfish/v1')

# Login into the server and create a session
Expand Down
7 changes: 4 additions & 3 deletions examples/quickstart_rmc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md
# Copyright 2016-2021 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link:
# https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md

import os
import sys
Expand All @@ -10,7 +11,7 @@
from redfish import redfish_logger
from redfish.ris import RmcApp, JSONEncoder

#Config logger used by Restful library
# Config logger used by Restful library
LOGGERFILE = "RedfishApiExamples.log"
LOGGERFORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
LOGGER = redfish_logger(LOGGERFILE, LOGGERFORMAT, logging.ERROR)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jsonpatch<=1.24 ; python_version == '3.4'
jsonpatch ; python_version >= '3.5' or python_version == '2.7'
jsonpatch ; python_version >= '3.5'
jsonpath_rw
jsonpointer
11 changes: 8 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Copyright Notice:
# Copyright 2016-2021 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link:
# https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md

from setuptools import setup, find_packages
from codecs import open
from os import path
Expand All @@ -14,9 +19,9 @@
author = 'DMTF, https://www.dmtf.org/standards/feedback',
license='BSD 3-clause "New" or "Revised License"',
classifiers=[
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Communications'
],
keywords='Redfish',
Expand All @@ -31,7 +36,7 @@
':python_version == "3.4"': [
'jsonpatch<=1.24'
],
':python_version >= "3.5" or python_version == "2.7"': [
':python_version >= "3.5"': [
'jsonpatch'
]
})
7 changes: 4 additions & 3 deletions src/redfish/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md
# Copyright 2016-2021 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link:
# https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md

""" Redfish restful library """

__all__ = ['rest', 'ris', 'discovery']
__version__ = "2.2.0"
__version__ = "2.2.0"

from redfish.rest.v1 import redfish_client
from redfish.rest.v1 import AuthMethod
Expand Down
2 changes: 1 addition & 1 deletion src/redfish/discovery/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# Copyright 2016-2021 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link:
# https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md
9 changes: 5 additions & 4 deletions src/redfish/discovery/discovery.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# Copyright 2016-2021 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link:
# https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md

# -*- coding: utf-8 -*-
"""Discovers Redfish services"""

import http.client
import re
import socket

from six import BytesIO
from six.moves import http_client
from io import BytesIO


class FakeSocket:
Expand All @@ -26,6 +26,7 @@ def makefile(self, *args, **kwargs):
def sanitize(number, minimum, maximum=None):
""" Sanity check a given number.
:param number: the number to check
:param minimum: the minimum acceptable number
:param maximum: the maximum acceptable number (optional)
Expand Down Expand Up @@ -101,7 +102,7 @@ def discover_ssdp(port=1900, ttl=2, response_time=3, iface=None, protocol="ipv4"
"^uuid:([a-f0-9\-]*)::urn:dmtf-org:service:redfish-rest:1(:\d)?$") # noqa
while True:
try:
response = http_client.HTTPResponse(FakeSocket(sock.recv(1024)))
response = http.client.HTTPResponse(FakeSocket(sock.recv(1024)))
response.begin()
uuid_search = pattern.search(response.getheader("USN").lower())
if uuid_search:
Expand Down
5 changes: 3 additions & 2 deletions src/redfish/rest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md
# Copyright 2016-2021 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link:
# https://github.com/DMTF/python-redfish-library/blob/master/LICENSE.md

""" Utilities to simplify interaction with Redfish data """
Loading

0 comments on commit 0040081

Please sign in to comment.