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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Douglas
slapos.libnetworkcache
Commits
af2f5c36
Commit
af2f5c36
authored
Jun 23, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid playing with url.
HTTPConnection accept port as none, there is no need to play with it.
parent
df7a4fa7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
slapos/libnetworkcache.py
slapos/libnetworkcache.py
+8
-11
No files found.
slapos/libnetworkcache.py
View file @
af2f5c36
...
...
@@ -36,10 +36,6 @@ class NetworkcacheClient(object):
# ShaCache Properties
if
shacache
is
not
None
:
shacache_urlparse
=
urlparse
(
shacache
)
self
.
shacache_host
=
shacache_urlparse
.
hostname
if
shacache_urlparse
.
port
is
not
None
:
self
.
shacache_host
+=
':%s'
%
shacache_urlparse
.
port
self
.
shacache_header_dict
=
{
'Content-Type'
:
'application/json'
}
shacache_user
=
shacache_urlparse
.
username
shacache_passwd
=
shacache_urlparse
.
password
...
...
@@ -53,8 +49,7 @@ class NetworkcacheClient(object):
self
.
shacache_path
=
shacache_urlparse
.
path
self
.
shacache_host
=
shacache_urlparse
.
hostname
if
shacache_urlparse
.
port
is
not
None
:
self
.
shacache_host
+=
':%s'
%
shacache_urlparse
.
port
self
.
shacache_port
=
shacache_urlparse
.
port
self
.
shacache_url
=
shacache
# ShaDir Properties
...
...
@@ -73,8 +68,7 @@ class NetworkcacheClient(object):
self
.
shadir_path
=
shadir_urlparse
.
path
self
.
shadir_host
=
shadir_urlparse
.
hostname
if
shadir_urlparse
.
port
is
not
None
:
self
.
shadir_host
+=
':%s'
%
shadir_urlparse
.
port
self
.
shadir_port
=
shadir_urlparse
.
port
def
upload
(
self
,
file_descriptor
,
directory_key
=
None
,
**
kw
):
''' Upload the file to the server.
...
...
@@ -89,7 +83,8 @@ class NetworkcacheClient(object):
sha512sum
=
hashlib
.
sha512
(
file_content
).
hexdigest
()
path
=
os
.
path
.
join
(
self
.
shacache_path
,
sha512sum
)
shacache_connection
=
httplib
.
HTTPConnection
(
self
.
shacache_host
)
shacache_connection
=
httplib
.
HTTPConnection
(
self
.
shacache_host
,
self
.
shacache_port
)
try
:
shacache_connection
.
request
(
'POST'
,
path
,
file_content
,
self
.
shacache_header_dict
)
...
...
@@ -119,7 +114,8 @@ class NetworkcacheClient(object):
signature
=
''
data
=
[
kw
,
signature
]
shadir_connection
=
httplib
.
HTTPConnection
(
self
.
shadir_host
)
shadir_connection
=
httplib
.
HTTPConnection
(
self
.
shadir_host
,
self
.
shadir_port
)
try
:
shadir_connection
.
request
(
'POST'
,
path
,
json
.
dumps
(
data
),
self
.
shadir_header_dict
)
...
...
@@ -157,7 +153,8 @@ class NetworkcacheClient(object):
if
directory_key
is
not
None
:
path_info
=
os
.
path
.
join
(
self
.
shadir_path
,
directory_key
)
shadir_connection
=
httplib
.
HTTPConnection
(
self
.
shadir_host
)
shadir_connection
=
httplib
.
HTTPConnection
(
self
.
shadir_host
,
self
.
shadir_port
)
try
:
shadir_connection
.
request
(
'GET'
,
path_info
,
headers
=
self
.
shadir_header_dict
)
result
=
shadir_connection
.
getresponse
()
...
...
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