Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Thought Log + Dropbox SDK
# Include the Dropbox SDK libraries
from dropbox import client, rest, session
import easygui
import subprocess
import webbrowser
from time import gmtime, strftime
name = easygui.enterbox(msg='Enter your name:', title='Name query')
if str(name).lower() == "Gian":['say','Welcome Inventor'])
msg= 'Welcome back Inventor Gian. You thoughts will be safe with me.',
title='You have completed one thought log',
#f, metadata = client.get_file_and_metadata('/magnum-opus.txt',rev='362e2029684fe')
#out = open('magnum-opus.txt', 'w')
#Makes variable for the current time for logging
current_time = strftime("%a, %d %b %Y %H:%M:%S", gmtime())
f1 = open('Gian\'s Log.txt', 'a')
f1.write('\n' + name + '\n')
f1.write(current_time + '\n')
#Asks for input on users current situation, thoughts, emotions and behavior.
situation = ['SITUATION:(Example: Waiting for a friend who is late.)']
thoughts = ['THOUGHTS:(Example: My friend Bob\'s is always late!)']
emotions = ['EMOTIONS:(Example: Mad & Stressed)']
behavior = ['BEHAVIOR:(Example: Arguing with family)']
field1 = easygui.multenterbox(name + ', please fill in the blanks', 'Gians Thought Log', situation + thoughts + emotions + behavior)
f2 = open(name + '''\'s Log.txt''', 'a')
f2.write('SITUATION: ' + str(field1[0]) + '\n')
f2.write('THOUGHTS: ' + str(field1[1]) + '\n')
f2.write('EMOTIONS: ' + str(field1[2]) + '\n')
f2.write('BEHAVIOR: ' + str(field1[3]) + '\n')
if str(field1[1]).lower() == "always":
msg= ''' !!!!!
A possible overgeneralization was detected.
The Thinking Trap auto detector identifyed a possible thinking trap. \n
You said "Always" in the thoughts enterbox.''',
title='Thinking Trap Detected',
elif str(field1[1]).lower() != "always":
msg= 'The Thinking Trap auto detector did not detect any Thinking Traps.',
title='Thinking Trap Detected',
#Lists field1 and thinking traps so that the user can identify thinking traps
thinking_trapsgui = easygui.enterbox(msg= name +', please identify your thinking traps: \n \n'
'FORTUNE-TELLING: This occurs when we predict that things will turn out badly. However, we cannot predict the future because we don\'t have a magic ball! \n \n'
'MIND-READING: This happens when we believe that we know what others are thinking and we assume that they\'re thinking the worst of us. However, we cannot mind-read so we do not know what others are thinking! \n \n'
'LABELING: Sometimes we talk to ourselves in a mean way and we use a single negative word to describe ourselves. However, this kind of thinking is unfair and we\'re too complex to be summed up in a single word! \n \n'
'FILTERING: This happens when we take note of all the bad things that happen, but ignore any good things. \n \n'
'OVERESTIMATING: This happens when we believe that something that\'s unlikely to occur is actually about to happen. \n \n'
'CATASTROPHIZING: This is when we imagine the worst possible thing is about to happen and we will be unable to cope with it. \n \n'
'OVERGENERALIZING: This is when we use words like always or never to describe situations or events. This is a problematic way of thinking because it doesn\'t take all situations or events into account \n \n'
+ str(field1),
title='Gians Thought Log')
f3 = open(name + '''\'s Log.txt''', 'a')
f3.write('THINKING TRAPS: ' + thinking_trapsgui + '\n')
#Alternate thoughts and behavior Multi Variable Mult Enter Box
alternate_behavior = ['ALTERNATE BEHAVIOR: \n Example: Find a constructive way to calm down. \n']
alternate_thoughts = ['ALTERNATE THOUGHTS: \n Example: He probably has a good reasong to be late.']
field2 = easygui.multenterbox(name + ', please fill in the blanks', 'Gians Thought Log', alternate_behavior + alternate_thoughts)
f4 = open(name + '''\'s Log.txt''', 'a')
f4.write('ALT THOUGHTS: ' + str(field2[0]) + '\n')
f4.write('ALT BEHAVIOR: ' + str(field2[1]) + '\n')
#Lets the user know that they have completed a thought log.
finish = easygui.msgbox(
msg= '''
You\'ve completed a thought log! Your thoughts will be logged,
along with the current date and time to a file called Log.txt.
title='You have completed one thought log',
# Get your app key and secret from the Dropbox developer website
APP_KEY = ''
# ACCESS_TYPE should be 'dropbox' or 'app_folder' as configured for your app
ACCESS_TYPE = 'app_folder'
sess = session.DropboxSession(APP_KEY, APP_SECRET, ACCESS_TYPE)
request_token = sess.obtain_request_token()
# Make the user sign in and authorize this token
url = sess.build_authorize_url(request_token)
easygui.enterbox(msg= "Please visit this URL by copying and pasting it into your browser and press the 'Allow' or 'Continue' button, then hit 'OK' here. \n \n",
title= "URL",
default= str(url),
image= "dropbox.gif"
# This will fail if the user didn't visit the above URL and hit 'Allow'
access_token = sess.obtain_access_token(request_token)
# This will display a window with info about the linked account
#client = client.DropboxClient(sess)
# msg= "Linked account: \n\n" + str(client.account_info()),
# title= "Linked account",
# ok_button= "OK",
# image= "dropbox.gif"
# )
# This will display a window notifying the user that their log has been uploaded to dropbox
client = client.DropboxClient(sess)
file_directory = open('''/Users/gianlazzarini/Documents/Aptana Studio 3 Workspace/Thought Log 3 w dropbox/src/Gian's Log.txt''')
file_name = 'Gian\'s Log ' + current_time + '.txt'
response = client.put_file(file_name, file_directory)
image= "install_graphic.gif"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.