So I started using github and realized I had to pay some money to make my code private and I did not want to pay money for that. So I started looking around for alternatives and came across bitbucket but I wanted to use my google drive. So I started writing a python script to control my google drive folder from my Ubuntu 14.04.
This app has one file called as drive.py and you can find the file at https://github.com/shady33/google-drive-terminal . Just download the file or clone it. This file is the main module that is responsible for all the commands. There is also another file that we need.If you want it you can drop me an e-mail and I will mail you the file. That file is basically a credentials.txt file in the .drive folder in the same directory where your project is. This file contains the client key and client secret and can also be obtained with the following method. Firstly, login to https://code.google.com/apis/console/ . Here you need to create a new project and enable the Drive API and Drive SDK in the API’s tab. You will then receive a Client ID for native application. Copy the Client Id and Client Secret to a credentials.txt file in the .drive folder on the first and second lines respectively. With this you will have a working drive for your terminal and you can call it by <code>python drive.py [command] [args]</code>
Now for the commands:
I have added the following 6 commands as of now and if and when I come up with a new command will include it in the source.
The first command is init. It basically creates the .drive folder for the application. Also when you do a init you will get a url which you need to open and copy paste the code in your terminal.
Second command is the origin where we add the remote url if needed for a particular folder and you dont need to run it if you wish to use the root directory.
Third command is add. It works similar to the git add where we add the files to be commited on later.
Next is the push. This command pushes the added files to your google drive.
Next is pull [args]. The valid args is all or nothing. If you input all as the argument then it will pull all files in that folder. If you do not use any arguments then all the files that you had pushed earlier would be pulled.
The last is upload. It is basically used to upload the file directly without a add operation. With this you won’t be able to pull the file after somebody has updated it.
I hope this helps you in some way. You can find the source at https://github.com/shady33/google-drive-terminal .
Cheers!