SCAutolib 3.4.0__tar.gz → 3.4.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {scautolib-3.4.0/SCAutolib.egg-info → scautolib-3.4.9}/PKG-INFO +3 -2
  2. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/__init__.py +63 -33
  3. scautolib-3.4.9/SCAutolib/cli_commands.py +614 -0
  4. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/controller.py +311 -123
  5. scautolib-3.4.9/SCAutolib/enums.py +75 -0
  6. scautolib-3.4.9/SCAutolib/exceptions.py +137 -0
  7. scautolib-3.4.9/SCAutolib/models/CA.py +1068 -0
  8. scautolib-3.4.9/SCAutolib/models/__init__.py +9 -0
  9. scautolib-3.4.9/SCAutolib/models/authselect.py +159 -0
  10. scautolib-3.4.9/SCAutolib/models/card.py +687 -0
  11. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/models/file.py +329 -125
  12. scautolib-3.4.9/SCAutolib/models/gui.py +1134 -0
  13. scautolib-3.4.9/SCAutolib/models/log.py +67 -0
  14. scautolib-3.4.9/SCAutolib/models/user.py +274 -0
  15. scautolib-3.4.9/SCAutolib/utils.py +193 -0
  16. {scautolib-3.4.0 → scautolib-3.4.9/SCAutolib.egg-info}/PKG-INFO +3 -2
  17. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/SOURCES.txt +0 -1
  18. {scautolib-3.4.0 → scautolib-3.4.9}/setup.py +1 -1
  19. {scautolib-3.4.0 → scautolib-3.4.9}/test/test_file.py +3 -2
  20. {scautolib-3.4.0 → scautolib-3.4.9}/test/test_sssd_conf.py +2 -1
  21. {scautolib-3.4.0 → scautolib-3.4.9}/test/test_utils.py +2 -1
  22. scautolib-3.4.0/SCAutolib/cli_commands.py +0 -318
  23. scautolib-3.4.0/SCAutolib/enums.py +0 -42
  24. scautolib-3.4.0/SCAutolib/exceptions.py +0 -34
  25. scautolib-3.4.0/SCAutolib/isDistro.py +0 -50
  26. scautolib-3.4.0/SCAutolib/models/CA.py +0 -767
  27. scautolib-3.4.0/SCAutolib/models/__init__.py +0 -3
  28. scautolib-3.4.0/SCAutolib/models/authselect.py +0 -89
  29. scautolib-3.4.0/SCAutolib/models/card.py +0 -463
  30. scautolib-3.4.0/SCAutolib/models/gui.py +0 -534
  31. scautolib-3.4.0/SCAutolib/models/log.py +0 -46
  32. scautolib-3.4.0/SCAutolib/models/user.py +0 -182
  33. scautolib-3.4.0/SCAutolib/utils.py +0 -212
  34. {scautolib-3.4.0 → scautolib-3.4.9}/LICENSE +0 -0
  35. {scautolib-3.4.0 → scautolib-3.4.9}/MANIFEST.in +0 -0
  36. {scautolib-3.4.0 → scautolib-3.4.9}/README.md +0 -0
  37. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/ca.cnf +0 -0
  38. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/gnome_disable_welcome +0 -0
  39. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/softhsm2.conf +0 -0
  40. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/sssd.conf-10 +0 -0
  41. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/sssd.conf-8or9 +0 -0
  42. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/user.cnf +0 -0
  43. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/virt_cacard.service +0 -0
  44. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/virtcacard.cil +0 -0
  45. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/dependency_links.txt +0 -0
  46. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/entry_points.txt +0 -0
  47. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/requires.txt +0 -0
  48. {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/top_level.txt +0 -0
  49. {scautolib-3.4.0 → scautolib-3.4.9}/requirements.txt +0 -0
  50. {scautolib-3.4.0 → scautolib-3.4.9}/setup.cfg +0 -0
  51. {scautolib-3.4.0 → scautolib-3.4.9}/test/test_ca.py +0 -0
  52. {scautolib-3.4.0 → scautolib-3.4.9}/test/test_card.py +0 -0
  53. {scautolib-3.4.0 → scautolib-3.4.9}/test/test_cli.py +0 -0
  54. {scautolib-3.4.0 → scautolib-3.4.9}/test/test_controller.py +0 -0
  55. {scautolib-3.4.0 → scautolib-3.4.9}/test/test_openssl_conf.py +0 -0
  56. {scautolib-3.4.0 → scautolib-3.4.9}/test/test_user.py +0 -0
  57. {scautolib-3.4.0 → scautolib-3.4.9}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: SCAutolib
3
- Version: 3.4.0
3
+ Version: 3.4.9
4
4
  Summary: Python library for automation tests of smart cards using virtualization.
5
5
  Home-page: https://github.com/redhat-qe-security/SCAutolib
6
6
  Author: Pavel Yadlouski
@@ -38,6 +38,7 @@ Dynamic: classifier
38
38
  Dynamic: description
39
39
  Dynamic: description-content-type
40
40
  Dynamic: home-page
41
+ Dynamic: license-file
41
42
  Dynamic: provides-extra
42
43
  Dynamic: requires-dist
43
44
  Dynamic: requires-python
@@ -1,3 +1,23 @@
1
+ """
2
+ This module serves as the initialization point for the SCAutolib package.
3
+
4
+ It sets up the package-wide logging configuration using ``coloredlogs``.
5
+ It defines global constants for directory paths used throughout the library for
6
+ templates, backup files, and data dumps.
7
+
8
+ Additionally, it establishes validation schemas using the ``schema`` library
9
+ for various configuration sections, including CAs (Certificate Authorities),
10
+ users, and smart cards. These schemas ensure that input data conforms to
11
+ expected structures and types, facilitating robust data handling across
12
+ SCAutolib's components.
13
+
14
+ The module also provides a generalized ``run`` function, acting as a wrapper
15
+ for ``subprocess.run``. This wrapper standardizes command execution,
16
+ logging, error checking, and offers options for controlling standard
17
+ output/error, return code validation, and post-execution delays.
18
+ """
19
+
20
+
1
21
  import coloredlogs
2
22
  import logging
3
23
  import subprocess
@@ -71,44 +91,54 @@ schema_card = Schema({'name': Use(str),
71
91
  Optional('key', default=None): Use(str)})
72
92
 
73
93
 
74
- def run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True,
75
- print_=True, return_code: list = None, sleep: int = 0, **kwargs) \
94
+ def run(cmd: list[str], stdout: int = subprocess.PIPE,
95
+ stderr: int = subprocess.PIPE, check: bool = True, log: bool = True,
96
+ return_code: list = None, sleep: int = 0, **kwargs) \
76
97
  -> subprocess.CompletedProcess:
