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:
setuptools
.
archive_util
.
unpack_archive
(
path
,
extract_dir
)
self
.
cleanup_dir_list
.
append
(
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
=
[]):
"""Recursively Copy directory. if "overwrite" is set to False, will stop if
destination already exists. ignore_dir_list is an array of directories
you want to exclude.
Example : copytree("/from", "/to", overwrite=True, ignore_dir_list=["a_private_dir"])
ignore_dir_list is a list of relative directories you want to exclude.
Example :
copytree("/from", "/to", ignore_dir_list=["a_private_dir"])
"""
if
os
.
path
.
exists
(
destination
)
and
not
overwrite
:
self
.
logger
.
info
(
'Destination already exists, aborting.'
)
return
False
# Check existence before beginning. We don't want to cleanup something
# that does not belong to us.
if
os
.
path
.
exists
(
destination
):
raise
shutil
.
Error
(
'Destination already exists: %s'
%
destination
)
self
.
logger
.
info
(
"Copying %s to %s"
%
(
origin
,
destination
))
if
ignore_dir_list
is
None
:
ignore_dir_list
=
[]
try
:
shutil
.
copytree
(
origin
,
destination
,
ignore
=
lambda
src
,
names
:
ignore_dir_list
)
except
shutil
.
Error
:
self
.
logger
.
error
(
"Error occurred : %s"
)
shutil
.
rmtree
(
destination
)
return
False
except
(
shutil
.
Error
,
OSError
)
as
error
:
# Cleanup in case of failure
try
:
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
script
=
'raise NotImplementedError'
def
__init__
(
self
,
buildout
,
name
,
options
):
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