Results 1 to 3 of 3

Thread: New to Python: Google Docs Upload Project

  1. #1
    Join Date
    Oct 2008
    Beans
    6

    New to Python: Google Docs Upload Project

    Hello everyone. I'm a beginner to Python and I've decided to start a project to help me learn the language. Since I could not find an easy way to upload files to Google Docs from the desktop, I figured that I could help both myself and the community by attempting to create one. At the moment I have a very basic prototype that asks for authentication info and the full path of a file, while checking and outputting the content-type to the Google Docs server. I'd like to add some basic user input checks and possibly migrate it over to PyGTK with more features, such as a list of all files, a delete function, mass upload, and possibly download. If anyone could help me that'd be great, as I am completely lost with PyGTK.

    Here's the script I have so far:
    Code:
    from gdata.docs import service
    import mimetypes
    
    def create_client():
    	client = service.DocsService()
    	client.email = raw_input("Enter your Google Account e-mail address: ")
    	client.password = raw_input("Enter your Google Account password: ")
    	client.ProgrammaticLogin()
    	return client
    
    def upload_file():
    	import gdata
    	file_path = raw_input("Please enter the full path of the file you wish to upload: ")
    	title = raw_input("What would you like to name this file? ")
    	type = mimetypes.guess_type(file_path)
    	ms = gdata.MediaSource(file_path = file_path, content_type = type[0])
    	client = create_client()
    	entry = client.UploadDocument(ms,title)
    	print 'Link:', entry.GetAlternateLink().href
    
    upload_file()

  2. #2
    Join Date
    May 2006
    Location
    Pakistan
    Beans
    425
    Distro
    Kubuntu 7.10 Gutsy Gibbon

    Re: New to Python: Google Docs Upload Project

    I was looking for the same idea in C#. It will help me to write code in C#.

  3. #3
    Join Date
    Aug 2007
    Location
    127.0.0.1
    Beans
    1,800
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: New to Python: Google Docs Upload Project

    Don't waste time with PyGTK. I mean, is not bad, but build a full working application first in the shell, and when that is done, build a GUI with Glade, Micah Carrik has a good tutorial for all that:

    http://www.micahcarrick.com/12-24-20...al-part-1.html
    "Just in terms of allocation of time resources, religion is not very efficient. There's a lot more I could be doing on a Sunday morning."
    -Bill Gates

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •