Package: gdrive2
gdrive2What is gdrive2?gdrive2 helps users to easily access files from Google Drive using paths, instead of File ids. Google API requires the users to know the File ID to access it, but this package which is built using the pyDrive package allows users to use a file path to access the file or folder.In addition to this, the package also provides commands that can be called from a terminal, like cd, ls, pull or push, to quickly view, modify, download or upload files from or to Google drive using a python code or just the command line.Setup:pip install -i https://test.pypi.org/simple/ gdrive2Documentation:For more details aboutsetupandcommands, checkgdrive2.readthedocs.io.Quickdemo 1 : BasicsLets see how gdrive2 can be used from command line.Open terminal and set some folder where you intend to download or from where you intend to upload files.$ gd initWhen asked for a username, this is not same as the google username. More about this explained in theusernamedocumentation.
Enter some nickname (for example,mygdrive2) you would like to give to your google account, so that you can use this for quick authentication into your account in future.
This should take you to a Oauth Consent screen, where you'll be asked to enter your Google username and password. You are good, if you see this a html page showing this.The authentication is successful.Once authentication is done, from the current working folder, you can try several gdrive2 commands. Just likegit, gdrive2 also creates a hidden folder.gdwhich contains information about the fileIDs, driveIDs etc. More about this explained in theparentsdocumentation.:warning: After authentication of a new account, the credentials are stored inROOT_PATH/api_datafolder. The contents of this folder must be handled with discretion.After, initialization and authentication, you can use all the gdrive2 commands from this directory.$ gd status
---------------
Parent dicts :
---------------
// origin // 
username : mygdrive2
path     : ''
id       : 'root'
drive    : 'My Drive'
driveId  : 'root'
client_sec : 'client_secrets'

No files/folders staged.This command shows the contents of.gd/.gdinfo.jsonfile created during initialization. The structure of this and the meaning of each term are explained in theparentsdocumentation. For example, the folders in my drive are in this hierarchy.My Drive
|
|___fruits
|      |___hard
|      |     |__apple.jpg
|      |     |__guava.png
|      |
|      |___soft
|            |__grapes.jpg
|
|___flowers
      |___yellow
      |      |__sunflower.tiff
      |
      |___red
	   |__roses.jpg
	   |__poppy.pngTo list my files in the path stored in thepathvariable of the dictionary showed above:$ gd ls
: D[2351.5kB] 1 : fruits
: D[6571.2kB] 2 : flowersMy Driveis the name of the google drive's root folder.''(empty string) denotes the path to it. This shows that there are two folders in my root folder - fruits and flowers.$ gd ls fruits/hard
: f[1000.5kB] 1 : apple.jpg
: F[321.0kB] 2 : guava.jpgThis is how the paths can be simply used to get the file contents. Now, I'll change my path from''to'fruits/hard':$ gd cd fruits/hard
origin cwd changed to 'fruits/hard'

$ gd ls
: f[1000.5kB] 1 : apple.jpg
: F[321.0kB] 2 : guava.jpg

$ gd status
---------------
Parent dicts :
---------------
// origin // 
username : mygdrive2
path     : 'fruits/hard'
id       : '34eWf..iT23'
drive    : 'My Drive'
driveId  : 'root'
client_sec : 'client_secrets'

No files/folders staged.If I want to download the folder:$ gd pullOr, to just download theapple.jpg:$ gd pull origin apple.jpgIf I want to uploadberry.pngtofruits/hard:$ gd add 
$ gd cd fruits/hard
$ gd pushQuickdemo 2 : Multiple Parent functionality.gd/.gdinfo.jsonis a dictionary with each key defined as a parent (just like a remote in git). The first key of this dictionary is 'default_parent' whose value is the name of a default parent. Multiple parents can be set with multiple usernames(i.e. google accounts), paths, shared drives or even different client secrets files and one of these can be given the status of 'default_parent'. This makes frequent uploading and downloading as easy as git pull and push functions.To add a new parent:$ git init -addOnce a parent is added (say, origin2), we can assign different parameters (like username, path etc.) and push files simultaneously$ git push origin origin2Quickdemo 3 : Use of these commands in python script:All these commands can be used in a python script as shown below. The only difference from the terminal commands is that apart from the main function (init, status, etc), the optional arguements must be passed as strings in a list. If there is no arguements, an empty list must be passed in the function.>> import gdrive2 as gd
>> 
>> gd.init([])
>> gd.status([])
>> gd.add(['berry.jpg', 'mango.jpg'])For more details, checkgdrive2.readthedocs.ioPlease post issues here or email me atpreeth@uw.edu