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
Ophélie Gagnard
slapos.libnetworkcache
Commits
555902b4
Commit
555902b4
authored
Jun 25, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os.path must not be used for url
parent
b007f41a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
slapos/libnetworkcache.py
slapos/libnetworkcache.py
+9
-4
No files found.
slapos/libnetworkcache.py
View file @
555902b4
...
@@ -17,7 +17,6 @@ import base64
...
@@ -17,7 +17,6 @@ import base64
import
hashlib
import
hashlib
import
httplib
import
httplib
import
json
import
json
import
os
import
socket
import
socket
import
subprocess
import
subprocess
import
tempfile
import
tempfile
...
@@ -35,6 +34,12 @@ TIMEOUT = 60
...
@@ -35,6 +34,12 @@ TIMEOUT = 60
UPLOAD_TIMEOUT
=
60
*
60
UPLOAD_TIMEOUT
=
60
*
60
def
urljoin
(
a
,
b
):
if
not
a
.
endswith
(
'/'
):
a
+=
'/'
return
a
+
b
class
NetworkcacheClient
(
object
):
class
NetworkcacheClient
(
object
):
'''
'''
NetworkcacheClient is a wrapper for httplib.
NetworkcacheClient is a wrapper for httplib.
...
@@ -279,7 +284,7 @@ class NetworkcacheClient(object):
...
@@ -279,7 +284,7 @@ class NetworkcacheClient(object):
''' Download the file.
''' Download the file.
It uses http GET request method.
It uses http GET request method.
'''
'''
sha_cache_url
=
os
.
path
.
join
(
self
.
shacache_url
,
sha512sum
)
sha_cache_url
=
url
join
(
self
.
shacache_url
,
sha512sum
)
request
=
urllib2
.
Request
(
url
=
sha_cache_url
,
data
=
None
,
request
=
urllib2
.
Request
(
url
=
sha_cache_url
,
data
=
None
,
headers
=
self
.
shadir_header_dict
)
headers
=
self
.
shadir_header_dict
)
return
urllib2
.
urlopen
(
request
,
timeout
=
TIMEOUT
)
return
urllib2
.
urlopen
(
request
,
timeout
=
TIMEOUT
)
...
@@ -288,7 +293,7 @@ class NetworkcacheClient(object):
...
@@ -288,7 +293,7 @@ class NetworkcacheClient(object):
''' Download a file from shacache by selecting the entry in shadir
''' Download a file from shacache by selecting the entry in shadir
Raise DirectoryNotFound if no trustable file is found.
Raise DirectoryNotFound if no trustable file is found.
'''
'''
url
=
os
.
path
.
join
(
self
.
shadir_url
,
key
)
url
=
url
join
(
self
.
shadir_url
,
key
)
request
=
urllib2
.
Request
(
url
=
url
,
data
=
None
,
request
=
urllib2
.
Request
(
url
=
url
,
data
=
None
,
headers
=
self
.
shadir_header_dict
)
headers
=
self
.
shadir_header_dict
)
data
=
urllib2
.
urlopen
(
request
,
timeout
=
TIMEOUT
).
read
()
data
=
urllib2
.
urlopen
(
request
,
timeout
=
TIMEOUT
).
read
()
...
@@ -327,7 +332,7 @@ class NetworkcacheClient(object):
...
@@ -327,7 +332,7 @@ class NetworkcacheClient(object):
def
select_generic
(
self
,
key
):
def
select_generic
(
self
,
key
):
''' Select trustable entries from shadir.
''' Select trustable entries from shadir.
'''
'''
url
=
os
.
path
.
join
(
self
.
shadir_url
,
key
)
url
=
url
join
(
self
.
shadir_url
,
key
)
request
=
urllib2
.
Request
(
url
=
url
,
data
=
None
,
request
=
urllib2
.
Request
(
url
=
url
,
data
=
None
,
headers
=
self
.
shadir_header_dict
)
headers
=
self
.
shadir_header_dict
)
data
=
urllib2
.
urlopen
(
request
,
timeout
=
TIMEOUT
).
read
()
data
=
urllib2
.
urlopen
(
request
,
timeout
=
TIMEOUT
).
read
()
...
...
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