Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
missed a file check in.
Browse files Browse the repository at this point in the history
  • Loading branch information
chambridge committed Jun 16, 2017
1 parent bf5a2da commit 20e7c15
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions rho/clicommands.py
Expand Up @@ -25,6 +25,7 @@
from optparse import OptionParser
from getpass import getpass
import gettext
from __future__ import print_function

t = gettext.translation('rho', 'locale', fallback=True)
_ = t.ugettext
Expand Down Expand Up @@ -107,8 +108,8 @@ def _check_range_validity(range_list):
match = True
if not match:
if len(r) <= 1:
print _("No such hosts file.")
print _("Bad host name/range : '%s'") % r
print("No such hosts file.")
print("Bad host name/range : '%s'") % r
sys.exit(1)


Expand All @@ -131,7 +132,7 @@ def _edit_playbook(facts, report_path):
" set_fact:\n fact_list:\n"
string_to_write = _stringify_facts(string_to_write, facts)
elif not facts == ['default']:
print _("facts can be a file, list or 'default' only")
print("facts can be a file, list or 'default' only")
sys.exit(1)

with open('roles/collect/tasks/main.yml', 'w') as f:
Expand Down Expand Up @@ -415,28 +416,28 @@ def _validate_options(self):
CliCommand._validate_options(self)

if not self.options.profile:
print _("No profile specified.")
print("No profile specified.")
self.parser.print_help()
sys.exit(1)

if not self.options.facts:
print _("No facts specified.")
print("No facts specified.")
self.parser.print_help()
sys.exit(1)

if not self.options.report_path:
print _("No report location specified.")
print("No report location specified.")
self.parser.print_help()
sys.exit(1)

if self.options.ansible_forks:
try:
if int(self.options.ansible_forks) <= 0:
print _("ansible_forks can only be a positive integer.")
print("ansible_forks can only be a positive integer.")
self.parser.print_help()
sys.exit(1)
except ValueError:
print _("ansible_forks can only be a positive integer.")
print("ansible_forks can only be a positive integer.")
self.parser.print_help()
sys.exit(1)

Expand Down Expand Up @@ -478,7 +479,7 @@ def _do_command(self):
break

if not profile_exists:
print _("Invalid profile. Create profile first")
print("Invalid profile. Create profile first")
sys.exit(1)

_edit_playbook(facts, report_path)
Expand All @@ -494,7 +495,7 @@ def _do_command(self):
forks)

if not len(success_auths):
print _('All auths are invalid for this profile')
print('All auths are invalid for this profile')
sys.exit(1)

_create_hosts_auths_file(success_map, profile)
Expand All @@ -517,7 +518,7 @@ def _do_command(self):

process.communicate()

print _("Scanning has completed. The mapping has been"
print("Scanning has completed. The mapping has been"
" stored in file '" + self.options.profile +
"_host_auth_map'. The"
" facts have been stored in '" +
Expand Down Expand Up @@ -622,7 +623,7 @@ def _validate_options(self):
sys.exit(1)

if not self.options.hosts and not self.options.auth:
print _("Specify either hosts or auths to update.")
print("Specify either hosts or auths to update.")
self.parser.print_help()
sys.exit(1)

Expand Down Expand Up @@ -698,7 +699,7 @@ def _do_command(self):
f.write(line_string + '\n')

if not auth_exists:
print _("Auths do not exist.")
print("Auths do not exist.")
sys.exit(1)

if not profile_exists:
Expand Down Expand Up @@ -874,7 +875,7 @@ def _do_command(self):
cred_names.append(line_list[1])

if not valid:
print _("Auth '%s' does not exist") % a
print("Auth '%s' does not exist") % a
sys.exit(1)

with open('data/profiles', 'a') as f:
Expand Down Expand Up @@ -928,7 +929,7 @@ def _validate_options(self):
if not (self.options.filename or
self.options.username or
self.options.password):
print _("Should specify an option to update:"
print("Should specify an option to update:"
" --username, --password or --filename")
sys.exit(1)

Expand Down Expand Up @@ -1063,7 +1064,7 @@ def _do_command(self):
', ' + line_list[4]

if not auth_exists:
print _('Auth "%s" does not exist' % self.options.name)
print('Auth "%s" does not exist' % self.options.name)
sys.exit(1)


Expand All @@ -1082,7 +1083,7 @@ def __init__(self):

def _do_command(self):
if not os.path.isfile('data/credentials'):
print _('No credentials exist yet.')
print('No credentials exist yet.')
sys.exit(1)

with open('data/credentials', 'r') as f:
Expand Down

0 comments on commit 20e7c15

Please sign in to comment.