From 565415d4bfb20a5127643115152e402255a4117b Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sun, 24 Mar 2019 10:49:35 -0700 Subject: [PATCH] code simplificatons in newcron (although deprecated), thanks Paolo Pastori --- gluon/newcron.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gluon/newcron.py b/gluon/newcron.py index c5a0119f..320af201 100644 --- a/gluon/newcron.py +++ b/gluon/newcron.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- """ @@ -279,8 +278,7 @@ class cronlauncher(threading.Thread): def crondance(applications_parent, ctype='soft', startup=False, apps=None): apppath = os.path.join(applications_parent, 'applications') - cron_path = os.path.join(applications_parent) - token = Token(cron_path) + token = Token(applications_parent) cronmaster = token.acquire(startup=startup) if not cronmaster: return @@ -314,9 +312,8 @@ def crondance(applications_parent, ctype='soft', startup=False, apps=None): if not os.path.exists(crontab): continue try: - cronlines = fileutils.readlines_file(crontab, 'rt') - lines = [x.strip() for x in cronlines if x.strip( - ) and not x.strip().startswith('#')] + cronlines = [line.strip() for line in fileutils.readlines_file(crontab, 'rt')] + lines = [line for line in cronlines if line and not line.startswith('#')] tasks = [parsecronline(cline) for cline in lines] except Exception as e: logger.error('WEB2PY CRON: crontab read error %s' % e)