SCAutolib 3.3.3__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 (58) hide show
  1. {scautolib-3.3.3/SCAutolib.egg-info → scautolib-3.4.9}/PKG-INFO +13 -2
  2. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib/__init__.py +67 -35
  3. scautolib-3.4.9/SCAutolib/cli_commands.py +614 -0
  4. scautolib-3.4.9/SCAutolib/controller.py +789 -0
  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.3.3 → scautolib-3.4.9}/SCAutolib/models/file.py +334 -124
  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.3.3 → scautolib-3.4.9/SCAutolib.egg-info}/PKG-INFO +13 -2
  17. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib.egg-info/SOURCES.txt +0 -1
  18. {scautolib-3.3.3 → scautolib-3.4.9}/setup.py +1 -1
  19. {scautolib-3.3.3 → scautolib-3.4.9}/test/test_file.py +3 -2
  20. {scautolib-3.3.3 → scautolib-3.4.9}/test/test_sssd_conf.py +2 -1
  21. {scautolib-3.3.3 → scautolib-3.4.9}/test/test_utils.py +2 -1
  22. scautolib-3.3.3/SCAutolib/cli_commands.py +0 -171
  23. scautolib-3.3.3/SCAutolib/controller.py +0 -584
  24. scautolib-3.3.3/SCAutolib/enums.py +0 -42
  25. scautolib-3.3.3/SCAutolib/exceptions.py +0 -34
  26. scautolib-3.3.3/SCAutolib/isDistro.py +0 -50
  27. scautolib-3.3.3/SCAutolib/models/CA.py +0 -767
  28. scautolib-3.3.3/SCAutolib/models/__init__.py +0 -3
  29. scautolib-3.3.3/SCAutolib/models/authselect.py +0 -89
  30. scautolib-3.3.3/SCAutolib/models/card.py +0 -463
  31. scautolib-3.3.3/SCAutolib/models/gui.py +0 -495
  32. scautolib-3.3.3/SCAutolib/models/log.py +0 -46
  33. scautolib-3.3.3/SCAutolib/models/user.py +0 -182
  34. scautolib-3.3.3/SCAutolib/utils.py +0 -211
  35. {scautolib-3.3.3 → scautolib-3.4.9}/LICENSE +0 -0
  36. {scautolib-3.3.3 → scautolib-3.4.9}/MANIFEST.in +0 -0
  37. {scautolib-3.3.3 → scautolib-3.4.9}/README.md +0 -0
  38. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib/templates/ca.cnf +0 -0
  39. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib/templates/gnome_disable_welcome +0 -0
  40. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib/templates/softhsm2.conf +0 -0
  41. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib/templates/sssd.conf-10 +0 -0
  42. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib/templates/sssd.conf-8or9 +0 -0
  43. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib/templates/user.cnf +0 -0
  44. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib/templates/virt_cacard.service +0 -0
  45. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib/templates/virtcacard.cil +0 -0
  46. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib.egg-info/dependency_links.txt +0 -0
  47. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib.egg-info/entry_points.txt +0 -0
  48. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib.egg-info/requires.txt +0 -0
  49. {scautolib-3.3.3 → scautolib-3.4.9}/SCAutolib.egg-info/top_level.txt +0 -0
  50. {scautolib-3.3.3 → scautolib-3.4.9}/requirements.txt +0 -0
  51. {scautolib-3.3.3 → scautolib-3.4.9}/setup.cfg +0 -0
  52. {scautolib-3.3.3 → scautolib-3.4.9}/test/test_ca.py +0 -0
  53. {scautolib-3.3.3 → scautolib-3.4.9}/test/test_card.py +0 -0
  54. {scautolib-3.3.3 → scautolib-3.4.9}/test/test_cli.py +0 -0
  55. {scautolib-3.3.3 → scautolib-3.4.9}/test/test_controller.py +0 -0
  56. {scautolib-3.3.3 → scautolib-3.4.9}/test/test_openssl_conf.py +0 -0
  57. {scautolib-3.3.3 → scautolib-3.4.9}/test/test_user.py +0 -0
  58. {scautolib-3.3.3 → scautolib-3.4.9}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: SCAutolib
