conduit r1460 - in trunk: . conduit/modules/GoogleModule scripts test/python-tests
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1460 - in trunk: . conduit/modules/GoogleModule scripts test/python-tests
- Date: Wed, 7 May 2008 23:10:30 +0100 (BST)
Author: jstowers
Date: Wed May 7 22:10:29 2008
New Revision: 1460
URL: http://svn.gnome.org/viewvc/conduit?rev=1460&view=rev
Log:
2008-05-08 John Stowers <john stowers gmail com>
* scripts/continuous-tester.sh: Fix USAGE
* conduit/modules/GoogleModule/GoogleModule.py:
* test/python-tests/TestDataProviderGoogleDocuments.py: Some more API
cleanup and tests.
Modified:
trunk/ChangeLog
trunk/conduit/modules/GoogleModule/GoogleModule.py
trunk/scripts/continuous-tester.sh
trunk/test/python-tests/TestDataProviderGoogleDocuments.py
Modified: trunk/conduit/modules/GoogleModule/GoogleModule.py
==============================================================================
--- trunk/conduit/modules/GoogleModule/GoogleModule.py (original)
+++ trunk/conduit/modules/GoogleModule/GoogleModule.py Wed May 7 22:10:29 2008
@@ -38,7 +38,7 @@
"PicasaTwoWay" : { "type": "dataprovider" },
"YouTubeSource" : { "type": "dataprovider" },
"ContactsTwoWay" : { "type": "dataprovider" },
-# "DocumentsSink" : { "type": "dataprovider" },
+ "DocumentsSink" : { "type": "dataprovider" },
}
log.info("Module Information: %s" % Utils.get_module_information(gdata, None))
except (ImportError, AttributeError):
@@ -1002,9 +1002,13 @@
_out_type_ = "contact"
_icon_ = "applications-office"
- SUPPORTED_DOCS = ('DOC','ODT','SWX','TXT','RTF','HTM','HTML')
+ SUPPORTED_DOCUMENTS = ('DOC','ODT','SWX','TXT','RTF','HTM','HTML')
SUPPORTED_SHEETS = ('ODS','XLS','CSV','TSV')
SUPPORTED_PRESENTATIONS = ('PPT','PPS')
+
+ TYPE_DOCUMENT = 'document'
+ TYPE_SPREADSHEET = 'spreadsheet'
+ TYPE_PRESENTATION = 'presentation'
def __init__(self, *args):
GoogleBase.__init__(self)
@@ -1023,7 +1027,7 @@
content_type=gdata.docs.service.SUPPORTED_FILETYPES[ext])
#upload using the appropriate service
- if ext in self.SUPPORTED_DOCS:
+ if ext in self.SUPPORTED_DOCUMENTS:
entry = self.service.UploadDocument(ms,name)
elif ext in self.SUPPORTED_SHEETS:
entry = self.service.UploadSpreadsheet(ms,name)
@@ -1033,7 +1037,7 @@
log.info("Unknown document format")
return None
- return Rid(uid=entry.id.text)
+ return entry.id.text
def _get_all_documents(self):
feed = self.service.GetDocumentListFeed()
@@ -1053,9 +1057,19 @@
return gd
- def _download_doc(self, docid):
- print self.service.additional_headers
- self.service.debug = True
+ # Parses the document id out of the alternate link url, the atom feed
+ # doesn't actually provide the document id
+ def _get_document_id(self, LUID):
+ from urlparse import *
+ parsed_url = urlparse(LUID)
+ url_params = parsed_url[4]
+ document_id = url_params.split('=')[1]
+ return document_id
+
+ def _download_doc(self, LUID):
+ docid = self._get_document_id(LUID)
+
+ #self.service.debug = True
#https://docs.google.com/MiscCommands?command=saveasdoc&exportformat=%s&docID=%s
resp = atom.service.HttpRequest(
service=self.service,
@@ -1067,10 +1081,13 @@
escape_params=True,
content_type='application/atom+xml')
- file_handle = open("/home/john/Desktop/%s.doc" % docid, 'wb')
+ path = "/home/john/Desktop/%s.doc" % docid
+ file_handle = open(path, 'wb')
file_handle.write(resp.read())
file_handle.close()
+ return path
+
def refresh(self):
DataProvider.DataSink.refresh(self)
self._login()
Modified: trunk/scripts/continuous-tester.sh
==============================================================================
--- trunk/scripts/continuous-tester.sh (original)
+++ trunk/scripts/continuous-tester.sh Wed May 7 22:10:29 2008
@@ -32,9 +32,9 @@
l ) LOOP=yes
CNT=1;;
b ) DBUS_LAUNCH=dbus-launch;;
- h ) echo $USAGE
+ h ) echo -e $USAGE
exit 0;;
- * ) echo $USAGE
+ * ) echo -e $USAGE
exit 1;;
esac
done
Modified: trunk/test/python-tests/TestDataProviderGoogleDocuments.py
==============================================================================
--- trunk/test/python-tests/TestDataProviderGoogleDocuments.py (original)
+++ trunk/test/python-tests/TestDataProviderGoogleDocuments.py Wed May 7 22:10:29 2008
@@ -17,13 +17,30 @@
except Exception, err:
ok("Logged in (%s)" % err, False)
-print google._get_all_documents()
+docs = google._get_all_documents()
+for d in docs:
+ print "DOC: %s" % d
-#f = File.File(URI="/home/john/Desktop/test2.odt")
-#print google._upload_document(f)
+doc = google._get_document(d)
+#print doc info
+info = {"raw txt link":doc.content.src,
+ "link":doc.GetAlternateLink().href,
+ "title": doc.title.text.encode('UTF-8'),
+ "updated":doc.updated.text,
+ "author_name":doc.author[0].name.text,
+ "author_email":doc.author[0].email.text,
+ "type":doc.category[0].label}
+for k,v in info.items():
+ print "\tINFO %s=%s" % (k,v)
+#for c in doc.category:
+# print "CAT: %s" % c.label
-#print google._get_document("http://docs.google.com/feeds/documents/private/full/document%3Adf32bhnd_6dvqk4x2f")
+path = google._download_doc(info['link'])
+print "DL: %s" % path
+
+f = File.File(URI="/home/john/Desktop/test.odt")
+LUID = google._upload_document(f)
+print "UL: %s" % LUID
-google._download_doc('df32bhnd_6dvqk4x2f')
finished()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]