77
98
  """
78
- Wrapper for subrpocess.run function. This function explicitly set several
79
- parameter of original function and also provides similar thing as
80
- subprocess.check_output do. But with having this wrapper, functionality
81
- of this two functions is generalized and can be changed by setting
82
- corresponding parameters. If there are any specific parameter of
83
- subprocess.run function needed to be passed to this wrapper, you can do
84
- it by adding same parameters names in key=value format.
85
-
86
- :param sleep: time to sleep after command is executed
87
- :type sleep: int
88
- :param return_code: acceptable return codes from given commands.
89
- If check=True, and the return code of the cmd is not in the return_code
90
- list a subprocess.CalledProcessError exception would be raised.
91
- :type return_code: list
92
- :param cmd: Command to be executed
99
+ Executes an external command as a subprocess, providing a controlled
100
+ wrapper around ``subprocess.run``. This function
101
+ standardizes command execution, capturing and optionally printing output,
102
+ performing robust error checking based on expected return codes, and
103
+ provides consistent logging of what is being executed.
104
+
105
+ :param cmd: The command to be executed, provided as a list of strings
106
+ (preferred) or a single space-separated string.
93
107
  :type cmd: list or str
94
- :param stdout: Redirection of stdout. Default is subprocess.PIPE
108
+ :param stdout: Redirects the standard output of the command.
109
+ Accepts an int representing a file descriptor, or an
110
+ `IO object <https://docs.python.org/3/library/io.html>`__.
111
+ Defaults to ``subprocess.PIPE`` to capture output.
95
112
  :type stdout: None or int or IO
96
- :param stderr: Redirection of stderr. Default is subprocess.PIPE
113
+ :param stderr: Redirects the standard error of the command.
114
+ Accepts an int representing a file descriptor, or an
115
+ `IO object <https://docs.python.org/3/library/io.html>`__.
116
+ Defaults to ``subprocess.PIPE`` to capture output.
97
117
  :type stderr: None or int or IO
98
- :param check: Specifies it return code of the command would be checked for
99
- 0 (if return code == 0). If True and return code is not 0, then
100
- subprocess.CalledProcessError exception would be risen. Default is
101
- False.
118
+ :param check: If ``True``, the function will raise a
119
+ ``subprocess.CalledProcessError`` exception if the command's
120
+ return code is not in the ``return_code`` list. Defaults to
121
+ ``True``.
102
122
  :type check: bool
103
- :param print_: Specifies it stdout and stderr should be printed to the
104
- terminal. Log message with stdout would have debug type and stderr
105
- log message would have error type. Default is True.
106
- :type print_: bool
107
- :param kwargs: Other parameters to subprocess.run function
108
-
109
- :exception subprocess.CalledProcessError:
110
-
111
- :return: Completed process from subprocess.run
123
+ :param log: If ``True``, the command's standard output will be logged at
124
+ DEBUG level and standard error at WARNING level. Defaults to
125
+ ``True``.
126
+ :type log: bool
127
+ :param return_code: A list of acceptable return codes for the command. If
128
+ ``check`` is ``True`` and the command's return code is
129
+ not in this list, an exception is raised. Defaults to
130
+ ``[0]``.
131
+ :type return_code: list
132
+ :param sleep: The duration in seconds to pause execution after the command
133
+ completes. Defaults to ``0``.
134
+ :type sleep: int
135
+ :param kwargs: Additional keyword arguments are passed directly to the
136
+ ``subprocess.run`` function.
137
+ :raises subprocess.CalledProcessError: If ``check`` is ``True`` and the
138
+ command's return code is not among
139
+ the expected ``return_code`` values.
140
+ :return: An object representing the completed process, including stdout,
141
+ stderr, and return code.
112
142
  :rtype: subprocess.CompletedProcess
113
143
  """
114
144
  if return_code is None:
@@ -118,7 +148,7 @@ def run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True,
118
148
  logger.debug(f"run: {' '.join([str(i) for i in cmd])}")
119
149
  out = subprocess.run(cmd, stdout=stdout, stderr=stderr, encoding="utf-8",
120
150
  **kwargs)
121
- if print_:
151
+ if log:
122
152
  if out.stdout != "":
123
153
  logger.debug(out.stdout)
124
154
  if out.stderr != "":