Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.libnetworkcache
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.libnetworkcache
Commits
68014b94
Commit
68014b94
authored
Jan 19, 2012
by
Yingjie Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Extend methods to use binary cache."
This reverts commit
2a9024fc
.
parent
c0c5c973
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
30 deletions
+4
-30
slapos/libnetworkcache.py
slapos/libnetworkcache.py
+4
-30
No files found.
slapos/libnetworkcache.py
View file @
68014b94
...
...
@@ -24,8 +24,7 @@ import tempfile
import
traceback
import
urllib2
import
urlparse
import
ctypes
from
ctypes
import
util
class
NetworkcacheClient
(
object
):
'''
...
...
@@ -113,7 +112,7 @@ class NetworkcacheClient(object):
self
.
shadir_cert_file
=
shadir_cert_file
def
upload
(
self
,
file_descriptor
,
key
=
None
,
urlmd5
=
None
,
file_name
=
None
,
valid_until
=
None
,
architecture
=
None
,
kernel
=
None
,
libc_version
=
None
):
valid_until
=
None
,
architecture
=
None
):
''' Upload the file to the server.
If urlmd5 is None it must only upload to SHACACHE.
Otherwise, it must create a new entry on SHADIR.
...
...
@@ -162,10 +161,6 @@ class NetworkcacheClient(object):
kw
[
'valid-until'
]
=
valid_until
if
architecture
is
not
None
:
kw
[
'architecture'
]
=
architecture
if
kernel
is
not
None
:
kw
[
'kernel'
]
=
kernel
if
libc_version
is
not
None
:
kw
[
'libc-version'
]
=
libc_version
sha_entry
=
json
.
dumps
(
kw
)
try
:
...
...
@@ -205,7 +200,7 @@ class NetworkcacheClient(object):
headers
=
self
.
shadir_header_dict
)
return
urllib2
.
urlopen
(
request
)
def
select
(
self
,
key
,
binary_mode
=
False
):
def
select
(
self
,
key
):
''' Download a file from shacache by selecting the entry in shadir
Raise DirectoryNotFound if multiple files are found.
'''
...
...
@@ -223,8 +218,7 @@ class NetworkcacheClient(object):
if
self
.
signature_certificate_list
is
not
None
:
for
data
in
data_list
:
if
len
(
data
[
1
]):
if
self
.
_verifySignatureInCertificateList
(
data
[
0
],
data
[
1
])
and
\
self
.
_isCompatible
(
data
[
0
],
binary_mode
=
binary_mode
):
if
self
.
_verifySignatureInCertificateList
(
data
[
0
],
data
[
1
]):
filtered_data_list
.
append
(
data
)
else
:
filtered_data_list
=
data_list
...
...
@@ -324,26 +318,6 @@ class NetworkcacheClient(object):
content_file
.
close
()
pubkey_file
.
close
()
def
_isCompatible
(
self
,
information_json
,
binary_mode
=
False
):
if
not
binary_mode
:
return
True
try
:
information_dict
=
json
.
loads
(
information_json
)
except
Exception
:
raise
DirectoryNotFound
(
'It was impossible to parse json-in-json '
'response:
\
n
%s'
%
traceback
.
format_exc
())
_
,
_
,
kernel
,
_
,
_
=
os
.
uname
()
LIBC
=
ctypes
.
cdll
.
LoadLibrary
(
ctypes
.
util
.
find_library
(
'c'
))
libc_version
=
LIBC
.
gnu_get_libc_version
libc_version
.
restype
=
ctypes
.
c_char_p
try
:
if
kernel
!=
information_dict
.
get
(
'kernel'
):
return
False
if
(
"libc-%s"
%
libc_version
())
!=
information_dict
.
get
(
'libc-version'
):
return
False
except
Exception
:
return
False
return
True
class
DirectoryNotFound
(
Exception
):
pass
...
...
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