ttm: Allow to run in daemon mode without stdin attached

When running as a systemd daemon, it is useless to wait for user input
to possible trigger an earlier re-run. Interaction is not possible.

Additionally, there is no stdin assigned to the process when running as
a systemd daemon, which results in raw_input() failing with EOFError
This commit is contained in:
Dominique Leuenberger 2017-01-26 17:05:21 +01:00
parent 95e5a75a0e
commit 331903b74b
Signed by untrusted user: dimstar
GPG Key ID: E69F22089B497C99

View File

@ -16,6 +16,7 @@ import sys
import urllib2
import logging
import signal
import time
from xml.etree import cElementTree as ET
@ -600,6 +601,7 @@ class CommandlineInterface(cmdln.Cmdln):
logger.error(e)
if opts.interval:
if os.isatty(0):
logger.info("sleeping %d minutes. Press enter to check now ..."%opts.interval)
signal.alarm(opts.interval*60)
try:
@ -609,6 +611,9 @@ class CommandlineInterface(cmdln.Cmdln):
signal.alarm(0)
logger.info("recheck at %s"%datetime.datetime.now().isoformat())
continue
else:
logger.info("sleeping %d minutes."%opts.interval)
time.sleep(opts.interval*60)
break
def do_release(self, subcmd, opts, project = 'Factory'):