Metadata-Version: 1.1
Name: googleDriveAccess
Version: 0.1.2
Summary: recursive upload to Google Drive ( supports OAuth2, Calendar, Gmail, etc ) and import-export Google Apps Script source code
Home-page: https://github.com/HatsuneMiku/googleDriveAccess
Author: 999hatsune
Author-email: 999hatsune@gmail.com
License: BSD License
Download-URL: https://pypi.python.org/packages/source/g/googleDriveAccess/googleDriveAccess-0.1.2.tar.gz
Description: googleDriveAccess
        =================
        
        a Python tool to Access to the Google Drive ( OAuth2, Calendar, Gmail,
        etc )
        
        Package Documentation
        https://github.com/HatsuneMiku/googleDriveAccess/wiki/module\_googleDriveAccess
        
        Sample
        ------
        
        ::
        
            import os
            import googleDriveAccess as gda
        
            # create instance
            da = gda.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
            da.recursiveUpload('a_local_directory_you_want_to_backup_recursively')
        
            # search
            da.execQuery("explicitlyTrashed=True")
            da.execQuery("'root' in parents", **{'maxResults': 5})
            da.execQuery("'root' in parents and explicitlyTrashed=True", repeattoken=True, **{'maxResults': 500})
        
            # OAuth2
            oa2 = gda.OAuth2Client(abc=da)
            ui = oa2.userInfo()
            act = ui['email']
            print act
        
            # gmail
            gm = gda.GmailClient(abc=oa2)
            mo = gm.sendMsg(act, act, 'message title', 'message text')
            if mo:
              mo = gm.modifyLabels(mo['id'], addLabels=['INBOX', 'UNREAD', 'STARRED'])
            mo = gm.sendMsg(act, act, 'title attach', 'text attach', 'test_document.txt')
            if mo:
              mo = gm.modifyLabels(mo['id'], addLabels=['INBOX', 'UNREAD', 'STARRED'])
            msgs = gm.getMsgEntries(maxResults=3)
            for msg in msgs['messages']:
              mo = gm.getMsg(msg['id'])
              hdrs = gm.getHdrsDict(mo)
              for k in ('date', 'to', 'from', 'subject'):
                if k in hdrs: print u'%s: %s' % hdrs[k] # unicode
              print u'snippet: %s' % gm.trimWidth(mo['snippet'], 70) # unicode
        
            # calendar
            import time
            ca = gda.CalendarClient('Asia/Tokyo', abc=oa2)
            cals = ca.idList()
            for cal in cals['items']:
              print u'%s : %s' % (cal['id'], cal['summary']) # unicode
            id = cals['items'][0]['id']
            print id
            TEST_TITLE = u'rendez-vous 今日の待ち合わせ' # unicode
            t = time.time()
            eo = ca.insertEvent(id,
              start=ca.isoDate(t), end=ca.isoDate(t + 24 * 3600), # date only
              location=u'皇居', summary=TEST_TITLE) # unicode
            eo = ca.insertEvent(id,
              start=ca.isoTime(t + 1800), end=ca.isoTime(t + 3600), # date and time
              location=u'京都御所', summary=TEST_TITLE) # unicode
        
        How to use it
        -------------
        
        Install
        
        ::
        
            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 https://console.developers.google.com/project 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 ./encrypt\_client\_secret.py to encrypt downloaded JSON file.
        
        ::
        
            ./encrypt_client_secret.py
        
        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 ./test\_upload\_first.py to test OAuth2 flow and store
        credentials.
        
        ::
        
            ./test_upload_first.py
        
        Execute ./test\_upload\_second.py to test OAuth2 using stored
        credentials.
        
        ::
        
            ./test_upload_second.py
        
        Execute ./test\_calendar\_v3.py to test OAuth2 and add calendar event.
        
        ::
        
            ./test_calendar_v3.py
        
        Execute ./test\_gmail\_v1.py to test OAuth2 and send mail and modify
        labels.
        
        ::
        
            ./test_gmail_v1.py
        
        Execute ./test\_script\_prefetch.py to test Drive API search with query.
        
        ::
        
            ./test_script_prefetch.py
        
        Edit test\_script\_import\_export.py (set 'mode = 0') to test create new
        Google Apps Script 'test\_GoogleAppsScript\_createCalendarEvent' for
        tests below.
        
        Execute ./test\_script\_import\_export.py to test create and *'get
        SCRIPT\_ID'* .
        
        ::
        
            ./test_script_import_export.py
        
        Edit test\_script\_import\_export.py (set 'mode = 2' and *'set
        SCRIPT\_ID'*) to test download.
        
        Execute ./test\_script\_import\_export.py to test download.
        
        ::
        
            ./test_script_import_export.py
        
        Edit downloaded script
        './script\_import\_export/test\_GoogleAppsScript\_createCalendarEvent/Code.gs'
        .
        
        Edit test\_script\_import\_export.py (set 'mode = 1') to test upload.
        
        Execute ./test\_script\_import\_export.py to test upload.
        
        ::
        
            ./test_script_import_export.py
        
        Known BUGs
        ----------
        
        Fails to create and update Google Apps Script.
        
        ::
        
            mimeType was changed about specification of uploading Google Apps Script ?
        
        I will make refresh\_cache.py :
        
        ::
        
            This program will cache each folder (or file) ids assigned by the Google Drive.
            (Into the cache file cache_folderIds_[Client ID]_[OAuth2Act].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'.
        
        Links
        -----
        
        Package Documentation
        https://github.com/HatsuneMiku/googleDriveAccess/wiki/module\_googleDriveAccess
        
        You can get the latest version at this GitHub repository.
        https://github.com/HatsuneMiku/googleDriveAccess
        
        GitHub HomePage http://hatsunemiku.github.io/googleDriveAccess
        
        PyPI https://pypi.python.org/pypi/googleDriveAccess
        
        Relations
        ---------
        
        pytz-memcache https://github.com/HatsuneMiku/pytz-memcache
        
        pytz-memcache (PyPI) https://pypi.python.org/pypi/pytz-memcache
        
        License
        -------
        
        BSD License
        
Keywords: GAE google app engine client api OAuth2 gmail mail calendar drive googledrive recursive upload backup import export apps script
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 2 :: Only
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Networking
Classifier: Topic :: System :: Filesystems
Classifier: Topic :: System :: Archiving :: Mirroring
Classifier: Topic :: Utilities
Requires: make_GitHub_wiki_tree
Requires: make_GitHub_doc_PyPI
Requires: httplib2
Requires: pycrypto
Requires: simplejson
Requires: ssl
