Skip to main content

recursive upload to Google Drive and import-export Google Apps Script source code

Project description

a Python tool to Access to the Google Drive

Package Documentation


import os
import googleDriveAccess

# create instance
da = googleDriveAccess.DAClient(os.path.abspath('.'))

# create parent folders at the same time
folderId, folderPath = da.makeDirs('/remote_drive/subfolder_test/subsubfolder')
print folderId, folderPath

# recursive backup to remote folder

# search
da.execQuery("'root' in parents", **{'maxResults': 5})
da.execQuery("'root' in parents and explicitlyTrashed=True", repeattoken=True, **{'maxResults': 500})

How to use it


pip install 'google-api-python-client'
pip install googleDriveAccess
  (or easy_install googleDriveAccess)
cd /opt/googleDriveAccess

First, create your Client_ID and secret on the Google Drive.

Register your App on and ‘download JSON’ of your Client ID and Client secret.

Rename this JSON file to ‘./client_secret_[Client ID].json’ .

mv client_secrets.json /opt/googleDriveAccess/client_secret_YOURCLIENTID.json

Second, create cache file for Client ID .

Create ‘./cicache.txt’ file and write your Client ID to the first line.

echo YOURCLIENTID > ./cicache.txt

Third, encrypt secret file.

Execute ./ to encrypt downloaded JSON file.


Check that encrypted file exists ‘./client_secret[Client ID].json.enc’ and plain text JSON file ‘./client_secret[Client ID].json’ will be deleted.

Execute ./ to test OAuth2 flow and store credentials.


Execute ./ to test OAuth2 using stored credentials.


Execute ./ to test Drive API search with query.


Edit (set ‘mode = 0’) to test create new Google Apps Script ‘test_GoogleAppsScript_createCalendarEvent’ for tests below.

Execute ./ to test create and ‘get SCRIPT_ID’ .


Edit (set ‘mode = 2’ and ‘set SCRIPT_ID’) to test download.

Execute ./ to test download.


Edit downloaded script ‘./script_import_export/test_GoogleAppsScript_createCalendarEvent/’ .

Edit (set ‘mode = 1’) to test upload.

Execute ./ to test upload.


Known BUGs

I will make :

This program will cache each folder (or file) ids assigned by the Google Drive.
(Into the cache file cache_folderIds_[Client ID].sl3 .)
Please search and erase a row that has same id from the cache file
when you delete your folder or file using another Google Drive client tool.

It may be fixed:

When uploading a file that would not be automaticaly handled Google Drive,
"Media type 'None' is not supported. Valid media types: [*/*]"
error occurred.
Because of default mimeType is set to None on uploadFile.
So it may correct to catch the exception and retry with 'binary/octet-stream'.


BSD License

Project details

Release history Release notifications

History Node


History Node


History Node


History Node


History Node


History Node


This version
History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
googleDriveAccess-0.0.10.tar.gz (14.2 kB) Copy SHA256 hash SHA256 Source None Jul 14, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page