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
1ddddac3
Commit
1ddddac3
authored
Jun 23, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify parsing.
parent
af2f5c36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
32 deletions
+21
-32
slapos/libnetworkcache.py
slapos/libnetworkcache.py
+21
-32
No files found.
slapos/libnetworkcache.py
View file @
1ddddac3
...
...
@@ -31,44 +31,33 @@ class NetworkcacheClient(object):
- SHACACHE
'''
def
parseUrl
(
self
,
url
):
return_dict
=
{}
parsed_url
=
urlparse
(
url
)
return_dict
[
'header_dict'
]
=
{
'Content-Type'
:
'application/json'
}
user
=
parsed_url
.
username
passwd
=
parsed_url
.
password
if
user
is
not
None
:
authentication_string
=
'%s:%s'
%
(
user
,
passwd
)
base64string
=
base64
.
encodestring
(
authentication_string
).
strip
()
return_dict
[
'header_dict'
][
'Authorization'
]
=
'Basic %s'
%
\
base64string
return_dict
[
'path'
]
=
parsed_url
.
path
return_dict
[
'host'
]
=
parsed_url
.
hostname
return_dict
[
'port'
]
=
parsed_url
.
port
return
return_dict
def
__init__
(
self
,
shacache
,
shadir
):
''' Set the initial values. '''
# ShaCache Properties
if
shacache
is
not
None
:
shacache_urlparse
=
urlparse
(
shacache
)
self
.
shacache_header_dict
=
{
'Content-Type'
:
'application/json'
}
shacache_user
=
shacache_urlparse
.
username
shacache_passwd
=
shacache_urlparse
.
password
if
shacache_user
is
not
None
:
authentication_string
=
'%s:%s'
%
(
shacache_user
,
shacache_passwd
)
base64string
=
base64
.
encodestring
(
authentication_string
).
strip
()
self
.
shacache_header_dict
[
'Authorization'
]
=
'Basic %s'
%
base64string
self
.
shacache_path
=
'/'
if
shacache_urlparse
.
path
not
in
(
''
,
'/'
):
self
.
shacache_path
=
shacache_urlparse
.
path
self
.
shacache_host
=
shacache_urlparse
.
hostname
self
.
shacache_port
=
shacache_urlparse
.
port
for
k
,
v
in
self
.
parseUrl
(
shacache
).
iteritems
():
setattr
(
self
,
'shacache_%s'
%
k
,
v
)
self
.
shacache_url
=
shacache
# ShaDir Properties
if
shadir
is
not
None
:
shadir_urlparse
=
urlparse
(
shadir
)
self
.
shadir_header_dict
=
{
'Content-Type'
:
'application/json'
}
shadir_user
=
shadir_urlparse
.
username
shadir_passwd
=
shadir_urlparse
.
password
if
shadir_user
is
not
None
:
authentication_string
=
'%s:%s'
%
(
shadir_user
,
shadir_passwd
)
base64string
=
base64
.
encodestring
(
authentication_string
).
strip
()
self
.
shadir_header_dict
[
'Authorization'
]
=
'Basic %s'
%
base64string
self
.
shadir_path
=
'/'
if
shadir_urlparse
.
path
not
in
(
''
,
'/'
):
self
.
shadir_path
=
shadir_urlparse
.
path
self
.
shadir_host
=
shadir_urlparse
.
hostname
self
.
shadir_port
=
shadir_urlparse
.
port
for
k
,
v
in
self
.
parseUrl
(
shadir
).
iteritems
():
setattr
(
self
,
'shadir_%s'
%
k
,
v
)
def
upload
(
self
,
file_descriptor
,
directory_key
=
None
,
**
kw
):
''' Upload the file to the server.
...
...
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