Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions horde/horde.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,15 @@ def local_ip():

def hordemain():
if not os.path.exists(opts['hosts']) and opts['hostlist'] is False:
sys.exit('ERROR: hosts file "%s" does not exist' % opts['hosts'])

if opts['hosts']:
hosts = [line.strip() for line in sys.stdin]
elif opts['hosts']:
hosts = [line.strip() for line in open(opts['hosts'], 'r')]
# filter out comments and empty lines
hosts = [
host for host in hosts if not re.match("^#", host)
and host is not '']
else:
hosts = opts['hostlist'].split(',')
# filter out comments and empty lines
hosts = [host for host in hosts if not re.match("^#", host) and not host == '']
if len(hosts) == 0:
sys.exit('ERROR: No hosts provided.')
# handles duplicates
hosts = list(set(hosts))
log.info("Running with options: %s" % opts)
Expand Down