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
Łukasz Nowak
slapos.buildout
Commits
0d5c1c7a
Commit
0d5c1c7a
authored
Jun 17, 2011
by
Lucas Carvalho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
following last modification on libnetworkcache.
the behavior still the same.
parent
08aa5cab
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
src/zc/buildout/networkcache.py
src/zc/buildout/networkcache.py
+17
-11
No files found.
src/zc/buildout/networkcache.py
View file @
0d5c1c7a
...
@@ -21,7 +21,7 @@ import urllib
...
@@ -21,7 +21,7 @@ import urllib
import
urlparse
import
urlparse
from
download
import
check_md5sum
from
download
import
check_md5sum
from
slapos.libnetworkcache
import
NetworkcacheClient
,
UploadError
,
\
from
slapos.libnetworkcache
import
NetworkcacheClient
,
UploadError
,
\
MultipleFileFoundError
,
DirectoryNotFound
DirectoryNotFound
_md5_re
=
re
.
compile
(
r'md5=([a-f0-9]+)'
)
_md5_re
=
re
.
compile
(
r'md5=([a-f0-9]+)'
)
...
@@ -81,21 +81,27 @@ def download_network_cached(sha_dir, sha_cache, path, url, logger, md5sum=None):
...
@@ -81,21 +81,27 @@ def download_network_cached(sha_dir, sha_cache, path, url, logger, md5sum=None):
md5sum
=
_get_md5_from_url
(
url
)
md5sum
=
_get_md5_from_url
(
url
)
sha512sum
=
select_sha512sum_from_shadir
(
sha_dir
,
url
,
logger
)
directory_key
=
get_directory_key
(
url
)
if
sha512sum
is
None
:
file_name
=
os
.
path
.
basename
(
url
)
return
False
logger
.
info
(
'Downloading %s from network cache.'
%
file_name
)
try
:
nc
=
NetworkcacheClient
(
shacache
=
sha_cache
,
shadir
=
sha_dir
)
file_content
=
nc
.
select
(
directory_key
)
sha_cache_url
=
os
.
path
.
join
(
sha_cache
,
sha512sum
)
f
=
open
(
path
,
'w+b'
)
logger
.
info
(
'Downloading from network cache %s'
%
sha_cache_url
)
try
:
try
:
nc
=
NetworkcacheClient
(
shacache
=
sha_cache
)
f
.
write
(
file_content
)
nc
.
download
(
path
,
sha512sum
)
finally
:
f
.
close
()
if
not
check_md5sum
(
path
,
md5sum
):
if
not
check_md5sum
(
path
,
md5sum
):
logger
.
info
(
'MD5 checksum mismatch downloading %
r'
%
sha_cache_url
)
logger
.
info
(
'MD5 checksum mismatch downloading %
s'
%
file_name
)
return
False
return
False
except
IOError
,
e
:
except
(
IOError
,
DirectoryNotFound
),
e
:
logger
.
info
(
'Fail to download from network cache %s: %s'
%
\
logger
.
info
(
'Fail to download from network cache %s: %s'
%
\
(
sha_cache_url
,
str
(
e
)))
(
file_name
,
str
(
e
)))
return
False
return
False
return
True
return
True
...
...
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