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
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
Show 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):
...
@@ -31,44 +31,33 @@ class NetworkcacheClient(object):
- SHACACHE
- SHACACHE
'''
'''
def
__init__
(
self
,
shacache
,
shadir
):
def
parseUrl
(
self
,
url
):
''' Set the initial values. '''
return_dict
=
{}
# ShaCache Properties
parsed_url
=
urlparse
(
url
)
if
shacache
is
not
None
:
return_dict
[
'header_dict'
]
=
{
'Content-Type'
:
'application/json'
}
shacache_urlparse
=
urlparse
(
shacache
)
user
=
parsed_url
.
username
self
.
shacache_header_dict
=
{
'Content-Type'
:
'application/json'
}
passwd
=
parsed_url
.
password
shacache_user
=
shacache_urlparse
.
username
if
user
is
not
None
:
shacache_passwd
=
shacache_urlparse
.
password
authentication_string
=
'%s:%s'
%
(
user
,
passwd
)
if
shacache_user
is
not
None
:
authentication_string
=
'%s:%s'
%
(
shacache_user
,
shacache_passwd
)
base64string
=
base64
.
encodestring
(
authentication_string
).
strip
()
base64string
=
base64
.
encodestring
(
authentication_string
).
strip
()
self
.
shacache_header_dict
[
'Authorization'
]
=
'Basic %s'
%
base64string
return_dict
[
'header_dict'
][
'Authorization'
]
=
'Basic %s'
%
\
base64string
self
.
shacache_path
=
'/'
return_dict
[
'path'
]
=
parsed_url
.
path
if
shacache_urlparse
.
path
not
in
(
''
,
'/'
):
return_dict
[
'host'
]
=
parsed_url
.
hostname
self
.
shacache_path
=
shacache_urlparse
.
path
return_dict
[
'port'
]
=
parsed_url
.
port
return
return_dict
self
.
shacache_host
=
shacache_urlparse
.
hostname
def
__init__
(
self
,
shacache
,
shadir
):
self
.
shacache_port
=
shacache_urlparse
.
port
''' Set the initial values. '''
# ShaCache Properties
for
k
,
v
in
self
.
parseUrl
(
shacache
).
iteritems
():
setattr
(
self
,
'shacache_%s'
%
k
,
v
)
self
.
shacache_url
=
shacache
self
.
shacache_url
=
shacache
# ShaDir Properties
# ShaDir Properties
if
shadir
is
not
None
:
for
k
,
v
in
self
.
parseUrl
(
shadir
).
iteritems
():
shadir_urlparse
=
urlparse
(
shadir
)
setattr
(
self
,
'shadir_%s'
%
k
,
v
)
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
def
upload
(
self
,
file_descriptor
,
directory_key
=
None
,
**
kw
):
def
upload
(
self
,
file_descriptor
,
directory_key
=
None
,
**
kw
):
''' Upload the file to the server.
''' 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