command_watcher 0.2.0__tar.gz → 0.4.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: command-watcher
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: Module to watch the execution of shell scripts. Both streams (`stdout` and `stderr`) are captured.
5
5
  Home-page: https://github.com/Josef-Friedrich/command-watcher
6
6
  License: MIT
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.8
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
- Requires-Dist: conf2levels (>=0.4.0,<0.5.0)
16
+ Requires-Dist: conf2levels (>=0.5.0,<0.6.0)
17
17
  Requires-Dist: icinga2apic (>=0.7.5,<0.8.0)
18
18
  Requires-Dist: termcolor (>=1.1.0,<2.0.0)
19
19
  Requires-Dist: types-requests (>=2.28.1,<3.0.0)
@@ -0,0 +1,26 @@
1
+ """Small utility functions."""
2
+
3
+ import os
4
+ import shutil
5
+ import stat
6
+ import urllib.request
7
+
8
+
9
+ def download(url: str, dest: str) -> None:
10
+ """Download a file and save it under a destination path.
11
+
12
+ :param url: The URL of the file to download.
13
+ :param dest: The path of the destination file.
14
+ """
15
+ with urllib.request.urlopen(url) as response, \
16
+ open(dest, 'wb') as out_file:
17
+ shutil.copyfileobj(response, out_file)
18
+
19
+
20
+ def make_executable(path: str) -> None:
21
+ """Make a file executable.
22
+
23
+ :param path: The path of the file
24
+ """
25
+ st = os.stat(path)
26
+ os.chmod(path, st.st_mode | stat.S_IEXEC)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "command_watcher"
3
- version = "0.2.0"
3
+ version = "0.4.0"
4
4
  description = "Module to watch the execution of shell scripts. Both streams (`stdout` and `stderr`) are captured."
5
5
  authors = ["Josef Friedrich <josef@friedrich.rocks>"]
6
6
  license = "MIT"
@@ -13,7 +13,7 @@ classifiers = [
13
13
 
14
14
  [tool.poetry.dependencies]
15
15
  python = "^3.8"
16
- conf2levels = "^0.4.0"
16
+ conf2levels = "^0.5.0"
17
17
  icinga2apic = "^0.7.5"
18
18
  termcolor = "^1.1.0"
19
19
  types-requests = "^2.28.1"
@@ -22,6 +22,7 @@ types-termcolor = "^1.1.5"
22
22
  [tool.poetry.group.dev.dependencies]
23
23
  tox = "^3.25.1"
24
24
  autopep8 = "^1.6.0"
25
+ stdout-stderr-capturing = "^0.2.0"
25
26
 
26
27
  [build-system]
27
28
  requires = ["poetry>=1.2.0b2"]
@@ -8,7 +8,7 @@ package_data = \
8
8
  {'': ['*']}
9
9
 
10
10
  install_requires = \
11
- ['conf2levels>=0.4.0,<0.5.0',
11
+ ['conf2levels>=0.5.0,<0.6.0',
12
12
  'icinga2apic>=0.7.5,<0.8.0',
13
13
  'termcolor>=1.1.0,<2.0.0',
14
14
  'types-requests>=2.28.1,<3.0.0',
@@ -16,7 +16,7 @@ install_requires = \
16
16
 
17
17
  setup_kwargs = {
18
18
  'name': 'command-watcher',
19
- 'version': '0.2.0',
19
+ 'version': '0.4.0',
20
20
  'description': 'Module to watch the execution of shell scripts. Both streams (`stdout` and `stderr`) are captured.',
21
21
  'long_description': "command_watcher\n===============\n\nModule to watch the execution of shell scripts. Both streams (`stdout`\nand `stderr`) are captured.\n\n.. code:: python\n\n watch = Watch()\n watch.log.critical('msg')\n watch.log.error('msg')\n watch.log.warning('msg')\n watch.log.info('msg')\n watch.log.debug('msg')\n watch.run(['rsync', '-av', '/home', '/backup'])\n\n.. code-block:: python\n\n from command_watcher import Watch\n watch = Watch(\n config_file='/etc/command-watcher.ini',\n service_name='texlive_update'\n )\n\n tlmgr = '/usr/local/texlive/bin/x86_64-linux/tlmgr'\n\n watch.run('{} update --self'.format(tlmgr))\n watch.run('{} update --all'.format(tlmgr))\n installed_packages = watch.run(\n '{} info --only-installed'.format(tlmgr), log=False\n )\n all_packages = watch.run('{} info'.format(tlmgr), log=False)\n\n watch.final_report(\n status=0,\n performance_data={\n 'installed_packages': installed_packages.line_count_stdout,\n 'all_packages': all_packages.line_count_stdout,\n },\n )\n\n.. code-block:: ini\n\n [email]\n subject_prefix = [cwatcher]\n from_addr =\n to_addr = logs@example.com\n to_addr_critical = critical@example.com\n smtp_login = mailer\n smtp_password = 1234\n smtp_server = mail.example.com:587\n\n [nsca]\n remote_host = 1.2.3.4\n password = asdf1234\n encryption_method = 8\n ; port = 5667\n\n [icinga]\n url = https://icinga.example.com:5665\n user = user\n password = 1234\n\n [beep]\n activated = True\n",
22
22
  'author': 'Josef Friedrich',
File without changes