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
3b4bc05a
Commit
3b4bc05a
authored
Jul 29, 2011
by
Lucas Carvalho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added utils file.
This file must provide all the utils function, to avoid duplicating code.
parent
a6be7424
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
slapos/libnetworkcacheutils.py
slapos/libnetworkcacheutils.py
+44
-0
No files found.
slapos/libnetworkcacheutils.py
0 → 100644
View file @
3b4bc05a
##############################################################################
#
# Copyright (c) 2010 ViFiB SARL and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
socket
import
urlparse
import
base64
def
parseUrl
(
url
):
info_dict
=
{}
parsed_url
=
urlparse
.
urlparse
(
url
)
info_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
()
info_dict
[
'header_dict'
][
'Authorization'
]
=
'Basic %s'
%
\
base64string
info_dict
[
'path'
]
=
parsed_url
.
path
info_dict
[
'host'
]
=
parsed_url
.
hostname
info_dict
[
'scheme'
]
=
parsed_url
.
scheme
info_dict
[
'port'
]
=
parsed_url
.
port
or
\
socket
.
getservbyname
(
parsed_url
.
scheme
)
info_dict
[
'simple_url'
]
=
"%s://%s:%s%s"
%
\
(
info_dict
.
get
(
'scheme'
),
info_dict
.
get
(
'host'
),
info_dict
.
get
(
'port'
),
info_dict
.
get
(
'path'
))
return
info_dict
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