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
1
Merge Requests
1
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.libnetworkcache
Commits
4246a2db
Commit
4246a2db
authored
Jun 14, 2011
by
Lucas Carvalho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented the basic usage of select method.
parent
e5ca9dd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
slapos/libnetworkcache/__init__.py
slapos/libnetworkcache/__init__.py
+23
-1
No files found.
slapos/libnetworkcache/__init__.py
View file @
4246a2db
...
@@ -129,6 +129,23 @@ class NetworkcacheClient(object):
...
@@ -129,6 +129,23 @@ class NetworkcacheClient(object):
raise
FileNotFound
(
result
.
read
())
raise
FileNotFound
(
result
.
read
())
return
result
return
result
def
select
(
self
,
directory_key
=
None
):
'''Download a file from shacache by selecting the entry in shadir
Raise DirectoryNotFound if multiple files are found.
'''
path_info
=
self
.
shadir_path
if
directory_key
is
not
None
path_info
=
os
.
path
.
join
(
self
.
shadir_path
,
directory_key
)
self
.
shadir_connection
=
httplib
.
HTTPConnection
(
self
.
shadir_host
)
self
.
shadir_connection
.
request
(
'GET'
,
path_info
,
headers
=
self
.
shadir_header_dict
)
result
=
self
.
shadir_connection
.
getresponse
()
if
result
.
status
!=
200
:
raise
DirectoryNotFound
(
result
.
read
())
data
=
json
.
loads
(
result
.
read
())
self
.
close
()
return
data
def
close
(
self
):
def
close
(
self
):
''' It must be called to close the HTTP Connection. '''
''' It must be called to close the HTTP Connection. '''
if
hasattr
(
self
,
'shacache_connection'
):
if
hasattr
(
self
,
'shacache_connection'
):
...
@@ -137,5 +154,10 @@ class NetworkcacheClient(object):
...
@@ -137,5 +154,10 @@ class NetworkcacheClient(object):
if
hasattr
(
self
,
'shadir_connection'
):
if
hasattr
(
self
,
'shadir_connection'
):
self
.
shadir_connection
.
close
()
self
.
shadir_connection
.
close
()
class
FileNotFound
(
Exception
):
class
FileNotFound
(
Exception
):
pass
pass
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