get cron to shut the hell up. too. many. emails.

This commit is contained in:
brent s 2017-09-15 09:56:11 -04:00
parent 30f508f40c
commit 130074788a

View File

@ -6,6 +6,7 @@ import datetime
import os import os
import pprint import pprint
import subprocess import subprocess
import sys


cfgfile = os.path.join(os.environ['HOME'], '.arch.repoclone.ini') cfgfile = os.path.join(os.environ['HOME'], '.arch.repoclone.ini')


@ -49,7 +50,11 @@ def sync(args):
if os.path.isfile(args['lockfile']): if os.path.isfile(args['lockfile']):
with open(args['lockfile'], 'r') as f: with open(args['lockfile'], 'r') as f:
existingpid = f.read().strip() existingpid = f.read().strip()
exit('!! A repo synchronization seems to already be running (PID: {0}). Quitting. !!'.format(existingpid)) if os.isatty(sys.stdin.fileno()):
# Running from shell
exit('!! A repo synchronization seems to already be running (PID: {0}). Quitting. !!'.format(existingpid))
else:
exit() # we're running in cron, shut the hell up.
else: else:
with open(args['lockfile'], 'w') as f: with open(args['lockfile'], 'w') as f:
f.write(str(os.getpid())) f.write(str(os.getpid()))