Commit e55c2054 authored by Marco Mariani's avatar Marco Mariani

print to stderr instead of exception

parent 1fbd79a6
...@@ -55,8 +55,6 @@ USER_SLAPOS_CONFIGURATION = os.environ.get( ...@@ -55,8 +55,6 @@ USER_SLAPOS_CONFIGURATION = os.environ.get(
'SLAPOS_CLIENT_CONFIGURATION', 'SLAPOS_CLIENT_CONFIGURATION',
os.environ.get('SLAPOS_CONFIGURATION', '~/.slapos/slapos.cfg')) os.environ.get('SLAPOS_CONFIGURATION', '~/.slapos/slapos.cfg'))
class UsageError(Exception):
pass
class EntryPointNotImplementedError(NotImplementedError): class EntryPointNotImplementedError(NotImplementedError):
def __init__(self, *args, **kw_args): def __init__(self, *args, **kw_args):
...@@ -119,9 +117,9 @@ def dispatch(command, is_node_command): ...@@ -119,9 +117,9 @@ def dispatch(command, is_node_command):
""" """
if is_node_command: if is_node_command:
# check root
if os.getuid() != 0: if os.getuid() != 0:
raise UsageError('Root rights are needed') sys.stderr.write('This command must be run as root.\n')
sys.exit()
if command == 'register': if command == 'register':
call(register) call(register)
......
...@@ -1241,7 +1241,8 @@ class Config(object): ...@@ -1241,7 +1241,8 @@ class Config(object):
if root_needed and os.getuid() != 0: if root_needed and os.getuid() != 0:
message = "Root rights are needed" message = "Root rights are needed"
self.logger.error(message) self.logger.error(message)
raise UsageError(message) sys.stderr.write(message+'\n')
sys.exit()
if self.log_file: if self.log_file:
if not os.path.isdir(os.path.dirname(self.log_file)): if not os.path.isdir(os.path.dirname(self.log_file)):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment