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
6
Merge Requests
6
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.buildout
Commits
f18c3b61
Commit
f18c3b61
authored
Jan 19, 2012
by
Yingjie Xu
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Uses binary cache.
parent
4b01f2ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
9 deletions
+29
-9
src/zc/buildout/networkcache.py
src/zc/buildout/networkcache.py
+29
-9
No files found.
src/zc/buildout/networkcache.py
View file @
f18c3b61
...
@@ -20,6 +20,14 @@ import re
...
@@ -20,6 +20,14 @@ import re
import
shutil
import
shutil
import
urlparse
import
urlparse
import
traceback
import
traceback
import
ctypes
from
ctypes
import
util
SYS
,
_
,
KERNEL
,
_
,
ARCH
=
os
.
uname
()
LIBC
=
ctypes
.
cdll
.
LoadLibrary
(
ctypes
.
util
.
find_library
(
'c'
))
LIBC_VERSION_FUN
=
LIBC
.
gnu_get_libc_version
LIBC_VERSION_FUN
.
restype
=
ctypes
.
c_char_p
LIBC_VERSION
=
"libc-%s"
%
LIBC_VERSION_FUN
()
try
:
try
:
try
:
try
:
...
@@ -76,7 +84,7 @@ def get_directory_key(url):
...
@@ -76,7 +84,7 @@ def get_directory_key(url):
@
fallback_call
@
fallback_call
def
download_network_cached
(
dir_url
,
cache_url
,
path
,
url
,
logger
,
def
download_network_cached
(
dir_url
,
cache_url
,
path
,
url
,
logger
,
signature_certificate_list
,
md5sum
=
None
):
signature_certificate_list
,
md5sum
=
None
,
binary_mode
=
False
):
"""Downloads from a network cache provider
"""Downloads from a network cache provider
If something fail (providor be offline, or hash_string fail), we ignore
If something fail (providor be offline, or hash_string fail), we ignore
...
@@ -92,8 +100,12 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
...
@@ -92,8 +100,12 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
if
md5sum
is
None
:
if
md5sum
is
None
:
md5sum
=
_get_md5_from_url
(
url
)
md5sum
=
_get_md5_from_url
(
url
)
if
binary_mode
:
directory_key
=
"binary-%s-%s-%s"
%
\
(
os
.
path
.
basename
(
path
),
SYS
,
ARCH
)
else
:
directory_key
=
get_directory_key
(
url
)
directory_key
=
get_directory_key
(
url
)
url
=
os
.
path
.
basename
(
url
)
url
=
os
.
path
.
basename
(
url
)
if
len
(
signature_certificate_list
)
==
0
:
if
len
(
signature_certificate_list
)
==
0
:
...
@@ -108,7 +120,7 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
...
@@ -108,7 +120,7 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
logger
.
info
(
'Downloading %s from network cache.'
%
url
)
logger
.
info
(
'Downloading %s from network cache.'
%
url
)
try
:
try
:
file_descriptor
=
nc
.
select
(
directory_key
)
file_descriptor
=
nc
.
select
(
directory_key
,
binary_mode
=
binary_mode
)
f
=
open
(
path
,
'w+b'
)
f
=
open
(
path
,
'w+b'
)
try
:
try
:
...
@@ -131,7 +143,7 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
...
@@ -131,7 +143,7 @@ def download_network_cached(dir_url, cache_url, path, url, logger,
@
fallback_call
@
fallback_call
def
upload_network_cached
(
dir_url
,
cache_url
,
external_url
,
path
,
logger
,
def
upload_network_cached
(
dir_url
,
cache_url
,
external_url
,
path
,
logger
,
signature_private_key_file
,
shacache_cert_file
,
shacache_key_file
,
signature_private_key_file
,
shacache_cert_file
,
shacache_key_file
,
shadir_cert_file
,
shadir_key_file
):
shadir_cert_file
,
shadir_key_file
,
binary_mode
=
False
):
"""Upload file to a network cache server"""
"""Upload file to a network cache server"""
if
not
LIBNETWORKCACHE_ENABLED
:
if
not
LIBNETWORKCACHE_ENABLED
:
return
False
return
False
...
@@ -141,8 +153,16 @@ def upload_network_cached(dir_url, cache_url, external_url, path, logger,
...
@@ -141,8 +153,16 @@ def upload_network_cached(dir_url, cache_url, external_url, path, logger,
logger
.
info
(
'Uploading %s into network cache.'
%
external_url
)
logger
.
info
(
'Uploading %s into network cache.'
%
external_url
)
if
binary_mode
:
file_name
=
get_filename_from_url
(
path
)
directory_key
=
"binary-%s-%s-%s"
%
\
(
file_name
,
SYS
,
ARCH
)
kw
=
dict
(
file_name
=
file_name
,
kernel
=
KERNEL
,
libc_version
=
LIBC_VERSION
,
urlmd5
=
hashlib
.
md5
(
external_url
).
hexdigest
())
else
:
file_name
=
get_filename_from_url
(
external_url
)
file_name
=
get_filename_from_url
(
external_url
)
directory_key
=
get_directory_key
(
external_url
)
directory_key
=
get_directory_key
(
external_url
)
kw
=
dict
(
file_name
=
file_name
,
kw
=
dict
(
file_name
=
file_name
,
urlmd5
=
hashlib
.
md5
(
external_url
).
hexdigest
())
urlmd5
=
hashlib
.
md5
(
external_url
).
hexdigest
())
...
...
Julien Muchembled
@jm
mentioned in commit
12706228
·
May 31, 2017
mentioned in commit
12706228
mentioned in commit 12706228dfe696c9d742d1e4c2530af56afa1cdd
Toggle commit 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