Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.cmmi
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.recipe.cmmi
Commits
dfb24fa1
Commit
dfb24fa1
authored
Jun 18, 2013
by
Thomas Larrieu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished implementing cleanup feature. still have to implement testing for this.
parent
f5d260a2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
179 additions
and
147 deletions
+179
-147
slapos/recipe/cmmi/__init__.py
slapos/recipe/cmmi/__init__.py
+179
-147
No files found.
slapos/recipe/cmmi/__init__.py
View file @
dfb24fa1
...
@@ -228,6 +228,48 @@ class Recipe(object):
...
@@ -228,6 +228,48 @@ class Recipe(object):
log
.
error
(
'Command failed: %s: %s'
%
(
e
,
cmd
))
log
.
error
(
'Command failed: %s: %s'
%
(
e
,
cmd
))
raise
zc
.
buildout
.
UserError
(
'System error'
)
raise
zc
.
buildout
.
UserError
(
'System error'
)
def
clean
(
self
,
cleanup_list
):
"""
Basically, this method does not do much, appart from removing
what it is told to, as a list passed in args
"""
import
glob
def
build_working_iterator
(
cleanup_list
):
current_dir
=
os
.
getcwd
()
for
pattern
in
cleanup_list
:
# if current pattern contains wildcards, we search for all matching
# files/directories
if
pattern
.
find
(
'*'
)
>
-
1
or
pattern
.
find
(
'?'
)
>
-
1
or
pattern
.
find
(
'['
)
>
-
1
:
g
=
glob
.
glob
(
pattern
)
if
g
:
for
x
in
g
:
yield
x
else
:
raise
IOError
(
"Pattern "
+
pattern
+
" did not match anything"
)
elif
os
.
path
.
exists
(
pattern
):
if
os
.
path
.
relpath
(
pattern
).
startswith
(
'..'
):
raise
IOError
(
current_dir
+
" does not contain "
+
pattern
)
else
:
yield
pattern
else
:
raise
IOError
(
pattern
+
" does not exist"
)
# As build_working_iterator is a generator and since we want to first
# check every file (raising exceptions when necessary) BEFORE removing
# anything from the file system, we enforce full lookup by build a tuple
# out of it
for
x
in
tuple
(
build_working_iterator
(
cleanup_list
)):
# This first condition is mandatory as we might have removed an entire
# tree during a previous iteration, possibly leading to a case where
# some items are still to be removed but do not exist anymore
if
os
.
path
.
exists
(
x
):
if
os
.
path
.
isdir
(
x
):
shutil
.
rmtree
(
x
)
else
:
os
.
remove
(
x
)
logging
.
getLogger
(
self
.
name
).
info
(
'%s has been successfully removed'
,
x
)
def
install
(
self
):
def
install
(
self
):
log
=
logging
.
getLogger
(
self
.
name
)
log
=
logging
.
getLogger
(
self
.
name
)
parts
=
[]
parts
=
[]
...
@@ -370,15 +412,5 @@ class Recipe(object):
...
@@ -370,15 +412,5 @@ class Recipe(object):
# Cleanup state
# Cleanup state
cleanup_list
=
self
.
options
.
get
(
'cleanup'
,
''
).
split
()
cleanup_list
=
self
.
options
.
get
(
'cleanup'
,
''
).
split
()
self
.
clean
(
cleanup_list
)
self
.
clean
(
cleanup_list
)
return
parts
return
parts
def
clean
(
self
,
cleanup_list
):
"""
Basically, this method does not do much, appart from removing
what it is told to, as a list passed in args
"""
current_dir
=
os
.
getcwd
()
for
i
,
directory
in
enumerate
(
cleanup_list
):
print
str
(
i
)
+
"->"
+
directory
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