Created
September 23, 2019 19:15
-
-
Save raihanba13/85131815ae9478aa239e95303b88a044 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import os | |
| import sys | |
| os.chdir('O:/python-code/gdrive_upload/') | |
| from pydrive.auth import GoogleAuth | |
| from pydrive.drive import GoogleDrive | |
| #print(os.getcwd()) | |
| try: | |
| gauth = GoogleAuth() | |
| gauth.LocalWebserverAuth() # Creates local webserver and auto handles authentication. | |
| drive = GoogleDrive(gauth) | |
| file1 = drive.CreateFile({'title': 'Hello.txt'}) # Create GoogleDriveFile instance with title 'Hello.txt'. | |
| file1.SetContentString('Hello World!') # Set content of the file from given string. | |
| file1.Upload() | |
| except Exception as e: | |
| exc_type, exc_obj, exc_tb = sys.exc_info() | |
| fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] | |
| print(exc_type, fname, exc_tb.tb_lineno) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment