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
Lu Xu
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
Show 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
...
@@ -41,6 +41,32 @@ import subprocess
import
sys
import
sys
import
time
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
):
class
SlapError
(
Exception
):
"""
"""
...
@@ -944,6 +970,9 @@ class Config:
...
@@ -944,6 +970,9 @@ class Config:
def
main
():
def
main
():
"Run default configuration."
"Run default configuration."
global
os
global
callAndRead
real_callAndRead
=
callAndRead
usage
=
"usage: %s [options] CONFIGURATION_FILE"
%
sys
.
argv
[
0
]
usage
=
"usage: %s [options] CONFIGURATION_FILE"
%
sys
.
argv
[
0
]
try
:
try
:
...
@@ -951,6 +980,12 @@ def main():
...
@@ -951,6 +980,12 @@ def main():
options
,
configuration_file_path
=
Parser
(
usage
=
usage
).
check_args
()
options
,
configuration_file_path
=
Parser
(
usage
=
usage
).
check_args
()
config
=
Config
()
config
=
Config
()
config
.
setConfig
(
options
,
configuration_file_path
)
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
)
run
(
config
)
except
UsageError
,
err
:
except
UsageError
,
err
:
print
>>
sys
.
stderr
,
err
.
msg
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