diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-04-11 20:51:09 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-04-11 20:51:09 +0100 |
commit | 4deef2283ce371e0c5e4e3360617e1890dee9cac (patch) | |
tree | aeb079a334171e5c33e8d2adfd73e064e094e953 /desktop-cronish | |
parent | bcdbf46c8ec8f3daf60550c059693595cc4cff79 (diff) | |
download | desktop-cronish-4deef2283ce371e0c5e4e3360617e1890dee9cac.tar.gz |
Add logging
Diffstat (limited to 'desktop-cronish')
-rwxr-xr-x | desktop-cronish | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/desktop-cronish b/desktop-cronish index 738d29c..713f135 100755 --- a/desktop-cronish +++ b/desktop-cronish @@ -16,6 +16,7 @@ import cliapp +import logging import time import sys import yaml @@ -40,6 +41,7 @@ class DesktopCronish(cliapp.Application): self.execute_jobs() def process_input(self, filename): + logging.info('Loading jobs from %s' % filename) with self.open_input(filename, 'r') as f: job_dict = yaml.safe_load(f) self.jobs.update(job_dict) @@ -52,6 +54,7 @@ class DesktopCronish(cliapp.Application): self.wait_until(when) self.execute_job(job_name) n += 1 + logging.info('Stopped executing after %d jobs' % n) def choose_job(self): next_job_name = None @@ -65,10 +68,13 @@ class DesktopCronish(cliapp.Application): def wait_until(self, when): while self.now() < when: - time.sleep(when - self.now()) + seconds = when - self.now() + logging.info('Sleeping for %d seconds' % seconds) + time.sleep(seconds) def execute_job(self, job_name): job = self.jobs[job_name] + logging.info('Executing job %s: %s' % (job_name, job['command'])) argv = ['sh', '-c', job['command']] if 'timeout' in job: argv = ['timeout', str(job['timeout'])] + argv @@ -84,4 +90,5 @@ class DesktopCronish(cliapp.Application): def now(self): return time.time() + DesktopCronish(version=__version__).run() |