Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-python-crontab for
openSUSE:Factory checked in at 2022-10-08 01:25:32
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-python-crontab (Old)
and /work/SRC/openSUSE:Factory/.python-python-crontab.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-python-crontab"
Sat Oct 8 01:25:32 2022 rev:6 rq:1008715 version:2.6.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-python-crontab/python-python-crontab.changes
2021-05-07 16:46:17.560182407 +0200
+++
/work/SRC/openSUSE:Factory/.python-python-crontab.new.2275/python-python-crontab.changes
2022-10-08 01:25:55.682326403 +0200
@@ -1,0 +2,15 @@
+Thu Oct 6 22:15:25 UTC 2022 - Yogalakshmi Arunachalam <[email protected]>
+
+- Update to 2.6.0
+- Fix #87 with specials flag on rendering options
+* Fix #82 with a cron_command API and README updates
+* Fix #88 with comment change
+* Merge branch 'issue-cron-weekdays-vs-python-weekdays' into 'master'
+* Fix test_02_days_per_year calculations incorrect
+* Fix #81 make a command valid when setting the command
+* bump version
+* Fix #75 apply disabled comment prefix before pre-comment
+* Fix #73 add support for percent sign stdin and escaping
+* Fix #71 record pre-comment styles faithfully for re-rendering
+
+-------------------------------------------------------------------
Old:
----
python-crontab-2.5.1.tar.gz
New:
----
python-crontab-2.6.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-python-crontab.spec ++++++
--- /var/tmp/diff_new_pack.xtkprm/_old 2022-10-08 01:25:56.154327485 +0200
+++ /var/tmp/diff_new_pack.xtkprm/_new 2022-10-08 01:25:56.158327495 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-python-crontab
#
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_without python2
Name: python-python-crontab
-Version: 2.5.1
+Version: 2.6.0
Release: 0
Summary: Python Crontab API
License: LGPL-3.0-only
++++++ python-crontab-2.5.1.tar.gz -> python-crontab-2.6.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-crontab-2.5.1/PKG-INFO
new/python-crontab-2.6.0/PKG-INFO
--- old/python-crontab-2.5.1/PKG-INFO 2020-05-17 19:15:40.000000000 +0200
+++ new/python-crontab-2.6.0/PKG-INFO 2021-10-19 22:50:03.383303600 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: python-crontab
-Version: 2.5.1
+Version: 2.6.0
Summary: Python Crontab API
Home-page: https://gitlab.com/doctormo/python-crontab/
Author: Martin Owens
@@ -21,7 +21,7 @@
Please report any problems to the `GitLab issues tracker
<https://gitlab.com/doctormo/python-crontab/issues>`_. Please use Git and push
patches to the `GitLab project code hosting
<https://gitlab.com/doctormo/python-crontab>`_.
- **Note:** If you get the error ``TypeError: __init__() takes exactly 2
arguments`` when using CronTab, you have the wrong module installed. You need
to install ``python-crontab`` and not ``crontab`` from pypi or your local
package manager and try again.
+ **Note:** If you get the error ``got an unexpected keyword argument
'user'`` when using CronTab, you have the wrong module installed. You need to
install ``python-crontab`` and not ``crontab`` from pypi or your local package
manager and try again.
Description
===========
@@ -433,6 +433,8 @@
Extra Support
=============
+ - Customise the location of the crontab command by setting the global
CRON_COMMAND
+ or the per-object cron_command attribute.
- Support for vixie cron with username addition with user flag
- Support for SunOS, AIX & HP with compatibility 'SystemV' mode.
- Python 3 (3.5, 3.6, 3.7) and Python 2.7 tested, python 2.6 removed
from support.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-crontab-2.5.1/README.rst
new/python-crontab-2.6.0/README.rst
--- old/python-crontab-2.5.1/README.rst 2020-01-27 07:39:48.000000000 +0100
+++ new/python-crontab-2.6.0/README.rst 2021-10-19 22:23:24.000000000 +0200
@@ -13,7 +13,7 @@
Please report any problems to the `GitLab issues tracker
<https://gitlab.com/doctormo/python-crontab/issues>`_. Please use Git and push
patches to the `GitLab project code hosting
<https://gitlab.com/doctormo/python-crontab>`_.
-**Note:** If you get the error ``TypeError: __init__() takes exactly 2
arguments`` when using CronTab, you have the wrong module installed. You need
to install ``python-crontab`` and not ``crontab`` from pypi or your local
package manager and try again.
+**Note:** If you get the error ``got an unexpected keyword argument 'user'``
when using CronTab, you have the wrong module installed. You need to install
``python-crontab`` and not ``crontab`` from pypi or your local package manager
and try again.
Description
===========
@@ -425,6 +425,8 @@
Extra Support
=============
+ - Customise the location of the crontab command by setting the global
CRON_COMMAND
+ or the per-object cron_command attribute.
- Support for vixie cron with username addition with user flag
- Support for SunOS, AIX & HP with compatibility 'SystemV' mode.
- Python 3 (3.5, 3.6, 3.7) and Python 2.7 tested, python 2.6 removed from
support.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-crontab-2.5.1/crontab.py
new/python-crontab-2.6.0/crontab.py
--- old/python-crontab-2.5.1/crontab.py 2020-05-17 19:15:32.000000000 +0200
+++ new/python-crontab-2.6.0/crontab.py 2021-10-19 22:44:22.000000000 +0200
@@ -1,5 +1,5 @@
#
-# Copyright 2017, Martin Owens <[email protected]>
+# Copyright 2021, Martin Owens <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -107,7 +107,7 @@
" install ordereddict 1.1 from pypi for python2.6")
__pkgname__ = 'python-crontab'
-__version__ = '2.5.1'
+__version__ = '2.6.0'
ITEMREX = re.compile(r'^\s*([^@#\s]+)\s+([^@#\s]+)\s+([^@#\s]+)\s+([^@#\s]+)'
r'\s+([^@#\s]+)\s+([^\n]*?)(\s+#\s*([^\n]*)|$)')
@@ -154,7 +154,7 @@
LOG = logging.getLogger('crontab')
-CRONCMD = "/usr/bin/crontab"
+CRON_COMMAND = "/usr/bin/crontab"
SHELL = os.environ.get('SHELL', '/bin/sh')
# The shell won't actually work on windows here, but
# it should be updated later in the below conditional.
@@ -198,7 +198,7 @@
return text
-class CronTab(object):
+class CronTab:
"""
Crontab object which can access any time based cron using the standard.
@@ -211,12 +211,12 @@
tab - Use a string variable as the crontab instead of installed crontab
tabfile - Use a file for the crontab instead of installed crontab
log - Filename for logfile instead of /var/log/syslog
-
"""
def __init__(self, user=None, tab=None, tabfile=None, log=None):
self.lines = None
self.crons = None
self.filen = None
+ self.cron_command = CRON_COMMAND
self.env = None
self._parked_env = OrderedDict()
# Protect windows users
@@ -237,7 +237,7 @@
@property
def log(self):
"""Returns the CronLog object for this tab (user or root tab only)"""
- from cronlog import CronLog
+ from cronlog import CronLog # pylint: disable=import-outside-toplevel
if self._log is None or isinstance(self._log, basestring):
self._log = CronLog(self._log, user=self.user or 'root')
return self._log
@@ -288,7 +288,7 @@
lines = fhl.readlines()
elif self.user:
- (out, err) = open_pipe(CRONCMD, l='',
**self.user_opt).communicate()
+ (out, err) = open_pipe(self.cron_command, l='',
**self.user_opt).communicate()
if err and 'no crontab for' in unicode(err):
pass
elif err:
@@ -354,11 +354,11 @@
os.unlink(path)
raise IOError("Please specify user or filename to write.")
- proc = open_pipe(CRONCMD, path, **self.user_opt)
+ proc = open_pipe(self.cron_command, path, **self.user_opt)
ret = proc.wait()
if ret != 0:
raise IOError("Program Error: {} returned {}: {}".format(
- CRONCMD, ret, proc.stderr.read()))
+ self.cron_command, ret, proc.stderr.read()))
proc.stdout.close()
proc.stderr.close()
os.unlink(path)
@@ -387,10 +387,14 @@
sleep(kwargs.get('cadence', 60))
count += 1
- def render(self, errors=False):
+ def render(self, errors=False, specials=True):
"""Render this crontab as it would be in the crontab.
errors - Should we not comment out invalid entries and cause errors?
+ specials - Turn known times into keywords such as "@daily"
+ True - (default) force all values to be converted (unless SYSTEMV)
+ False - force all values back from being a keyword
+ None - don't change the special keyword use
"""
crons = []
for line in self.lines:
@@ -404,7 +408,7 @@
elif isinstance(line, CronItem):
if not line.is_valid() and not errors:
line.enabled = False
- crons.append(unicode(line).strip())
+ crons.append(line.render(specials=specials).strip())
# Environment variables are attached to cron lines so order will
# always work no matter how you add lines in the middle of the stack.
@@ -421,7 +425,8 @@
"""
if not user and self.user is False:
raise ValueError("User is required for system crontabs.")
- item = CronItem(command, comment, user=user, cron=self,
pre_comment=pre_comment)
+ item = CronItem(command, comment, user=user, pre_comment=pre_comment)
+ item.cron = self
self.append(item)
return item
@@ -479,9 +484,9 @@
raise AttributeError("Invalid use: remove_all(command='cmd')")
if 'command' in kwargs:
return self.remove(*self.find_command(kwargs['command']))
- elif 'comment' in kwargs:
+ if 'comment' in kwargs:
return self.remove(*self.find_comment(kwargs['comment']))
- elif 'time' in kwargs:
+ if 'time' in kwargs:
return self.remove(*self.find_time(kwargs['time']))
return self.remove(*self.crons[:])
@@ -509,10 +514,9 @@
sibling.env.update(env)
sibling.env.job = sibling
break
- elif sibling == '':
- self.lines.remove(sibling)
- else:
+ if sibling != '':
break
+ self.lines.remove(sibling)
self.crons.remove(item)
self.lines.remove(item)
@@ -522,9 +526,9 @@
kind = 'System ' if self._user is False else ''
if self.filen:
return "<%sCronTab '%s'>" % (kind, self.filen)
- elif self.user and not self.user_opt:
+ if self.user and not self.user_opt:
return "<My CronTab>"
- elif self.user:
+ if self.user:
return "<User CronTab '%s'>" % self.user
return "<Unattached %sCronTab>" % kind
@@ -546,13 +550,13 @@
return self.render()
-class CronItem(object):
+class CronItem:
"""
An item which objectifies a single line of a crontab and
May be considered to be a cron job object.
"""
- def __init__(self, command='', comment='', user=None, cron=None,
pre_comment=False):
- self.cron = cron
+ def __init__(self, command='', comment='', user=None, pre_comment=False):
+ self.cron = None
self.user = user
self.valid = False
self.enabled = True
@@ -575,7 +579,6 @@
if command:
self.set_command(command)
- self.valid = True
def __hash__(self):
return hash((self.command, self.comment, self.hour, self.minute,
self.dow))
@@ -588,7 +591,8 @@
@classmethod
def from_line(cls, line, user=None, cron=None):
"""Generate CronItem from a cron-line and parse out command and
comment"""
- obj = cls(user=user, cron=cron)
+ obj = cls(user=user)
+ obj.cron = cron
obj.parse(line.strip())
return obj
@@ -596,8 +600,7 @@
"""Delete this item and remove it from it's parent"""
if not self.cron:
raise UnboundLocalError("Cron item is not in a crontab!")
- else:
- self.cron.remove(self)
+ self.cron.remove(self)
def set_command(self, cmd, parse_stdin=False):
"""Set the command and filter as needed"""
@@ -606,6 +609,7 @@
if '\n' in cmd:
cmd, self.stdin = cmd.split('\n', 1)
self.command = _unicode(cmd.strip())
+ self.valid = True
def set_comment(self, cmt, pre_comment=False):
"""Set the comment and don't filter, pre_comment indicates comment
appears
@@ -648,7 +652,6 @@
self.set_command(result[0][-3], True)
try:
self.setall(*result[0][:-3])
- self.valid = True
except (ValueError, KeyError) as err:
if self.enabled:
LOG.error(str(err))
@@ -669,15 +672,18 @@
"""Return true if this job is valid"""
return self.valid
- def render(self):
+ def render(self, specials=True):
"""Render this set cron-job to a string"""
+ if not self.is_valid() and self.enabled:
+ raise ValueError('Refusing to render invalid crontab.'
+ ' Disable to continue.')
command = _unicode(self.command).replace(u'%', u'\\%')
user = ''
if self.cron and self.cron.user is False:
if not self.user:
raise ValueError("Job to system-cron format, no user set!")
user = self.user + ' '
- result = u"%s %s%s" % (unicode(self.slices), user, command)
+ result = u"%s %s%s" % (self.slices.render(specials=specials), user,
command)
if self.stdin:
result += ' %' + self.stdin.replace('\n', '%')
if not self.enabled:
@@ -776,7 +782,7 @@
date_from = datetime.now()
try:
# Croniter is an optional import
- from croniter.croniter import croniter
+ from croniter.croniter import croniter # pylint:
disable=import-outside-toplevel
except ImportError:
raise ImportError("Croniter not available. Please install croniter"
" python module via pip or your package manager")
@@ -789,7 +795,7 @@
**kw - Keyword arguments to pass to cron_descriptor (see docs)
"""
try:
- from cron_descriptor import ExpressionDescriptor
+ from cron_descriptor import ExpressionDescriptor # pylint:
disable=import-outside-toplevel
except ImportError:
raise ImportError("cron_descriptor not available. Please install"\
"cron_descriptor python module via pip or your package manager")
@@ -868,13 +874,10 @@
return self.__unicode__()
def __unicode__(self):
- if not self.is_valid() and self.enabled:
- raise ValueError('Refusing to render invalid crontab.'
- ' Disable to continue.')
return self.render()
-class Every(object):
+class Every:
"""Provide an interface to the job.every() method:
Available Calls:
minute, minutes, hour, hours, dom, doms, month, months, dow, dows
@@ -950,15 +953,15 @@
return CronSlices._parse_str(value)
if isinstance(value, CronItem):
return value.slices, None
- elif isinstance(value, datetime):
+ if isinstance(value, datetime):
return [value.minute, value.hour, value.day, value.month, '*'],
None
- elif isinstance(value, time):
+ if isinstance(value, time):
return [value.minute, value.hour, '*', '*', '*'], None
- elif isinstance(value, date):
+ if isinstance(value, date):
return [0, 0, value.day, value.month, '*'], None
# It might be possible to later understand timedelta objects
# but there's no convincing mathematics to do the conversion yet.
- elif not isinstance(value, (list, tuple)):
+ if not isinstance(value, (list, tuple)):
raise ValueError("Unknown type: {}".format(type(value).__name__))
return value, None
@@ -968,9 +971,9 @@
key = value.lstrip('@').lower()
if value.count(' ') == 4:
return value.strip().split(' '), None
- elif key in SPECIALS.keys():
+ if key in SPECIALS.keys():
return SPECIALS[key].split(' '), '@' + key
- elif value.startswith('@'):
+ if value.startswith('@'):
raise ValueError("Unknown special '{}'".format(value))
return [value], None
@@ -978,14 +981,14 @@
"""Return just numbered parts of this crontab"""
return ' '.join([unicode(s) for s in self])
- def render(self):
+ def render(self, specials=True):
"Return just the first part of a cron job (the numbers or special)"
slices = self.clean_render()
- if self.special:
+ if self.special and specials is not False:
if self.special == '@reboot' or \
SPECIALS[self.special.strip('@')] == slices:
return self.special
- if not SYSTEMV:
+ if not SYSTEMV and specials is True:
for (name, value) in SPECIALS.items():
if value == slices and name not in SPECIAL_IGNORE:
return "@%s" % name
@@ -1013,7 +1016,7 @@
for month in self[3]:
for day in self[2]:
try:
- if date(year, month, day).weekday() in weekdays:
+ if (date(year, month, day).weekday() + 1) % 7 in weekdays:
result += 1
except ValueError:
continue
@@ -1036,9 +1039,8 @@
class SundayError(KeyError):
"""Sunday was specified as 7 instead of 0"""
- pass
-class Also(object):
+class Also:
"""Link range values together (appending instead of replacing)"""
def __init__(self, obj):
self.obj = obj
@@ -1055,7 +1057,7 @@
"""Also during these"""
return self.obj.during(*a, also=True)
-class CronSlice(object):
+class CronSlice:
"""Cron slice object which shows a time pattern"""
def __init__(self, info, value=None):
if isinstance(info, int):
@@ -1081,7 +1083,7 @@
continue
self.parts.append(self.parse_value(part, sunday=0))
- def render(self, resolve=False):
+ def render(self, resolve=False, specials=True):
"""Return the slice rendered as a crontab.
resolve - return integer values instead of enums (default False)
@@ -1187,14 +1189,14 @@
"""Returns a value as int (pass-through) or a special enum value"""
if isinstance(value, int):
return value
- elif unicode(value).isdigit():
+ if unicode(value).isdigit():
return int(str(value))
if not enums:
raise KeyError("No enumeration allowed")
return CronValue(unicode(value), enums)
-class CronValue(object): # pylint: disable=too-few-public-methods
+class CronValue: # pylint: disable=too-few-public-methods
"""Represent a special value in the cron line"""
def __init__(self, value, enums):
self.text = value
@@ -1229,7 +1231,7 @@
return unicode(u'{:02d}'.format(value) if ZERO_PAD else value)
-class CronRange(object):
+class CronRange:
"""A range between one value and another for a time range."""
def __init__(self, vslice, *vrange):
# holds an extra dangling entry, for example sundays.
@@ -1360,7 +1362,7 @@
previous = self.previous
if key in self:
return super(OrderedVariableList, self).__getitem__(key)
- elif previous is not None:
+ if previous is not None:
return previous.all()[key]
raise KeyError("Environment Variable '%s' not found." % key)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/python-crontab-2.5.1/python_crontab.egg-info/PKG-INFO
new/python-crontab-2.6.0/python_crontab.egg-info/PKG-INFO
--- old/python-crontab-2.5.1/python_crontab.egg-info/PKG-INFO 2020-05-17
19:15:40.000000000 +0200
+++ new/python-crontab-2.6.0/python_crontab.egg-info/PKG-INFO 2021-10-19
22:50:02.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: python-crontab
-Version: 2.5.1
+Version: 2.6.0
Summary: Python Crontab API
Home-page: https://gitlab.com/doctormo/python-crontab/
Author: Martin Owens
@@ -21,7 +21,7 @@
Please report any problems to the `GitLab issues tracker
<https://gitlab.com/doctormo/python-crontab/issues>`_. Please use Git and push
patches to the `GitLab project code hosting
<https://gitlab.com/doctormo/python-crontab>`_.
- **Note:** If you get the error ``TypeError: __init__() takes exactly 2
arguments`` when using CronTab, you have the wrong module installed. You need
to install ``python-crontab`` and not ``crontab`` from pypi or your local
package manager and try again.
+ **Note:** If you get the error ``got an unexpected keyword argument
'user'`` when using CronTab, you have the wrong module installed. You need to
install ``python-crontab`` and not ``crontab`` from pypi or your local package
manager and try again.
Description
===========
@@ -433,6 +433,8 @@
Extra Support
=============
+ - Customise the location of the crontab command by setting the global
CRON_COMMAND
+ or the per-object cron_command attribute.
- Support for vixie cron with username addition with user flag
- Support for SunOS, AIX & HP with compatibility 'SystemV' mode.
- Python 3 (3.5, 3.6, 3.7) and Python 2.7 tested, python 2.6 removed
from support.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-crontab-2.5.1/tests/test_crontabs.py
new/python-crontab-2.6.0/tests/test_crontabs.py
--- old/python-crontab-2.5.1/tests/test_crontabs.py 2019-09-26
12:51:45.000000000 +0200
+++ new/python-crontab-2.6.0/tests/test_crontabs.py 2021-10-19
22:14:53.000000000 +0200
@@ -62,7 +62,7 @@
(crontabs.AnaCronTab, os.path.join(TEST_DIR, 'data', 'anacron')),
]
-crontab.CRONCMD = "%s %s" % (sys.executable, os.path.join(TEST_DIR, 'data',
'crontest'))
+crontab.CRON_COMMAND = "%s %s" % (sys.executable, os.path.join(TEST_DIR,
'data', 'crontest'))
class CronTabsTestCase(unittest.TestCase):
"""Test use documentation in crontab."""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-crontab-2.5.1/tests/test_frequency.py
new/python-crontab-2.6.0/tests/test_frequency.py
--- old/python-crontab-2.5.1/tests/test_frequency.py 2016-01-02
05:38:51.000000000 +0100
+++ new/python-crontab-2.6.0/tests/test_frequency.py 2021-10-19
21:54:34.000000000 +0200
@@ -69,8 +69,9 @@
self.assertEqual(len(self.job[2]), 10)
self.assertEqual(len(self.job[3]), 4)
self.assertEqual(len(self.job[4]), 2)
- self.assertEqual(self.job.frequency_per_year(year=2013), 11)
- self.assertEqual(self.job.frequency_per_year(year=2010), 12)
+ self.assertEqual(self.job.frequency_per_year(year=2010), 11)
+ self.assertEqual(self.job.frequency_per_year(year=2013), 12)
+ self.assertEqual(self.job.frequency_per_year(year=2020), 13)
def test_03_job(self):
"""Once Yearly"""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-crontab-2.5.1/tests/test_interaction.py
new/python-crontab-2.6.0/tests/test_interaction.py
--- old/python-crontab-2.5.1/tests/test_interaction.py 2020-05-16
01:43:29.000000000 +0200
+++ new/python-crontab-2.6.0/tests/test_interaction.py 2021-10-19
22:42:20.000000000 +0200
@@ -199,10 +199,10 @@
job.minute.every(2)
job.valid = False
with self.assertRaises(ValueError):
- unicode(job)
+ str(job)
# Disabled jobs still work
job.enabled = False
- unicode(job)
+ str(job)
job.enabled = True
with self.assertRaises(ValueError):
@@ -210,6 +210,11 @@
self.crontab.render(errors=False)
self.assertFalse(job.enabled)
+ job = self.crontab.new()
+ self.assertFalse(job.is_valid())
+ job.set_command("now_valid")
+ self.assertTrue(job.is_valid())
+
def test_15_slices(self):
"""Invalid Slices"""
mon = CronSlices('* * * * *')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-crontab-2.5.1/tests/test_usage.py
new/python-crontab-2.6.0/tests/test_usage.py
--- old/python-crontab-2.5.1/tests/test_usage.py 2020-04-30
03:10:48.000000000 +0200
+++ new/python-crontab-2.6.0/tests/test_usage.py 2021-10-19
22:46:05.000000000 +0200
@@ -42,7 +42,7 @@
BASIC = '@hourly firstcommand\n\n'
USER = '\n*/4 * * * * user_command # user_comment\n\n\n'
-crontab.CRONCMD = "%s %s" % (sys.executable, os.path.join(TEST_DIR, 'data',
'crontest'))
+crontab.CRON_COMMAND = "%s %s" % (sys.executable, os.path.join(TEST_DIR,
'data', 'crontest'))
def flush():
pass
@@ -145,7 +145,7 @@
self.assertTrue(item.is_enabled())
with self.assertRaises(UnboundLocalError):
item.delete()
- item.command = str('nothing')
+ item.set_command('nothing')
self.assertEqual(item.render(), '* * * * * nothing')
def test_10_time_object(self):
@@ -198,10 +198,20 @@
self.assertFalse(CronSlices.is_valid('* * * * FRO-TOO'))
self.assertFalse(CronSlices.is_valid('@retool'))
+ def test_21_slice_special(self):
+ """Rendering can be done without specials"""
+ cronitem = crontab.CronItem('true')
+ cronitem.setall('0 0 * * *')
+ self.assertEqual(cronitem.render(specials=True), '@daily true')
+ self.assertEqual(cronitem.render(specials=None), '0 0 * * * true')
+ cronitem.setall('@daily')
+ self.assertEqual(cronitem.render(specials=None), '@daily true')
+ self.assertEqual(cronitem.render(specials=False), '0 0 * * * true')
+
def test_25_open_pipe(self):
"""Test opening pipes"""
- from crontab import open_pipe, CRONCMD
- pipe = open_pipe(CRONCMD, h=None, a='one', abc='two')
+ from crontab import open_pipe, CRON_COMMAND
+ pipe = open_pipe(CRON_COMMAND, h=None, a='one', abc='two')
(out, err) = pipe.communicate()
self.assertEqual(err, b'')
self.assertEqual(out, b'--abc=two|-a|-h|one\n')