Skip to content

Instantly share code, notes, and snippets.

@gsharp
Last active August 29, 2015 14:25
Show Gist options
  • Save gsharp/7e10bd9496980fed9515 to your computer and use it in GitHub Desktop.
Save gsharp/7e10bd9496980fed9515 to your computer and use it in GitHub Desktop.
#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)
@gsharp
Copy link
Author

gsharp commented Jul 21, 2015

you would call it like this:

python path/to/jesse_gdrive_getter.py service drive_file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment