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
1 changed files with 6 additions and 1 deletions

View File

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

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

@ -49,7 +50,11 @@ def sync(args):
if os.path.isfile(args['lockfile']):
with open(args['lockfile'], 'r') as f:
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:
with open(args['lockfile'], 'w') as f:
f.write(str(os.getpid()))