Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Tyagov
slapos.core
Commits
4a002857
Commit
4a002857
authored
Jun 14, 2011
by
Lucas Carvalho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved to
http://git.erp5.org/repos/slapos.libnetworkcache.git
parent
e5b06e1e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
82 deletions
+0
-82
slapos/README.libnetworkcache.txt
slapos/README.libnetworkcache.txt
+0
-14
slapos/libnetworkcache.py
slapos/libnetworkcache.py
+0
-68
No files found.
slapos/README.libnetworkcache.txt
deleted
100644 → 0
View file @
e5b06e1e
libnetworkcache
===============
The goal of libnetworkcache python library is to abstract the REST calls.
It works as wrapper of python httplib to use the Networkcache HTTP Server.
API
---
So, it must provide 2 methods:
put(file)
''' Upload the file to Networkcache HTTP Server using PUT as HTTP method.'''
get(key)
''' Download the file from Networkcache HTTP Server using GET as HTTP method.'''
slapos/libnetworkcache.py
deleted
100644 → 0
View file @
e5b06e1e
##############################################################################
#
# 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
httplib
import
os
class
NetworkcacheClient
(
object
):
'''
NetworkcacheClient is a wrapper for httplib.
It must implement all the required methods to use the Networkcache HTTP
Server.
- put(file)
- get(key)
'''
def
__init__
(
self
,
networkcache_url
):
# XXX (lucas): Is it required to check if networkcache_url is a valid URL?
self
.
networkcache_url
=
networkcache_url
def
_start
(
self
):
self
.
connection
=
httplib
.
HTTPConnection
(
self
.
networkcache_url
)
def
_close
(
self
):
self
.
connection
.
close
()
def
put
(
self
,
file_content
):
'''
Upload the file to the server.
It uses http PUT resquest method.
'''
if
file_content
is
not
None
:
raise
ValueError
(
'File content should not be None.'
)
self
.
_start
()
try
:
self
.
connection
.
request
(
'PUT'
,
'/'
,
file_content
)
result
=
self
.
connection
.
getresponse
()
finally
:
self
.
_close
()
return
result
def
get
(
self
,
key
):
'''
Download the file.
It uses http GET request method.
'''
path_info
=
'/%s'
%
key
self
.
_start
()
try
:
self
.
connection
.
request
(
'GET'
,
path_info
)
result
=
self
.
connection
.
getresponse
()
finally
:
self
.
_close
()
return
result
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