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
9b7aac9a
Commit
9b7aac9a
authored
Aug 24, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to urllib2.
parent
0a2ef6d5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
slapos/libnetworkcache.py
slapos/libnetworkcache.py
+8
-12
No files found.
slapos/libnetworkcache.py
View file @
9b7aac9a
...
@@ -19,7 +19,7 @@ import httplib
...
@@ -19,7 +19,7 @@ import httplib
import
json
import
json
import
os
import
os
import
tempfile
import
tempfile
import
urllib
import
urllib
2
import
urlparse
import
urlparse
import
M2Crypto
import
M2Crypto
import
socket
import
socket
...
@@ -150,9 +150,9 @@ class NetworkcacheClient(object):
...
@@ -150,9 +150,9 @@ class NetworkcacheClient(object):
'''
'''
sha_cache_url
=
os
.
path
.
join
(
self
.
shacache_url
,
sha512sum
)
sha_cache_url
=
os
.
path
.
join
(
self
.
shacache_url
,
sha512sum
)
file_descriptor
=
tempfile
.
NamedTemporaryFile
()
file_descriptor
=
tempfile
.
NamedTemporaryFile
()
path
,
headers
=
urllib
.
urlretrieve
(
sha_cache_url
,
file_descriptor
.
name
)
request
=
urllib2
.
Request
(
url
=
sha_cache_url
,
data
=
None
,
file_descriptor
.
seek
(
0
)
headers
=
self
.
shadir_header_dict
)
return
file_descriptor
return
urllib2
.
urlopen
(
request
)
def
select
(
self
,
urlmd5
):
def
select
(
self
,
urlmd5
):
''' Download a file from shacache by selecting the entry in shadir
''' Download a file from shacache by selecting the entry in shadir
...
@@ -160,9 +160,9 @@ class NetworkcacheClient(object):
...
@@ -160,9 +160,9 @@ class NetworkcacheClient(object):
'''
'''
url
=
os
.
path
.
join
(
self
.
shadir_url
,
urlmd5
)
url
=
os
.
path
.
join
(
self
.
shadir_url
,
urlmd5
)
file_descriptor
=
tempfile
.
NamedTemporaryFile
()
file_descriptor
=
tempfile
.
NamedTemporaryFile
()
path
,
headers
=
urllib
.
urlretrieve
(
url
,
file_descriptor
.
name
)
request
=
urllib2
.
Request
(
url
=
url
,
data
=
None
,
file_descriptor
.
seek
(
0
)
headers
=
self
.
shadir_header_dict
)
data
=
file_descriptor
.
read
()
data
=
urllib2
.
urlopen
(
request
)
.
read
()
# Filtering...
# Filtering...
data_list
=
json
.
loads
(
data
)
data_list
=
json
.
loads
(
data
)
if
len
(
data_list
)
>
1
and
not
\
if
len
(
data_list
)
>
1
and
not
\
...
@@ -233,11 +233,7 @@ class NetworkcacheClient(object):
...
@@ -233,11 +233,7 @@ class NetworkcacheClient(object):
def
_fetchCertificateFileFromUrl
(
self
,
certification_file_url
):
def
_fetchCertificateFileFromUrl
(
self
,
certification_file_url
):
""" Download the certification files from the url. """
""" Download the certification files from the url. """
file_descriptor
=
tempfile
.
NamedTemporaryFile
()
return
urllib2
.
urlopen
(
certification_file_url
)
path
,
headers
=
urllib
.
urlretrieve
(
certification_file_url
,
file_descriptor
.
name
)
file_descriptor
.
seek
(
0
)
return
file_descriptor
class
DirectoryNotFound
(
Exception
):
class
DirectoryNotFound
(
Exception
):
...
...
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