Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed reference to python2 #262

Merged
merged 5 commits into from
May 26, 2023

Conversation

chieto-arista
Copy link
Contributor

Removed a reference to support for python2 and < python3.7

pyeapi/client.py Outdated
from ConfigParser import SafeConfigParser
from ConfigParser import Error as SafeConfigParserError
# Throw incompatible version error
print("A supported version of configParser is missing. Please upgrade to a higher version that is supported by Python 3.7 or higher.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look, you print here an error and let parsing of the module continue. In 99.99% case nothing terribly wrong would happen (it would end up throwing another exception), but it might have side effects. A bit better handling would be re-raising the exception, but then printing an error does not make much sense - python tracebacks are typically very sufficient. Thus, the best handling (here and in other places) - just remove the try/except block and let python throw an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Better to remove it as we don't need the fallback at all

@@ -250,7 +250,7 @@ def connect(self):

Redefined/copied and extended from httplib.py:1105 (Python 2.6.x).
This is needed to pass cert_reqs=ssl.CERT_REQUIRED as parameter
to ssl.wrap_socket(), which forces SSL to check server certificate
to ssl.wrap_socket()(Now changed to ssl.SSLContext.wrap_socket() as the former has been deprecated from python 3.7), which forces SSL to check server certificate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you break the formatting and coding style here. flake might complain and doc building might have too. Please adjust accordingly. Also, be accurate with spaces, as it all goes into the official documentation

# Use Python 2.7 import as a fallback
from httplib import HTTPConnection, HTTPSConnection
from Cookie import SimpleCookie
# Throw incompatible version error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -259,11 +259,11 @@ def connect(self):
self._tunnel()
# If there's no CA File, don't force Server Certificate Check
if self.ca_file:
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file,
self.sock = ssl.SSLContext.wrap_socket(sock, self.key_file, self.cert_file,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, however it now breaks the formatting rules (the line extends past allowed column size), needs some adjustment

@@ -309,8 +309,7 @@ def authentication(self, username, password):
_auth_bin = base64.encodebytes(_auth_text.encode())
_auth = _auth_bin.decode()
else:
# For Python 2.7
_auth = str(base64.encodestring(_auth_text))
raise Exception("Incompatible python version.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handling is also superfluous now - because it's all will be guarded by import exception (i.e. if python 2 is used), so again, the try blocks has to go.

response = self.transport.getresponse()
except TypeError: #For < Python3.x
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

pyeapi/utils.py Outdated
@@ -43,8 +43,8 @@
# Try Python 3.x import first
from itertools import zip_longest
except ImportError:
# Use Python 2.7 import as a fallback
from itertools import izip_longest as zip_longest
# Throw incompatible version error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here.

@dlyssenko dlyssenko merged commit bf9976f into arista-eosplus:develop May 26, 2023
dlyssenko added a commit that referenced this pull request Jun 6, 2023
* Try importing ujson and rapidjson before json

ujson and rapidjson are libraries that are
faster to encode and decode JSON objects

* Implement configure_session() to send "configure session", diff() for "show session-config diff", commit() for "commit", and abort() for "abort"

* Bump version

* Fix issue #186, fix typo in client.py

* Amend tests for #186

* Amend remove vlan to vni mapping CLI

* Add config session documentation

* Add config session documentation

* Remove config session doc from wrong dir

* adding streaming option for commands

* Correct typo "mutlicast"

* Adding Power support(ppc64le)with continuous integration/testing to the project for architecture independent

* Inorrect import from 'collections' will stop working in Python 3.9

Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
Solving

* Fix python2 dependancy on collections

* Bump Python version to 3.9 for CI

* Fix #189 #190 #195

* Bump version to rc

* fixed issue #198

* #197 - updated vlans.getall() to handle vlan grouppings

* updated vlans.get() to return range/list of vlan ids (instead of input regex), plus updated relevant unit tests

* fixed import warning in abstract module

* updated documentation to avoid using localhost for off-box connections

* Refactor deprecated unittest aliases for Python 3.11 compatibility.

* Update configfile.rst

* fix for the issue #213

* Ignore subinterfaces on switchports.getall()

Signed-off-by: DavidVentura <[email protected]>

* Stop on whitespace

* extended config for unit testing issue #213

* Add a test

* Add new value from #213

* merge tests

* address perf issues on section splitting

* fix bad test

* Add option to not include defaults with node.running_config

Currently, the Node(conn).running_config always includes config defaults, this is not always wanted.
For example if you want to compare the running_config to the startup_config, it is easier to not have defaults included in the running_config.

With this option you can do something like this;
```
In [3]: conn = client.connect(**params)

In [4]: node = client.Node(conn, config_defaults=False)

In [5]: node.running_config.splitlines()[3:] == node.startup_config.splitlines()[4:]
Out[5]: True
```

* updated client descritpion to reflect issue #222

* mitor fix in the description for reST markdown

* another minor update for client.connect description

* Add support for passwords that cannot be used to login

* added sphinx_rtd_theme to dev-requrements.txt

* docs: fixing #231

* fixing collection.Iterables in test_utils.py for py3.10

* fixing collection.Iterables in test_utils.py for py3.10 - minor improvement

* fix for issue #234 - allow passing ssl context to pyeapi

* minor markdown fix in client module description

* fix passwd exposure in traceback issue

* fixed issue where sphinx failed to generate API modules doc, plus made it python3 ready

* readying pyeapi for github actions + minor style fixes

* Migrate from Travis CI to GitHub workflows

* extended python-version list for CI with 2.7 and 3.10

* removed password from showing in debugs

* added pep8 E128 to ignore list - to adopt to Arista coding style

* fixed my update to accomodate to unit tests and possibly invalid jsons

* minor typo fixes in comments

* one more minor typo fix in comments

* Update ci.yml

self approving - trivial change

* Update test_client.py

self-approved - this is non-functional, only syntactic change to keep flake8 happy

* Update eapilib.py

self-approving: non-functional, only syntactic changes to keep flake8 happier.

* Update ci.yml

adding flake8 upgrade, as it crashes in some python versions

* fix for issue #210 - getall() fails in ipinterfaces module

* fix for issue #193 - flood list for vxlan in interfaces returns wrong data

* enhanced `section` to match subsections and removed py2.7 from CI

* minor syntax change to keep flake8 happy

* added a doc string and dressed up the function, no functional change

* few more space adjustments to please flake8

* Store and pass credentials as header tuple

* Support session-based authorization

Create a Session API mixin for Http and Https connection methods that
uses the /login endpoint to store a Cookie for all future connections.
This is useful when using centralized AAA to reduce the load of repeated
command calls.

Note that the cookie does have a lifetime, and that the connection will
stop working once the cookie lifetime expires, unless the authentication
method is manually called again

* provisioning for providing CLI variants to handle deprecated cli transitions

* moved cli varinats functionality to clint.py module so that users could use it too

* fixed issue raising the exception properly for the last failed command

* fixed again raising the exception properly for the last failed command

* updated documentation

* space adjustment in the docstring

* provided comments on enforce_verification param deprecation

* removed python 3.5 and 3.6 from the workflows - unsupported

* fix issue #161 - add parsing of secondary ip from interfaces

* making flake8 happy

* Include error message in CommandError for commands that cause internal exceptions

* _parse_bgp_as regex to match as and asdot

* Checking if asn is asdot or not, and return string if asdot and int if not

* typo

* testing dumb shit

* dumby dumb dumb

* dafuq am i doing

* maybe just maybe

* i hate this shit i just wanna do neworking again :(

* lemme be a network engineer again please i wanna die

* play stupid games win stupid prices

* var typo

* testing

* testing suggested changes

* intendation error

* Update ipinterfaces.py

Replace IP MTU magic numbers with constants and provide references to RFCs

* Update ipinterfaces.py

* fixing doc build issues, errors, and providing docstring interpolation decorator

* fixing indents

* moved decorator's descriptin into the doc string

* removed deprecated spanningtree module

* removed all outdated python version checks

* minor improvement for docstr decorator

* Removed reference to python2 (#262)

* Removed reference to python2

* Removed support for lower versions of python

* Updated EOS version to the minimum supported

* Addressed formatting and error handling comments

* Refactored extra python2 check

* removed couple deprecations

* removed one more deprecation

* Created release-notes-1.0.0.rst

* Updated release-notes.rst

* Update VERSION

* Update __init__.py

* Update release-notes-1.0.0.rst

fixed a capital letter.

---------

Signed-off-by: DavidVentura <[email protected]>
Co-authored-by: Xavier Hardy <[email protected]>
Co-authored-by: Shintaro Kojima <[email protected]>
Co-authored-by: andriirr <[email protected]>
Co-authored-by: Andrii Rykhlivskyi <[email protected]>
Co-authored-by: mharista <[email protected]>
Co-authored-by: Bharath Ravindranath <[email protected]>
Co-authored-by: Will Hargrave <[email protected]>
Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Petr Klíma <[email protected]>
Co-authored-by: Dmitry Lyssenko <[email protected]>
Co-authored-by: Dmitry Lyssenko <[email protected]>
Co-authored-by: Karthikeyan Singaravelan <[email protected]>
Co-authored-by: DavidVentura <[email protected]>
Co-authored-by: erikl <[email protected]>
Co-authored-by: Jeremiah Millay <[email protected]>
Co-authored-by: steve ulrich <[email protected]>
Co-authored-by: Alarig Le Lay <[email protected]>
Co-authored-by: Stefano Rivera <[email protected]>
Co-authored-by: Brandon Ewing <[email protected]>
Co-authored-by: Dylan Kaplan <[email protected]>
Co-authored-by: bh-rr <[email protected]>
Co-authored-by: Greg Skinner <[email protected]>
Co-authored-by: chieto-arista <[email protected]>
@dlyssenko dlyssenko mentioned this pull request Jun 6, 2023
dlyssenko added a commit that referenced this pull request Jun 6, 2023
* Try importing ujson and rapidjson before json

ujson and rapidjson are libraries that are
faster to encode and decode JSON objects

* Implement configure_session() to send "configure session", diff() for "show session-config diff", commit() for "commit", and abort() for "abort"

* Bump version

* Fix issue #186, fix typo in client.py

* Amend tests for #186

* Amend remove vlan to vni mapping CLI

* Add config session documentation

* Add config session documentation

* Remove config session doc from wrong dir

* adding streaming option for commands

* Correct typo "mutlicast"

* Adding Power support(ppc64le)with continuous integration/testing to the project for architecture independent

* Inorrect import from 'collections' will stop working in Python 3.9

Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
Solving

* Fix python2 dependancy on collections

* Bump Python version to 3.9 for CI

* Fix #189 #190 #195

* Bump version to rc

* fixed issue #198

* #197 - updated vlans.getall() to handle vlan grouppings

* updated vlans.get() to return range/list of vlan ids (instead of input regex), plus updated relevant unit tests

* fixed import warning in abstract module

* updated documentation to avoid using localhost for off-box connections

* Refactor deprecated unittest aliases for Python 3.11 compatibility.

* Update configfile.rst

* fix for the issue #213

* Ignore subinterfaces on switchports.getall()



* Stop on whitespace

* extended config for unit testing issue #213

* Add a test

* Add new value from #213

* merge tests

* address perf issues on section splitting

* fix bad test

* Add option to not include defaults with node.running_config

Currently, the Node(conn).running_config always includes config defaults, this is not always wanted.
For example if you want to compare the running_config to the startup_config, it is easier to not have defaults included in the running_config.

With this option you can do something like this;
```
In [3]: conn = client.connect(**params)

In [4]: node = client.Node(conn, config_defaults=False)

In [5]: node.running_config.splitlines()[3:] == node.startup_config.splitlines()[4:]
Out[5]: True
```

* updated client descritpion to reflect issue #222

* mitor fix in the description for reST markdown

* another minor update for client.connect description

* Add support for passwords that cannot be used to login

* added sphinx_rtd_theme to dev-requrements.txt

* docs: fixing #231

* fixing collection.Iterables in test_utils.py for py3.10

* fixing collection.Iterables in test_utils.py for py3.10 - minor improvement

* fix for issue #234 - allow passing ssl context to pyeapi

* minor markdown fix in client module description

* fix passwd exposure in traceback issue

* fixed issue where sphinx failed to generate API modules doc, plus made it python3 ready

* readying pyeapi for github actions + minor style fixes

* Migrate from Travis CI to GitHub workflows

* extended python-version list for CI with 2.7 and 3.10

* removed password from showing in debugs

* added pep8 E128 to ignore list - to adopt to Arista coding style

* fixed my update to accomodate to unit tests and possibly invalid jsons

* minor typo fixes in comments

* one more minor typo fix in comments

* Update ci.yml

self approving - trivial change

* Update test_client.py

self-approved - this is non-functional, only syntactic change to keep flake8 happy

* Update eapilib.py

self-approving: non-functional, only syntactic changes to keep flake8 happier.

* Update ci.yml

adding flake8 upgrade, as it crashes in some python versions

* fix for issue #210 - getall() fails in ipinterfaces module

* fix for issue #193 - flood list for vxlan in interfaces returns wrong data

* enhanced `section` to match subsections and removed py2.7 from CI

* minor syntax change to keep flake8 happy

* added a doc string and dressed up the function, no functional change

* few more space adjustments to please flake8

* Store and pass credentials as header tuple

* Support session-based authorization

Create a Session API mixin for Http and Https connection methods that
uses the /login endpoint to store a Cookie for all future connections.
This is useful when using centralized AAA to reduce the load of repeated
command calls.

Note that the cookie does have a lifetime, and that the connection will
stop working once the cookie lifetime expires, unless the authentication
method is manually called again

* provisioning for providing CLI variants to handle deprecated cli transitions

* moved cli varinats functionality to clint.py module so that users could use it too

* fixed issue raising the exception properly for the last failed command

* fixed again raising the exception properly for the last failed command

* updated documentation

* space adjustment in the docstring

* provided comments on enforce_verification param deprecation

* removed python 3.5 and 3.6 from the workflows - unsupported

* fix issue #161 - add parsing of secondary ip from interfaces

* making flake8 happy

* Include error message in CommandError for commands that cause internal exceptions

* _parse_bgp_as regex to match as and asdot

* Checking if asn is asdot or not, and return string if asdot and int if not

* typo

* testing dumb shit

* dumby dumb dumb

* dafuq am i doing

* maybe just maybe

* i hate this shit i just wanna do neworking again :(

* lemme be a network engineer again please i wanna die

* play stupid games win stupid prices

* var typo

* testing

* testing suggested changes

* intendation error

* Update ipinterfaces.py

Replace IP MTU magic numbers with constants and provide references to RFCs

* Update ipinterfaces.py

* fixing doc build issues, errors, and providing docstring interpolation decorator

* fixing indents

* moved decorator's descriptin into the doc string

* removed deprecated spanningtree module

* removed all outdated python version checks

* minor improvement for docstr decorator

* Removed reference to python2 (#262)

* Removed reference to python2

* Removed support for lower versions of python

* Updated EOS version to the minimum supported

* Addressed formatting and error handling comments

* Refactored extra python2 check

* removed couple deprecations

* removed one more deprecation

* Created release-notes-1.0.0.rst

* Updated release-notes.rst

* Update VERSION

* Update __init__.py

* Update release-notes-1.0.0.rst

fixed a capital letter.

---------

Signed-off-by: DavidVentura <[email protected]>
Co-authored-by: Xavier Hardy <[email protected]>
Co-authored-by: Shintaro Kojima <[email protected]>
Co-authored-by: andriirr <[email protected]>
Co-authored-by: Andrii Rykhlivskyi <[email protected]>
Co-authored-by: mharista <[email protected]>
Co-authored-by: Bharath Ravindranath <[email protected]>
Co-authored-by: Will Hargrave <[email protected]>
Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Petr Klíma <[email protected]>
Co-authored-by: Dmitry Lyssenko <[email protected]>
Co-authored-by: Dmitry Lyssenko <[email protected]>
Co-authored-by: Karthikeyan Singaravelan <[email protected]>
Co-authored-by: DavidVentura <[email protected]>
Co-authored-by: erikl <[email protected]>
Co-authored-by: Jeremiah Millay <[email protected]>
Co-authored-by: steve ulrich <[email protected]>
Co-authored-by: Alarig Le Lay <[email protected]>
Co-authored-by: Stefano Rivera <[email protected]>
Co-authored-by: Brandon Ewing <[email protected]>
Co-authored-by: Dylan Kaplan <[email protected]>
Co-authored-by: bh-rr <[email protected]>
Co-authored-by: Greg Skinner <[email protected]>
Co-authored-by: chieto-arista <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants