From f0fd1109dda1b947f2626f9b1873111d60ea5ce1 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Tue, 17 May 2016 19:19:19 +0200 Subject: [PATCH] Port cron to a py3 and py24 compatible syntax (#3674) --- lib/ansible/modules/system/cron.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/system/cron.py b/lib/ansible/modules/system/cron.py index 5851cfe366b..5884fa82290 100644 --- a/lib/ansible/modules/system/cron.py +++ b/lib/ansible/modules/system/cron.py @@ -241,7 +241,7 @@ class CronTab(object): f = open(self.cron_file, 'r') self.lines = f.read().splitlines() f.close() - except IOError, e: + except IOError: # cron file does not exist return except: @@ -278,7 +278,7 @@ class CronTab(object): fileh = open(self.cron_file, 'w') else: filed, path = tempfile.mkstemp(prefix='crontab') - os.chmod(path, 0644) + os.chmod(path, int('0644', 8)) fileh = os.fdopen(filed, 'w') fileh.write(self.render()) @@ -354,7 +354,7 @@ class CronTab(object): try: os.unlink(self.cron_file) return True - except OSError, e: + except OSError: # cron file does not exist return False except: @@ -568,7 +568,7 @@ def main(): res_args = dict() # 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) module.debug('cron instantiated - name: "%s"' % name)