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
Xavier Thompson
slapos.buildout
Commits
3671cc41
Commit
3671cc41
authored
Oct 18, 2015
by
Kazuhiko Shiozaki
Committed by
Xavier Thompson
Mar 13, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[feat] Support network cache in Download.download()
parent
2a7cd7f6
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
361 additions
and
4 deletions
+361
-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
+308
-0
No files found.
src/zc/buildout/buildout.py
View file @
3671cc41
...
...
@@ -324,6 +324,9 @@ def _get_user_config():
return
os
.
path
.
join
(
buildout_home
,
'default.cfg'
)
network_cache_parameter_dict
=
{}
@
commands
class
Buildout
(
DictMixin
):
...
...
@@ -576,6 +579,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 @
3671cc41
...
...
@@ -199,10 +199,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
)
...
...
@@ -271,6 +290,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 @
3671cc41
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