From 7f66ff3e6bbb43cd7864b75cd6c0909bd471f914 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Fri, 1 Apr 2022 16:47:59 +0200 Subject: [PATCH] Little fixes found during cnfvar-api-Review --- make_dist.py | 12 ++++++------ setup.py | 2 +- src/cnfvar_old.py | 4 +++- src/dial.py | 8 +++++--- src/text_helpers.py | 4 +++- test/test_arnied_wrapper.py | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/make_dist.py b/make_dist.py index 849e6f5..a505124 100755 --- a/make_dist.py +++ b/make_dist.py @@ -3,7 +3,7 @@ """ Create source tarball, create rpm from it together with spec file. -Create a source tarball that is compatbile with standard build pipelines. Then +Create a source tarball that is compatible with standard build pipelines. Then run rpmbuild on it to create an installable rpm. .. codeauthor:: Intra2net AG @@ -28,10 +28,11 @@ SOURCE_REGEX = re_compile(r'^Source0:\s*(\S+)\s*$') # dir to contain tarball DIST_DIR = join(BASE_DIR, 'dist') -# files and dirs to add to tarball; keep in sync with %files secion in spec +# files and dirs to add to tarball; keep in sync with %files section in spec DATA = ( 'COPYING.GPL', 'Linking-Exception.txt', 'README', 'CONTRIBUTING', - 'setup.py', 'src', 'test', 'doc/about_docu.rst', 'doc/conf.py' + 'setup.py', 'src', 'test', 'doc/about_docu.rst', 'doc/conf.py', + 'doc/cnfvar-api-ascii-art.rst' ) # dir where rpmbuild expects its tarballs @@ -85,10 +86,10 @@ def create_tarball(): name, version, tarball_file = get_spec_info() tarball_path = join(DIST_DIR, tarball_file) print(f'Creating {tarball_path}') - dirname = f'{name}-{version}' + dir_name = f'{name}-{version}' with tarfile.open(tarball_path, 'w:gz') as tarball: for entry in DATA: - tarball.add(entry, join(dirname, entry), filter=tar_add_filter) + tarball.add(entry, join(dir_name, entry), filter=tar_add_filter) return tarball_path @@ -113,4 +114,3 @@ def main(): if __name__ == '__main__': sys.exit(main()) - diff --git a/setup.py b/setup.py index 0a9293e..a9eeae9 100644 --- a/setup.py +++ b/setup.py @@ -41,4 +41,4 @@ setup(name='pyi2ncommon', "Programming Language :: Python :: 3", "Operating System :: OS Independent", ], - ) + ) diff --git a/src/cnfvar_old.py b/src/cnfvar_old.py index e4c46d3..29b7629 100644 --- a/src/cnfvar_old.py +++ b/src/cnfvar_old.py @@ -451,7 +451,8 @@ def read_cnf(data): """ Read cnf data from data bytes. - :param bytes data: raw data + :param data: raw data + :type data: str or bytes :return: the parsed cnf data :rtype: {str, {str, str or int}} """ @@ -1164,5 +1165,6 @@ def main(argv): usage() return -1 + if __name__ == "__main__": sys.exit(main(sys.argv)) diff --git a/src/dial.py b/src/dial.py index e34921a..30e930e 100644 --- a/src/dial.py +++ b/src/dial.py @@ -79,8 +79,6 @@ __all__ = ( "arnied_dial_hangup", "arnied_dial_doc", "arnied_dial_permanent", "dialout", "get_wan_address", "DIALOUT_MODE_PERMANENT", "DIALOUT_MODE_MANUAL", "DIALOUT_MODE_DEFAULT", "DIALOUT_MODE_BY_NAME" ) -TELL_CONND_BIN = "/usr/intranator/bin/tell-connd" - DIALOUT_MODE_PERMANENT = 0 DIALOUT_MODE_MANUAL = 1 DIALOUT_MODE_DEFAULT = DIALOUT_MODE_PERMANENT @@ -93,8 +91,12 @@ NEEDLE_MEMO = " \[%s\] :(.*connected online fsm.*)" NEEDLE_OFFLINE = re.compile("connection map:\nend of connection map") DIALTOOLS_HANGUP_BIN = "/usr/intranator/bin/hangup" + +#: binary for manual dialing (dial on command) DIALTOOLS_DOC_BIN = "/usr/intranator/bin/doc" DIALTOOLS_TIMEOUT = 10 # s + +#: client binary for talking to connd TELL_CONND_BIN = "/usr/intranator/bin/tell-connd" @@ -133,7 +135,7 @@ def arnied_dial_hangup(block=False): def arnied_dial_doc(prid="P1", block=False): """ - Bring provider up via arnied manual dial. + Bring provider up via arnied manual dial (dial on command). :param prid: Provider id, default *P1*. It is up to the caller to ensure this is a valid provider id. diff --git a/src/text_helpers.py b/src/text_helpers.py index 45680a8..a258f43 100644 --- a/src/text_helpers.py +++ b/src/text_helpers.py @@ -49,6 +49,7 @@ end-of-color or end-of-style escape sequences instead of 0 (reset-everything). .. seealso:: http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python .. seealso:: https://en.wikipedia.org/wiki/ANSI_escape_code +.. seealso:: :py:mod:`textwrap` INTERFACE @@ -93,7 +94,8 @@ def head_and_tail(iterable, n_head=20, n_tail=20, n_elems=None, :yields: `n_head+n_tail` elements from iterable plus the `skip_elem` (or less if iterable is shorter than this). - .. seealso:: :py:func:`slice`, :py:func:`itertools.islice` + .. seealso:: :py:func:`slice`, :py:func:`itertools.islice`, :py:func:`textwrap.shorten` + """ if n_elems is None: n_elems = len(iterable) diff --git a/test/test_arnied_wrapper.py b/test/test_arnied_wrapper.py index bce22a8..da6ddb0 100755 --- a/test/test_arnied_wrapper.py +++ b/test/test_arnied_wrapper.py @@ -27,7 +27,7 @@ import subprocess from src import arnied_wrapper -class DummyCmdOutputMapping(object): +class DummyCmdOutputMapping: """ Class to replace the :py:function:`arnied_wrapper.run_cmd` function. -- 1.7.1