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.build
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
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.recipe.build
Commits
3a48320e
Commit
3a48320e
authored
Aug 26, 2011
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Luke review : add try/catch and be safer, documentation, follow conventions
parent
ed24d550
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
slapos/recipe/build.py
slapos/recipe/build.py
+20
-13
No files found.
slapos/recipe/build.py
View file @
3a48320e
...
@@ -163,26 +163,33 @@ class Script:
...
@@ -163,26 +163,33 @@ class Script:
setuptools
.
archive_util
.
unpack_archive
(
path
,
extract_dir
)
setuptools
.
archive_util
.
unpack_archive
(
path
,
extract_dir
)
self
.
cleanup_dir_list
.
append
(
extract_dir
)
self
.
cleanup_dir_list
.
append
(
extract_dir
)
return
extract_dir
return
extract_dir
def
copyTree
(
self
,
origin
,
destination
,
ignore_dir_list
=
None
):
"""Recursively Copy directory.
def
copytree
(
self
,
origin
,
destination
,
overwrite
=
False
,
ignore_dir_list
=
[]):
ignore_dir_list is a list of relative directories you want to exclude.
"""Recursively Copy directory. if "overwrite" is set to False, will stop if
Example :
destination already exists. ignore_dir_list is an array of directories
copytree("/from", "/to", ignore_dir_list=["a_private_dir"])
you want to exclude.
Example : copytree("/from", "/to", overwrite=True, ignore_dir_list=["a_private_dir"])
"""
"""
if
os
.
path
.
exists
(
destination
)
and
not
overwrite
:
# Check existence before beginning. We don't want to cleanup something
self
.
logger
.
info
(
'Destination already exists, aborting.'
)
# that does not belong to us.
return
False
if
os
.
path
.
exists
(
destination
):
raise
shutil
.
Error
(
'Destination already exists: %s'
%
destination
)
self
.
logger
.
info
(
"Copying %s to %s"
%
(
origin
,
destination
))
self
.
logger
.
info
(
"Copying %s to %s"
%
(
origin
,
destination
))
if
ignore_dir_list
is
None
:
ignore_dir_list
=
[]
try
:
try
:
shutil
.
copytree
(
origin
,
destination
,
shutil
.
copytree
(
origin
,
destination
,
ignore
=
lambda
src
,
names
:
ignore_dir_list
)
ignore
=
lambda
src
,
names
:
ignore_dir_list
)
except
shutil
.
Error
:
except
(
shutil
.
Error
,
OSError
)
as
error
:
self
.
logger
.
error
(
"Error occurred : %s"
)
# Cleanup in case of failure
shutil
.
rmtree
(
destination
)
try
:
return
False
shutil
.
rmtree
(
destination
,
ignore_errors
=
True
)
except
(
shutil
.
Error
,
OSError
),
strerror
:
self
.
logger
.
error
(
"Error occurred when cleaning after error: %s"
,
strerror
)
raise
error
return
True
return
True
script
=
'raise NotImplementedError'
script
=
'raise NotImplementedError'
def
__init__
(
self
,
buildout
,
name
,
options
):
def
__init__
(
self
,
buildout
,
name
,
options
):
self
.
cleanup_dir_list
=
[]
self
.
cleanup_dir_list
=
[]
...
...
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