Hi everyone,
I'm in the process of creating a Python app which will run on my Raspberry Pi to allow me to control a webcam via Dropbox. I have created an app and generated an access token. In my program, I have the following general structure:
if __name__ == '__main__':
dbx = dropbox.Dropbox('MY_ACCESS_TOKEN')
while True:
if poll_parameter('imagerequest') == 1:
print 'Image requested'
## Image capture code here
reset_parameter('imagerequest')
if poll_parameter('exitprogram') == 1:
print 'Exit requested'
reset_parameter('exitprogram')
break
time.sleep(poll_parameter('delay'))
So, you can see that the program creates a dropbox.Dropbox() session when it first opens, and then enters a loop where it polls certain parameters which are stored as files in the app's folder on Dropbox. Note that the poll_parameter() and reset_parameter() functions use the files_search() and files_move() API functions to search and rename the parameter files as necessary.
So, I started the program running today when I left for work, and I was able to command it for a few hours and it was taking/uploading images fine, but then it stopped responding. I think this is because the dropbox.Dropbox session may have expired. Does this happen after a certain time interval? How can I ensure that my app can continue to stay connected to Dropbox for as long as I want to use it (possibly weeks at a time)?
Perhaps if I put my dbx = dropbox.Dropbox('MY_ACCESS_TOKEN') line at the beginning of every loop, instead of just once at the very beginning of the program?
I also went into my app settings on Dropbox, and my Generated Access Token has disappeared (it just shows the 'Generate' button again). Is this because I left my app running? Why would this delete my access token?
Thanks a lot for the help, I'd love to get this little project off the ground, to the point where it will work for weeks on end so I can remotely monitor my webcams on holiday!