Skip to content

Restructuring of code to make it modular.#357

Closed
rahkumar651991 wants to merge 16 commits intoJuniper:masterfrom
rahkumar651991:restructure_code
Closed

Restructuring of code to make it modular.#357
rahkumar651991 wants to merge 16 commits intoJuniper:masterfrom
rahkumar651991:restructure_code

Conversation

@rahkumar651991
Copy link
Copy Markdown
Contributor

What does this PR do?

The PR restructure the code to make it modular.

What issues does this PR fix or reference?

#356

sidhujasminder and others added 16 commits June 1, 2018 12:25
* Fixes for issues Juniper#345, Juniper#324, Juniper#325

* Fixed conditions for UT.

* Condition fixed for UT

* Fixes for issues Juniper#345, Juniper#324, Juniper#325 Juniper#347

* Fixes for issues Juniper#345, Juniper#324, Juniper#325

* Fixes for issues Juniper#345, Juniper#324, Juniper#325
* Update setup.py

I've noticed that this setup.py does not work when trying to execute
"pip install jsnapy" from a Python 3.X Virtual environment.

It appears that Python 3.X does not use the sys.real_prefix attribute any more.
I found some documentation here https://stackoverflow.com/questions/1871549/determine-if-python-is-running-inside-virtualenv showing that it is moved to base_prefix.

What i've added will check sys.base_prefix and compare it to sys.prefix, if it doesn't match, than you're in a virtual environment. 

Outside of VirtualEnv;

Gian-Lucas-MacBook-Pro:~ gianluca.casella$ python3.8
Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.base_prefix
'/Library/Frameworks/Python.framework/Versions/3.8'
>>> sys.prefix
'/Library/Frameworks/Python.framework/Versions/3.8'
>>> quit()



Inside VirtualEnv:
Gian-Lucas-MacBook-Pro:~ gianluca.casella$ source venv/bin/activate
(venv) Gian-Lucas-MacBook-Pro:~ gianluca.casella$ python
Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.base_prefix
'/Library/Frameworks/Python.framework/Versions/3.8'
>>> sys.prefix
'/Users/gianluca.casella/venv'

* Update setup.py

Updated typo on 

hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix))

* Update setup.py

Added line 75

* Update __init__.py

Modified line 29 to enable Python 3.X Support in Virtual Environments

* Update test_init.py

Modified line 39 to add Python 3.X Support for Virtual Environments

* Added the venv_check() function to the setup.py and lib/jnpr/jsnapy/__init__.py
* port support added for same Ip-address. Juniper#322

* port support added for same Ip-address. Juniper#322
…Juniper as well as Day-One Book about hardening Junos (Juniper#344)
* Development version to be updated in git repository
@coveralls
Copy link
Copy Markdown

coveralls commented Feb 18, 2020

@rahkumar651991
Copy link
Copy Markdown
Contributor Author

closing this as merge with master created issues.

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.

6 participants