Last active
August 29, 2015 14:25
-
-
Save gsharp/7e10bd9496980fed9515 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#setup some basic python script to get params from the command line | |
import sys | |
Param1 = sys.argv[0] #make the first param map to variable Param1 | |
Param2 = sys.argv[1] #make the first param map to variable Param2 | |
# now the google example | |
# from google api https://developers.google.com/drive/web/manage-downloads#examples | |
from apiclient import errors | |
# ... | |
def download_file(service, drive_file): | |
"""Download a file's content. | |
Args: | |
service: Drive API service instance. | |
drive_file: Drive File instance. | |
Returns: | |
File's content if successful, None otherwise. | |
""" | |
download_url = drive_file.get('downloadUrl') | |
if download_url: | |
resp, content = service._http.request(download_url) | |
if resp.status == 200: | |
print 'Status: %s' % resp | |
return content | |
else: | |
print 'An error occurred: %s' % resp | |
return None | |
else: | |
# The file doesn't have any content stored on Drive. | |
return None | |
# end google example | |
# now do the google funciton call with your params | |
download_file(Param1, Param2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you would call it like this:
python path/to/jesse_gdrive_getter.py service drive_file