Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
c2b4cb75
Commit
c2b4cb75
authored
May 31, 2021
by
Dennis Gläser
Browse files
[bin][runcommand] outsource error hints
parent
87c384c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin/util/common.py
View file @
c2b4cb75
...
...
@@ -4,6 +4,14 @@ import functools
import
subprocess
def
getCommandErrorHints
(
command
):
if
"git "
in
command
:
return
"It seems that a git command failed. Please check:
\n
"
\
" -- is the module registered as git repository?
\n
"
\
" -- is upstream defined for the branch?"
return
None
# execute a command and retrieve the output
def
runCommand
(
command
,
suppressTraceBack
=
False
,
errorMessage
=
''
):
try
:
...
...
@@ -18,11 +26,9 @@ def runCommand(command, suppressTraceBack=False, errorMessage=''):
print
(
"-- command: {}"
.
format
(
command
))
print
(
"-- folder: {}"
.
format
(
os
.
getcwd
()))
print
(
"-- error: {}"
.
format
(
sys
.
exc_info
()[
1
]))
if
"git "
in
command
:
print
()
print
(
"It seems that a git command failed. Please check:
\n
"
" -- is the module registered as git repository?
\n
"
" -- is upstream defined for the branch?
\n
"
)
hints
=
getCommandErrorHints
(
command
)
if
hints
is
not
None
:
print
(
hints
)
raise
else
:
raise
Exception
(
errorMessage
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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