Loading .gitlab-ci.yml +3 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ ruff: stage: lint image: registry.gitlab.com/pipeline-components/ruff:latest script: - ruff --ignore=E402,E731,F401,F821,F841 --line-length=128 --show-source . - ruff check --output-format=gitlab . pytest: stage: test Loading @@ -39,7 +39,7 @@ setup.py_test: stage: test image: python:latest script: # All pytests fail with ModuleNotFoundError: No module named 'test' - pip install pytest - pip install pytest setuptools - pip install --editable ".[cron-description,cron-schedule]" - pip list - python setup.py test Loading @@ -48,7 +48,7 @@ setup.py_test_with_coverage: stage: test image: python:latest script: # With `&> /dev/null` in `./coverage.sh` everything appears green but... - pip install coverage pytest - pip install coverage pytest setuptools - pip install --editable ".[cron-description,cron-schedule]" - ./coverage.sh Loading cronlog.py +7 −4 Original line number Diff line number Diff line Loading @@ -21,12 +21,12 @@ Access logs in known locations to find information about them. import os import re import codecs import platform from dateutil import parser as dateparse from datetime import datetime MATCHER = r'(?P<date>\w+ +\d+ +\d\d:\d\d:\d\d) (?P<host>\w+) ' + \ r'CRON\[(?P<pid>\d+)\]: \((?P<user>\w+)\) CMD \((?P<cmd>.*)\)' class LogReader(object): """Opens a Log file, reading backwards and watching for changes""" def __init__(self, filename, mass=4096): Loading Loading @@ -82,6 +82,10 @@ class LogReader(object): loc -= len(line) def cron_date_to_datetime(cron_str): with_year = f"{cron_str} {datetime.now().year}" return datetime.strptime(with_year, "%b %d %H:%M:%S %Y") class CronLog(LogReader): """Use the LogReader to make a Cron specific log reader""" Loading @@ -98,7 +102,7 @@ class CronLog(LogReader): match = re.match(MATCHER, str(line)) datum = match and match.groupdict() if datum and (not self.user or datum['user'] == self.user): datum['date'] = dateparse.parse(datum['date']) datum['date'] = cron_date_to_datetime(datum['date']) yield datum Loading @@ -112,4 +116,3 @@ class ProgramLog(object): for entry in self.log: if entry['cmd'] == str(self.command): yield entry pyproject.toml 0 → 100644 +12 −0 Original line number Diff line number Diff line [tool.ruff] line-length = 128 [tool.ruff.lint] ignore = [ "E402", "E731", "F401", "F821", "F841", ] setup.py +0 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ setup( license = 'LGPLv3', py_modules = ['crontab', 'crontabs', 'cronlog'], provides = ['crontab', 'crontabs', 'cronlog'], install_requires = ['python-dateutil'], extras_require = { 'cron-schedule': ['croniter'], 'cron-description': ['cron-descriptor'], Loading tests/test_utf8.py +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ class Utf8TestCase(unittest.TestCase): def test_02_write(self): """Write/Read UTF-8 Filename""" self.assertEqual(locale.getpreferredencoding(), 'UTF-8') self.assertEqual(locale.getpreferredencoding().lower(), 'utf-8') self.crontab.write(filename) crontab = CronTab(tabfile=filename) self.assertTrue(crontab) Loading Loading
.gitlab-ci.yml +3 −3 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ ruff: stage: lint image: registry.gitlab.com/pipeline-components/ruff:latest script: - ruff --ignore=E402,E731,F401,F821,F841 --line-length=128 --show-source . - ruff check --output-format=gitlab . pytest: stage: test Loading @@ -39,7 +39,7 @@ setup.py_test: stage: test image: python:latest script: # All pytests fail with ModuleNotFoundError: No module named 'test' - pip install pytest - pip install pytest setuptools - pip install --editable ".[cron-description,cron-schedule]" - pip list - python setup.py test Loading @@ -48,7 +48,7 @@ setup.py_test_with_coverage: stage: test image: python:latest script: # With `&> /dev/null` in `./coverage.sh` everything appears green but... - pip install coverage pytest - pip install coverage pytest setuptools - pip install --editable ".[cron-description,cron-schedule]" - ./coverage.sh Loading
cronlog.py +7 −4 Original line number Diff line number Diff line Loading @@ -21,12 +21,12 @@ Access logs in known locations to find information about them. import os import re import codecs import platform from dateutil import parser as dateparse from datetime import datetime MATCHER = r'(?P<date>\w+ +\d+ +\d\d:\d\d:\d\d) (?P<host>\w+) ' + \ r'CRON\[(?P<pid>\d+)\]: \((?P<user>\w+)\) CMD \((?P<cmd>.*)\)' class LogReader(object): """Opens a Log file, reading backwards and watching for changes""" def __init__(self, filename, mass=4096): Loading Loading @@ -82,6 +82,10 @@ class LogReader(object): loc -= len(line) def cron_date_to_datetime(cron_str): with_year = f"{cron_str} {datetime.now().year}" return datetime.strptime(with_year, "%b %d %H:%M:%S %Y") class CronLog(LogReader): """Use the LogReader to make a Cron specific log reader""" Loading @@ -98,7 +102,7 @@ class CronLog(LogReader): match = re.match(MATCHER, str(line)) datum = match and match.groupdict() if datum and (not self.user or datum['user'] == self.user): datum['date'] = dateparse.parse(datum['date']) datum['date'] = cron_date_to_datetime(datum['date']) yield datum Loading @@ -112,4 +116,3 @@ class ProgramLog(object): for entry in self.log: if entry['cmd'] == str(self.command): yield entry
pyproject.toml 0 → 100644 +12 −0 Original line number Diff line number Diff line [tool.ruff] line-length = 128 [tool.ruff.lint] ignore = [ "E402", "E731", "F401", "F821", "F841", ]
setup.py +0 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ setup( license = 'LGPLv3', py_modules = ['crontab', 'crontabs', 'cronlog'], provides = ['crontab', 'crontabs', 'cronlog'], install_requires = ['python-dateutil'], extras_require = { 'cron-schedule': ['croniter'], 'cron-description': ['cron-descriptor'], Loading
tests/test_utf8.py +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ class Utf8TestCase(unittest.TestCase): def test_02_write(self): """Write/Read UTF-8 Filename""" self.assertEqual(locale.getpreferredencoding(), 'UTF-8') self.assertEqual(locale.getpreferredencoding().lower(), 'utf-8') self.crontab.write(filename) crontab = CronTab(tabfile=filename) self.assertTrue(crontab) Loading