Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
slapos.core
Commits
ac29c88d
Commit
ac29c88d
authored
May 31, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle exceptions without --debug
parent
37ba1f8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
19 deletions
+32
-19
slapos/cli/entry.py
slapos/cli/entry.py
+32
-19
No files found.
slapos/cli/entry.py
View file @
ac29c88d
...
...
@@ -79,9 +79,6 @@ class SlapOSApp(cliff.app.App):
help
=
'Specify a file to log output (default: console only)'
,
)
# always show tracebacks on errors
parser
.
set_defaults
(
debug
=
True
)
return
parser
def
initialize_app
(
self
,
argv
):
...
...
@@ -96,37 +93,53 @@ class SlapOSApp(cliff.app.App):
if
self
.
options
.
verbose_level
>
2
:
self
.
log
.
debug
(
'clean_up %s'
,
cmd
.
__class__
.
__name__
)
if
err
:
self
.
log
.
debug
(
'got an error: %s'
,
err
)
def
run
(
self
,
argv
):
# same as cliff.App.run except that it won't re-raise
# a logged exception
# a logged exception
, and doesn't use --debug
try
:
self
.
options
,
remainder
=
self
.
parser
.
parse_known_args
(
argv
)
self
.
configure_logging
()
self
.
interactive_mode
=
not
remainder
self
.
initialize_app
(
remainder
)
except
Exception
as
err
:
if
hasattr
(
self
,
'options'
):
debug
=
self
.
options
.
debug
else
:
debug
=
True
if
debug
:
LOG
.
exception
(
err
)
# XXX change from cliff behaviour: avoid
# displaying the exception twice
# raise
else
:
LOG
.
error
(
err
)
LOG
.
exception
(
err
)
return
1
result
=
1
if
self
.
interactive_mode
:
result
=
self
.
interact
()
else
:
result
=
self
.
run_subcommand
(
remainder
)
return
result
def
run_subcommand
(
self
,
argv
):
# same as cliff.App.run_subcommand except that it won't re-raise
# a logged exception, and doesn't use --debug
subcommand
=
self
.
command_manager
.
find_command
(
argv
)
cmd_factory
,
cmd_name
,
sub_argv
=
subcommand
cmd
=
cmd_factory
(
self
,
self
.
options
)
err
=
None
result
=
1
try
:
self
.
prepare_to_run_command
(
cmd
)
full_name
=
(
cmd_name
if
self
.
interactive_mode
else
' '
.
join
([
self
.
NAME
,
cmd_name
])
)
cmd_parser
=
cmd
.
get_parser
(
full_name
)
parsed_args
=
cmd_parser
.
parse_args
(
sub_argv
)
result
=
cmd
.
run
(
parsed_args
)
except
Exception
as
err
:
LOG
.
exception
(
err
)
try
:
self
.
clean_up
(
cmd
,
result
,
err
)
except
Exception
as
err2
:
LOG
.
exception
(
err2
)
else
:
try
:
self
.
clean_up
(
cmd
,
result
,
None
)
except
Exception
as
err3
:
LOG
.
exception
(
err3
)
return
result
def
main
(
argv
=
sys
.
argv
[
1
:]):
app
=
SlapOSApp
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment