Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.buildout
Commits
dc81c018
Commit
dc81c018
authored
Oct 18, 2015
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support network cache in Download.download().
parent
1947c1c9
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
369 additions
and
4 deletions
+369
-4
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+28
-0
src/zc/buildout/download.py
src/zc/buildout/download.py
+25
-4
src/zc/buildout/networkcache.py
src/zc/buildout/networkcache.py
+316
-0
No files found.
src/zc/buildout/buildout.py
View file @
dc81c018
...
...
@@ -175,6 +175,9 @@ class Buildout(DictMixin):
__doing__
=
'Initializing.'
global
network_cache_parameter_dict
network_cache_parameter_dict
=
{}
# default options
data
=
dict
(
buildout
=
_buildout_default_options
.
copy
())
self
.
_buildout_dir
=
os
.
getcwd
()
...
...
@@ -417,6 +420,31 @@ class Buildout(DictMixin):
os
.
chdir
(
options
[
'directory'
])
networkcache_section_name
=
options
.
get
(
'networkcache-section'
)
if
networkcache_section_name
:
networkcache_section
=
self
[
networkcache_section_name
]
for
k
in
(
'download-cache-url'
,
'download-dir-url'
,
'upload-cache-url'
,
'upload-dir-url'
,
'signature-certificate-list'
,
'signature-private-key-file'
,
'shacache-ca-file'
,
'shacache-cert-file'
,
'shacache-key-file'
,
'shadir-ca-file'
,
'shadir-cert-file'
,
'shadir-key-file'
,
):
network_cache_parameter_dict
[
k
]
=
networkcache_section
.
get
(
k
,
''
)
# parse signature list
cert_marker
=
'-----BEGIN CERTIFICATE-----'
network_cache_parameter_dict
[
'signature-certificate-list'
]
=
\
[
cert_marker
+
'
\
n
'
+
q
.
strip
()
\
for
q
in
network_cache_parameter_dict
[
'signature-certificate-list'
].
split
(
cert_marker
)
\
if
q
.
strip
()]
def
_buildout_path
(
self
,
name
):
if
'${'
in
name
:
return
name
...
...
src/zc/buildout/download.py
View file @
dc81c018
...
...
@@ -193,10 +193,29 @@ class Download(object):
handle
,
tmp_path
=
tempfile
.
mkstemp
(
prefix
=
'buildout-'
)
os
.
close
(
handle
)
try
:
tmp_path
,
headers
=
urlretrieve
(
url
,
tmp_path
)
if
not
check_md5sum
(
tmp_path
,
md5sum
):
raise
ChecksumError
(
'MD5 checksum mismatch downloading %r'
%
url
)
from
.buildout
import
network_cache_parameter_dict
as
nc
if
not
download_network_cached
(
nc
.
get
(
'download-dir-url'
),
nc
.
get
(
'download-cache-url'
),
tmp_path
,
url
,
self
.
logger
,
nc
.
get
(
'signature-certificate-list'
),
md5sum
):
# Download from original url if not cached or md5sum doesn't match.
tmp_path
,
headers
=
urlretrieve
(
url
,
tmp_path
)
if
not
check_md5sum
(
tmp_path
,
md5sum
):
raise
ChecksumError
(
'MD5 checksum mismatch downloading %r'
%
url
)
# Upload the file to network cache.
if
nc
.
get
(
'upload-cache-url'
)
and
nc
.
get
(
'upload-dir-url'
):
upload_network_cached
(
nc
.
get
(
'upload-dir-url'
),
nc
.
get
(
'upload-cache-url'
),
url
,
tmp_path
,
self
.
logger
,
nc
.
get
(
'signature-private-key-file'
),
nc
.
get
(
'shacache-ca-file'
),
nc
.
get
(
'shacache-cert-file'
),
nc
.
get
(
'shacache-key-file'
),
nc
.
get
(
'shadir-ca-file'
),
nc
.
get
(
'shadir-cert-file'
),
nc
.
get
(
'shadir-key-file'
))
except
IOError
:
e
=
sys
.
exc_info
()[
1
]
os
.
remove
(
tmp_path
)
...
...
@@ -265,6 +284,8 @@ def remove(path):
if
os
.
path
.
exists
(
path
):
os
.
remove
(
path
)
from
zc.buildout.networkcache
import
download_network_cached
,
\
upload_network_cached
def
locate_at
(
source
,
dest
):
if
dest
is
None
or
realpath
(
dest
)
==
realpath
(
source
):
...
...
src/zc/buildout/networkcache.py
0 → 100644
View file @
dc81c018
This diff is collapsed.
Click to expand it.
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