Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Lisa Casino
slapos
Commits
ba6d6b0b
Commit
ba6d6b0b
authored
Feb 21, 2013
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add download helper function in librecipe.
Simple wrapper around h.r.download
parent
95ba7554
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
slapos/recipe/librecipe/generic.py
slapos/recipe/librecipe/generic.py
+34
-4
No files found.
slapos/recipe/librecipe/generic.py
View file @
ba6d6b0b
...
...
@@ -32,6 +32,7 @@ import os
import
sys
import
inspect
import
re
import
shutil
import
urllib
import
urlparse
...
...
@@ -55,16 +56,16 @@ class GenericBaseRecipe(object):
self
.
buildout
=
buildout
self
.
logger
=
logging
.
getLogger
(
name
)
if
not
options
.
get
(
'location'
):
options
[
'location'
]
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'parts-directory'
],
self
.
name
)
self
.
options
=
options
.
copy
()
# If _options use self.optionIsTrue
self
.
_options
(
options
)
# Options Hook
self
.
options
=
options
.
copy
()
# Updated options dict
self
.
_ws
=
self
.
getWorkingSet
()
if
not
options
.
get
(
'location'
):
options
[
'location'
]
=
os
.
path
.
join
(
buildout
[
'buildout'
][
'parts-directory'
],
self
.
name
)
def
update
(
self
):
"""By default update method does the same thing than install"""
return
self
.
install
()
...
...
@@ -230,3 +231,32 @@ class GenericBaseRecipe(object):
url
=
urlparse
.
urlunparse
((
scheme
,
netloc
,
path
,
params
,
query
,
fragment
))
return
url
def
download
(
self
,
destination
=
None
):
""" A simple wrapper around h.r.download, downloading to self.location"""
# F.ck that buildout1 dependency system.
# XXX-Cedric: FIX THAT UGLY THING.
import
sys
sys
.
path
[
0
:
0
]
=
[
os
.
path
.
join
(
self
.
buildout
[
'buildout'
][
'eggs-directory'
],
'hexagonit.recipe.download-1.6-py2.7.egg'
)]
import
hexagonit.recipe.download
if
not
destination
:
destination
=
self
.
location
try
:
os
.
mkdir
(
destination
)
except
OSError
,
e
:
# XXX-Cedric: improve error handling
# leftovers from a previous failed attempt,
# download recipe will raise a clean error message
if
e
.
errno
!=
errno
.
EEXIST
:
raise
try
:
options
=
self
.
options
.
copy
()
options
[
'destination'
]
=
destination
hexagonit
.
recipe
.
download
.
Recipe
(
self
.
buildout
,
self
.
name
,
options
).
install
()
except
:
shutil
.
rmtree
(
destination
)
raise
\ No newline at end of file
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