Skip to content

Commit

Permalink
translate both annually & anually to yearl, there is a typu in systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
a-detiste committed Oct 25, 2014
1 parent 2330924 commit 968add1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/bin/systemd-crontab-generator
@@ -1,6 +1,7 @@
#!/usr/bin/python3
import sys
import os
import pwd
import re
import string
from functools import reduce
Expand All @@ -12,7 +13,7 @@ HOURS_SET = list(range(0, 24))
DAYS_SET = list(range(0, 32))
DOWS_SET = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
MONTHS_SET = list(range(0, 13))
TIME_UNITS_SET = ['hourly', 'daily', 'weekly', 'monthly', 'yearly', 'annually']
TIME_UNITS_SET = ['hourly', 'daily', 'weekly', 'monthly', 'yearly']

def files(dirname):
try:
Expand Down Expand Up @@ -54,10 +55,12 @@ def parse_crontab(filename, withuser=True, monotonic=False):
command = ' '.join(parts[3:])
period = {
'1': 'daily',
'7': 'weekly',
'@midnight': 'daily',
'7': 'weekly',
'30': 'monthly',
'31': 'monthly'
'31': 'monthly',
'@anually': 'yearly',
'@annually': 'yearly',
}.get(period, None) or period.lstrip('@')
valid_chars = "-_%s%s" % (string.ascii_letters, string.digits)
jobid = ''.join(c for c in jobid if c in valid_chars)
Expand All @@ -83,7 +86,9 @@ def parse_crontab(filename, withuser=True, monotonic=False):

period = parts[0]
period = {
'@midnight': 'daily'
'@midnight': 'daily',
'@anually': 'yearly',
'@annually': 'yearly',
}.get(period, None) or period.lstrip('@')

user, command = (parts[1], ' '.join(parts[2:])) if withuser else (basename, ' '.join(parts[1:]))
Expand Down Expand Up @@ -259,7 +264,7 @@ def generate_timer_unit(job, seq):
schedule = 'Mon *-*-* %s:%s:0' % (hour, delay)
elif job['p'] == 'monthly':
schedule = '*-*-1 %s:%s:0' % (hour, delay)
elif job['p'] == 'yearly' or job['p'] == 'annually':
elif job['p'] == 'yearly':
schedule = '*-1-1 %s:%s:0' % (hour, delay)
else:
try:
Expand Down Expand Up @@ -316,6 +321,7 @@ def generate_timer_unit(job, seq):
f.write('RefuseManualStart=true\n')
f.write('RefuseManualStop=true\n')
f.write('SourcePath=%s\n' % job['f'])
f.write('RequiresMountsFor=%s\n' % pwd.getpwnam(job['u']).pw_dir)

f.write('\n[Service]\n')
f.write('Type=oneshot\n')
Expand Down

0 comments on commit 968add1

Please sign in to comment.