-
Notifications
You must be signed in to change notification settings - Fork 0
Dropbox Sync
This guide contains the steps to upload the generated csv file to Dropbox and have it available anywhere. This is very useful if you want to run it in a Raspberry Pi or private server. Feel free to share it!
First you have to visit this page(login is required) select Dropbox API, Full Dropbox and a name.
When your app is created, you will be redirected to the settings page (you can see all your apps in my apps). In the Oath2 section, click generate button and copy the token. It will be used later in the script to make API calls. Of course don't share it because it gives full dropbox access.
In order to store the file you can create a new folder or use any that is available. Remember its path because is important for the next step.
First you have to install Dropbox library. I recommend you use a virtualenv to manage dependencies. You can have this script in the ir_profile_tracker folder if you wish but not share virtualenv.
$ pip install dropboxCopy this code to a .py file and make it executable.
from dropbox import Dropbox, files
ACCESS_TOKEN = 'DROPBOX ACCESS TOKEN'
CSV_FILE = "PATH TO CSV FILE"
DROPBOX_PATH = "DROPBOX FOLDER/FILENAME"
def main():
dpx = Dropbox(ACCESS_TOKEN)
#/home/pi/ir_profile_tracker/output/drivers.csv
with open(CSV_FILE, 'rb') as file:
dpx.files_upload(file.read(),DROPBOX_PATH , mode=files.WriteMode.overwrite)
if __name__ == "__main__":
main()CSV_FILE contains the path where csv file is stored. For example:
CSV_FILE = 'myteam.csv'
CSV_FILE = '/home/pi/ir_profile_tracker/myteam.csv'DROPBOX_PATH contains the Dropbox folder where the file will be stored. You must include path and filename. For example:
DROPBOX_PATH = '/ir-files/myteam.csv'
DROPBOX_PATH = '/ir-files/stats/myteam.csv'
DROPBOX_PATH = 'myteam.csv' # It'll be stored in your Dropbox root.