mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Port cron to a py3 and py24 compatible syntax (#3674)
This commit is contained in:
parent
f2212dc41a
commit
f0fd1109dd
1 changed files with 4 additions and 4 deletions
|
@ -241,7 +241,7 @@ class CronTab(object):
|
||||||
f = open(self.cron_file, 'r')
|
f = open(self.cron_file, 'r')
|
||||||
self.lines = f.read().splitlines()
|
self.lines = f.read().splitlines()
|
||||||
f.close()
|
f.close()
|
||||||
except IOError, e:
|
except IOError:
|
||||||
# cron file does not exist
|
# cron file does not exist
|
||||||
return
|
return
|
||||||
except:
|
except:
|
||||||
|
@ -278,7 +278,7 @@ class CronTab(object):
|
||||||
fileh = open(self.cron_file, 'w')
|
fileh = open(self.cron_file, 'w')
|
||||||
else:
|
else:
|
||||||
filed, path = tempfile.mkstemp(prefix='crontab')
|
filed, path = tempfile.mkstemp(prefix='crontab')
|
||||||
os.chmod(path, 0644)
|
os.chmod(path, int('0644', 8))
|
||||||
fileh = os.fdopen(filed, 'w')
|
fileh = os.fdopen(filed, 'w')
|
||||||
|
|
||||||
fileh.write(self.render())
|
fileh.write(self.render())
|
||||||
|
@ -354,7 +354,7 @@ class CronTab(object):
|
||||||
try:
|
try:
|
||||||
os.unlink(self.cron_file)
|
os.unlink(self.cron_file)
|
||||||
return True
|
return True
|
||||||
except OSError, e:
|
except OSError:
|
||||||
# cron file does not exist
|
# cron file does not exist
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
|
@ -568,7 +568,7 @@ def main():
|
||||||
res_args = dict()
|
res_args = dict()
|
||||||
|
|
||||||
# Ensure all files generated are only writable by the owning user. Primarily relevant for the cron_file option.
|
# Ensure all files generated are only writable by the owning user. Primarily relevant for the cron_file option.
|
||||||
os.umask(022)
|
os.umask(int('022', 8))
|
||||||
crontab = CronTab(module, user, cron_file)
|
crontab = CronTab(module, user, cron_file)
|
||||||
|
|
||||||
module.debug('cron instantiated - name: "%s"' % name)
|
module.debug('cron instantiated - name: "%s"' % name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue