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
Xavier Thompson
slapos.core
Commits
84191b93
Commit
84191b93
authored
Oct 28, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapformat: WIP: Rename raise_on_error into throw
parent
ccd58b6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
slapos/format.py
slapos/format.py
+7
-7
No files found.
slapos/format.py
View file @
84191b93
...
@@ -482,7 +482,7 @@ class User(object):
...
@@ -482,7 +482,7 @@ class User(object):
parameters
.
append
(
self
.
name
)
parameters
.
append
(
self
.
name
)
if
self
.
userExists
(
self
.
name
):
if
self
.
userExists
(
self
.
name
):
# if the user is already created and used we should not fail
# if the user is already created and used we should not fail
call
([
'usermod'
]
+
parameters
,
raise_on_error
=
False
)
call
([
'usermod'
]
+
parameters
,
throw
=
False
)
else
:
else
:
parameters
.
append
(
'-r'
)
parameters
.
append
(
'-r'
)
call
([
'useradd'
]
+
parameters
)
call
([
'useradd'
]
+
parameters
)
...
@@ -512,7 +512,7 @@ class User(object):
...
@@ -512,7 +512,7 @@ class User(object):
# Utilities
# Utilities
def
call
(
args
,
raise_on_error
=
True
):
def
call
(
args
,
throw
=
True
):
popen
=
subprocess
.
Popen
(
popen
=
subprocess
.
Popen
(
args
,
args
,
stdout
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
...
@@ -520,7 +520,7 @@ def call(args, raise_on_error=True):
...
@@ -520,7 +520,7 @@ def call(args, raise_on_error=True):
universal_newlines
=
True
,
universal_newlines
=
True
,
)
)
result
=
popen
.
communicate
()[
0
]
result
=
popen
.
communicate
()[
0
]
if
raise_on_error
and
popen
.
returncode
!=
0
:
if
throw
and
popen
.
returncode
!=
0
:
raise
ValueError
(
raise
ValueError
(
"Issue while invoking %r, result was:
\
n
%s"
%
(
args
,
result
)
"Issue while invoking %r, result was:
\
n
%s"
%
(
args
,
result
)
)
)
...
@@ -591,17 +591,17 @@ class WrappedSystem(object):
...
@@ -591,17 +591,17 @@ class WrappedSystem(object):
)
)
if
conf
.
dry_run
:
if
conf
.
dry_run
:
conf
.
abort
=
conf
.
dryError
conf
.
abort
=
conf
.
dryError
def
dry_call
(
args
,
raise_on_error
=
True
):
def
dry_call
(
args
,
throw
=
True
):
conf
.
logger
.
debug
(
' '
.
join
(
args
))
conf
.
logger
.
debug
(
' '
.
join
(
args
))
it
=
iter
(
args
)
it
=
iter
(
args
)
if
all
(
w
in
it
for
w
in
(
'ip'
,
'addr'
,
'show'
)):
# subsequence test
if
all
(
w
in
it
for
w
in
(
'ip'
,
'addr'
,
'show'
)):
# subsequence test
return
self
.
call
(
args
,
raise_on_error
=
False
)
return
self
.
call
(
args
,
throw
=
False
)
return
0
,
''
return
0
,
''
call
=
dry_call
call
=
dry_call
else
:
else
:
def
tracing_call
(
args
,
raise_on_error
=
True
):
def
tracing_call
(
args
,
throw
=
True
):
conf
.
logger
.
debug
(
' '
.
join
(
args
))
conf
.
logger
.
debug
(
' '
.
join
(
args
))
return
self
.
call
(
args
,
raise_on_error
)
return
self
.
call
(
args
,
throw
)
call
=
tracing_call
call
=
tracing_call
def
__exit__
(
self
,
*
exc
):
def
__exit__
(
self
,
*
exc
):
...
...
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