Revision: 2292
Author: KariHusa
Date: Fri Oct 16 03:43:25 2009
Log: Cleanup
http://code.google.com/p/robotframework/source/detail?r=2292
Modified:
/trunk/tools/libdoc/rfdoc_uploader.py
=======================================
--- /trunk/tools/libdoc/rfdoc_uploader.py Thu Oct 15 03:48:10 2009
+++ /trunk/tools/libdoc/rfdoc_uploader.py Fri Oct 16 03:43:25 2009
@@ -1,8 +1,10 @@
"""Robot Framework Library Uploader
-Usage: python rfdoc_uploader.py url file_name [--o]
+Usage: python rfdoc_uploader.py host file_name [--o]
options:
--o Overwrites the library in the server, if it already exists.
+
+Example: python rfdoc_uploader.py ExampleLibrary_version_1.xml
localhost:8000
"""
import sys
@@ -11,14 +13,12 @@
class RFDocUploader(object):
-
- def upload(self, file_path, url, override=True):
- fields = {'override': 'true'}
- resp = self._post_multipart(url, fields, file_path, override)
+
+ def upload(self, file_path, host, override=True):
+ resp = self._post_multipart(host, file_path, override)
return self._validate_success(resp)
-
-
- def _post_multipart(self, host, fields, file_path, override):
+
+ def _post_multipart(self, host, file_path, override):
content_type, body = self._encode_multipart_formdata(file_path,
override)
conn = HTTPConnection(host)
conn.connect()
@@ -27,7 +27,7 @@
resp = conn.getresponse()
conn.close()
return resp
-
+
def _encode_multipart_formdata(self, file_path, override):
BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
CRLF = '\r\n'
@@ -52,7 +52,6 @@
def _validate_success(self, resp):
status = resp.status
- reason = resp.reason
html = resp.read()
if status is 200 and re.search('Successfully uploaded library',
html):
return True
@@ -64,7 +63,7 @@
print __doc__
sys.exit()
file_path = args[0]
- url = args[1]
+ host = args[1]
override = False
if len(args) == 3:
if args[2] == '--o':
@@ -72,7 +71,7 @@
else:
print __doc__
sys.exit()
- if RFDocUploader().upload(file_path, url, override):
+ if RFDocUploader().upload(file_path, host, override):
print 'Library successfully uploaded!'
else:
print 'Failed to upload library!'