3
- Version: 3.3.3
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
@@ -32,6 +32,17 @@ Requires-Dist: pandas; extra == "graphical"
32
32
  Requires-Dist: numpy; extra == "graphical"
33
33
  Requires-Dist: pytesseract; extra == "graphical"
34
34
  Requires-Dist: keyboard; extra == "graphical"
35
+ Dynamic: author
36
+ Dynamic: author-email
37
+ Dynamic: classifier
38
+ Dynamic: description
39
+ Dynamic: description-content-type
40
+ Dynamic: home-page
41
+ Dynamic: license-file
42
+ Dynamic: provides-extra
43
+ Dynamic: requires-dist
44
+ Dynamic: requires-python
45
+ Dynamic: summary
35
46
 
36
47
  # Smart Card Automation library (SCAutolib)
37
48
  Test automation library for Smart Cards.
@@ -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
@@ -7,10 +27,12 @@ from schema import Schema, Use, Or, And, Optional
7
27
 
8
28
  from SCAutolib.enums import CardType, UserType
9
29
 
10
- fmt = "%(name)s:%(module)s.%(funcName)s.%(lineno)d [%(levelname)s] %(message)s"
30
+ fmt = ("%(asctime)s %(name)s:%(module)s.%(funcName)s.%(lineno)d "
31
+ "[%(levelname)s] %(message)s")
11
32
  date_fmt = "%H:%M:%S"
12
33
  coloredlogs.install(level="DEBUG", fmt=fmt, datefmt=date_fmt,
13
- field_styles={'levelname': {'bold': True, 'color': 'blue'}})
34
+ field_styles={'levelname': {'bold': True, 'color': 'blue'},
35
+ 'asctime': {'color': 'green'}})
14
36
  logger = logging.getLogger(__name__)
15
37
  # Disable logs from imported packages
16
38
  logging.getLogger("paramiko").setLevel(logging.WARNING)
@@ -69,44 +91,54 @@ schema_card = Schema({'name': Use(str),
69
91
  Optional('key', default=None): Use(str)})
70
92
 
71
93
 
72
- def run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True,
73
- 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) \
74
97
  -> subprocess.CompletedProcess:
75
98
  """
76
- Wrapper for subrpocess.run function. This function explicitly set several
77
- parameter of original function and also provides similar thing as
78
- subprocess.check_output do. But with having this wrapper, functionality
79
- of this two functions is generalized and can be changed by setting
80
- corresponding parameters. If there are any specific parameter of
81
- subprocess.run function needed to be passed to this wrapper, you can do
82
- it by adding same parameters names in key=value format.
83
-
84
- :param sleep: time to sleep after command is executed
85
- :type sleep: int
86
- :param return_code: acceptable return codes from given commands.
87
- If check=True, and the return code of the cmd is not in the return_code
88
- list a subprocess.CalledProcessError exception would be raised.
89
- :type return_code: list
90
- :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.
91
107
  :type cmd: list or str
92
- :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.
93
112
  :type stdout: None or int or IO
94
- :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.
95
117
  :type stderr: None or int or IO
96
- :param check: Specifies it return code of the command would be checked for
97
- 0 (if return code == 0). If True and return code is not 0, then
98
- subprocess.CalledProcessError exception would be risen. Default is
99
- 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``.
100
122
  :type check: bool
101
- :param print_: Specifies it stdout and stderr should be printed to the
102
- terminal. Log message with stdout would have debug type and stderr
103
- log message would have error type. Default is True.
104
- :type print_: bool
105
- :param kwargs: Other parameters to subprocess.run function
106
-
107
- :exception subprocess.CalledProcessError:
108
-
109
- :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.
110
142
  :rtype: subprocess.CompletedProcess
111
143
  """
112
144
  if return_code is None:
@@ -116,7 +148,7 @@ def run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True,
116
148
  logger.debug(f"run: {' '.join([str(i) for i in cmd])}")
117
149
  out = subprocess.run(cmd, stdout=stdout, stderr=stderr, encoding="utf-8",
118
150
  **kwargs)
119
- if print_:
151
+ if log:
120
152
  if out.stdout != "":
121
153
  logger.debug(out.stdout)
122
154
  if out.stderr != "":