Skip to content

Commit

Permalink
Remove pkg_info.json file and replace it with python file to avoid ac…
Browse files Browse the repository at this point in the history
…cess issue at runtime
  • Loading branch information
t-cas committed Nov 3, 2020
1 parent 6943f96 commit a6d1364
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist: bionic
language: python
cache: pip

Expand All @@ -24,7 +25,6 @@ python:
- 3.6
- 3.7
- 3.8
- pypy
- pypy3

jobs:
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.6.5 (11/03/2020)
------------------
- [Bug] :issue:`152`: Remove pkg_info.json file and replace it with python file to avoid access issue at runtime

1.6.4 (08/24/2020)
------------------
- [Bug] :issue:`109`: Fix automated session closure handled by python garbage collection
Expand Down
11 changes: 5 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import json
import os
import sys

Expand All @@ -25,9 +24,9 @@
sys.path.insert(0, os.path.abspath(ROOT_DIR))

# get package information from config file
config_file_path = os.path.join(ROOT_DIR, 'jumpssh', 'pkg_info.json')
with open(config_file_path) as fp:
_pkg_info = json.load(fp)
_pkg_info = {}
with open(os.path.join(ROOT_DIR, 'jumpssh', '__version__.py')) as version_file:
exec(version_file.read(), _pkg_info)


# -- General configuration ------------------------------------------------
Expand Down Expand Up @@ -61,14 +60,14 @@
# General information about the project.
project = u'jumpssh'
copyright = u'(c) 2017 Amadeus sas'
author = _pkg_info['author']
author = _pkg_info['__author__']

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = _pkg_info['version']
version = _pkg_info['__version__']

# The full version, including alpha/beta/rc tags.
release = version
Expand Down
7 changes: 1 addition & 6 deletions jumpssh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import json
import os
import sys

from jumpssh.__version__ import __version__ # noqa: F401
from jumpssh.exception import SSHException, ConnectionError, RestClientError, RunCmdError, TimeoutError
from jumpssh.session import SSHSession
from jumpssh.restclient import RestSshClient

if sys.version_info < (2, 6):
raise RuntimeError('You need Python 2.6+ for this module.')

# set package version from config file
with open(os.path.join(os.path.dirname(__file__), 'pkg_info.json')) as fp:
_info = json.load(fp)
__version__ = _info['version']

__all__ = ['SSHException',
'ConnectionError',
Expand Down
14 changes: 14 additions & 0 deletions jumpssh/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
__title__ = 'jumpssh'
__description__ = 'Python library for remote ssh calls through a gateway.'
__version__ = '1.6.5'

__author__ = 'Thibaud Castaing'
__author_email__ = 't-cas@users.noreply.github.com'
__maintainer__ = 'Amadeus IT Group',
__maintainer_email__ = 'opensource@amadeus.com'

__url__ = 'https://github.com/AmadeusITGroup/JumpSSH'
__download_url__ = 'https://pypi.python.org/pypi/jumpssh'

__copyright__ = 'Copyright (c) 2017 Amadeus sas'
__license__ = 'MIT license'
4 changes: 0 additions & 4 deletions jumpssh/pkg_info.json

This file was deleted.

3 changes: 3 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ docker==4.3.1
docker-compose==1.27.2;python_version>="3.5"
docker-compose==1.26.2;python_version<"3.5"
pathlib2==2.3.5;python_version<"3.4"

# indirect dependencies
pyrsistent<0.17.0;python_version<"3.5"
34 changes: 19 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
from __future__ import print_function
import json
import os
from setuptools import setup

with open('jumpssh/pkg_info.json') as fp:
_pkg_info = json.load(fp)
ROOT = os.path.dirname(__file__)

with open('README.rst') as readme_file:
# retrieve package information
about = {}
with open(os.path.join(ROOT, 'jumpssh', '__version__.py')) as version_file:
exec(version_file.read(), about)

with open(os.path.join(ROOT, 'README.rst')) as readme_file:
readme = readme_file.read()

setup(
name="jumpssh",
version=_pkg_info['version'],
name=about['__title__'],
version=about['__version__'],

author='Amadeus IT Group',
author_email='opensource@amadeus.com',
maintainer='Thibaud Castaing',
maintainer_email='t-cas@users.noreply.github.com',
author=about['__author__'],
author_email=about['__author_email__'],
maintainer=about['__maintainer__'],
maintainer_email=about['__maintainer_email__'],

description="Python library for remote ssh calls through a gateway.",
description=about['__description__'],
long_description=readme,
url="https://github.com/AmadeusITGroup/JumpSSH",
download_url="https://pypi.python.org/pypi/jumpssh",
license='MIT license',
# long_description_content_type='text/markdown',
url=about['__url__'],
download_url=about['__download_url__'],
license=about['__license__'],
classifiers=[
'Development Status :: 5 - Production/Stable',

Expand Down Expand Up @@ -51,7 +56,6 @@
],

packages=['jumpssh'],
package_data={'': ['pkg_info.json']},
platforms='Unix; MacOS X',

install_requires=[
Expand Down
4 changes: 1 addition & 3 deletions tests/test__session.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from pathlib2 import Path
import os
import socket
import sys
import time

import paramiko
Expand Down Expand Up @@ -261,8 +260,7 @@ def test_run_cmd_retry(docker_env):
assert len(result.result_list) == 4


@pytest.mark.skipif(sys.version_info[0:2] in [(3, 5), (3, 6)],
reason="failing mostly with python 3.5/3.6 and no idea why yet...")
@pytest.mark.flaky
def test_run_cmd_interrupt_remote_command(docker_env, monkeypatch, caplog):
caplog.set_level(logging.DEBUG)
"""Test behavior of run_cmd when user hit Contrl-C while a command is being executed remotely"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_restclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import sys
import tempfile

from flaky import flaky
import pytest

from jumpssh import exception, SSHSession, RestSshClient
Expand All @@ -26,7 +25,7 @@ def docker_compose_file():
yield Path("docker-compose_restclient.yaml")


@flaky
@pytest.mark.flaky
def test_init_from_session(docker_env):
gateway_ip, gateway_port = docker_env.get_host_ip_port('gateway')
gateway_session = SSHSession(host=gateway_ip, port=gateway_port, username='user1', password='password1')
Expand All @@ -38,6 +37,7 @@ def test_init_from_session(docker_env):
assert http_response.text == 'Hello, World!'


@pytest.mark.flaky
def test_init_from_host_ip(docker_env):
gateway_ip, gateway_port = docker_env.get_host_ip_port('gateway')

Expand Down

0 comments on commit a6d1364

Please sign in to comment.