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
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Rafael Monnerat
slapos.core
Commits
050aadbe
Commit
050aadbe
authored
Jun 14, 2011
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increase verbosity.
Output system commands and system-altering functions from python's os module.
parent
18e7b0f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
slapos/format/__init__.py
slapos/format/__init__.py
+35
-0
No files found.
slapos/format/__init__.py
View file @
050aadbe
...
...
@@ -41,6 +41,32 @@ import subprocess
import
sys
import
time
class
OS
(
object
):
_os
=
os
def
__init__
(
self
,
config
):
self
.
_verbose
=
config
.
verbose
self
.
_logger
=
config
.
logger
add
=
self
.
_addWrapper
add
(
'chown'
)
add
(
'chmod'
)
add
(
'makedirs'
)
add
(
'mkdir'
)
def
_addWrapper
(
self
,
name
):
def
wrapper
(
*
args
,
**
kw
):
if
self
.
_verbose
:
arg_list
=
[
repr
(
x
)
for
x
in
args
]
+
[
'%s=%r'
%
(
x
,
y
)
for
x
,
y
in
kw
.
iteritems
()]
self
.
_logger
.
debug
(
'%s(%s)'
%
(
name
,
', '
.
join
(
arg_list
)
))
getattr
(
self
.
_os
,
name
)(
*
args
,
**
kw
)
setattr
(
self
,
name
,
wrapper
)
def
__getattr__
(
self
,
name
):
return
getattr
(
self
.
_os
,
name
)
class
SlapError
(
Exception
):
"""
...
...
@@ -944,6 +970,9 @@ class Config:
def
main
():
"Run default configuration."
global
os
global
callAndRead
real_callAndRead
=
callAndRead
usage
=
"usage: %s [options] CONFIGURATION_FILE"
%
sys
.
argv
[
0
]
try
:
...
...
@@ -951,6 +980,12 @@ def main():
options
,
configuration_file_path
=
Parser
(
usage
=
usage
).
check_args
()
config
=
Config
()
config
.
setConfig
(
options
,
configuration_file_path
)
os
=
OS
(
config
)
if
config
.
verbose
:
def
logging_callAndRead
(
argument_list
,
raise_on_error
=
True
):
config
.
logger
.
debug
(
' '
.
join
(
argument_list
))
return
real_callAndRead
(
argument_list
,
raise_on_error
)
callAndRead
=
logging_callAndRead
run
(
config
)
except
UsageError
,
err
:
print
>>
sys
.
stderr
,
err
.
msg
...
...
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