try: m = MessageReader(preload_conversations=preload) p = m.quick_stats except: # http://stackoverflow.com/questions/3702675/how-to-print-the-full-traceback-without-halting-the-program print(traceback.format_exc()) os._exit(1) # http://stackoverflow.com/questions/2356399/tell-if-python-is-in-interactive-mode if not sys.flags.interactive: print( "Are you sure you ran this program interactively, with the `-i` flag?") input("If not the program will exit. Press enter to continue: ") clear_screen() console_width = min(shutil.get_terminal_size().columns, 150) print("\nWelcome to the python3 terminal version of fb-msg-mining!\n\n") intro_text = ( "If you are unfamiliar with python syntax... then you might be better off using the GUI version of this " "program. You can exit this interactive session by typing the command `exit()` without the back tics, " "and clicking enter. If you're still set on using this version, then consider getting up to speed on " "syntax by executing the command `help()`") formatted_text = fit_colored_text_to_console(intro_text, "help()", "exit()") print(formatted_text) print() intro_text2 = ( 'Once you feel comfortable with basic python syntax, get ready to analyze your conversations with the ' 'command `m.help()`')
try: m = MessageReader(preload_conversations=preload) p = m.quick_stats except: # http://stackoverflow.com/questions/3702675/how-to-print-the-full-traceback-without-halting-the-program print(traceback.format_exc()) os._exit(1) # http://stackoverflow.com/questions/2356399/tell-if-python-is-in-interactive-mode if not sys.flags.interactive: print("Are you sure you ran this program interactively, with the `-i` flag?") input("If not the program will exit. Press enter to continue: ") clear_screen() console_width = min(shutil.get_terminal_size().columns, 150) print("\nWelcome to the python3 terminal version of fb-msg-mining!\n\n") intro_text = ("If you are unfamiliar with python syntax... then you might be better off using the GUI version of this " "program. You can exit this interactive session by typing the command `exit()` without the back tics, " "and clicking enter. If you're still set on using this version, then consider getting up to speed on " "syntax by executing the command `help()`") formatted_text = fit_colored_text_to_console(intro_text, "help()", "exit()") print(formatted_text) print() intro_text2 = ('Once you feel comfortable with basic python syntax, get ready to analyze your conversations with the ' 'command `m.help()`') print(fit_colored_text_to_console(intro_text2, "m.help()"))
if os.path.isfile('data/data.txt'): print("Are you sure you want to override the data currently saved?\n" "This might require resetting preferences. [Y/n]") choice = input("> ") while choice.lower() not in ['y', 'yes', 'no', 'n']: choice = input("> ") if choice.lower() in ['n', 'no']: exit() # ------------------------------------------ CHECKING FOR PREVIOUS SETUP ------------------------------------------- # # # ------------------------------------ BACKGROUND SETUP AND INFORMATION FOR USER ---------------------------------- # setup_functions.clear_screen() times = [time.time()] console_width = min(shutil.get_terminal_size().columns, 150) print('Setup information\n' + setup_functions.one_line() + '\n') # Background information print(Fore.LIGHTGREEN_EX + Back.BLACK + 'Background:' + Style.RESET_ALL) background = ("All of your message data (that hasn't been deleted) can be found in the file `messages.htm`. " "But since this file is written in raw html, and can get quite large, it isn't very fun to " "read through. What setup does is parse this html into a form more amenable to analysis.") print(textwrap.fill(background, width=console_width)) print() # User prompting information
# ------------------------------------------ CHECKING FOR PREVIOUS SETUP ------------------------------------------- # if os.path.isfile('data/data.json'): print("Are you sure you want to override the data currently saved?\n" "This might require resetting preferences. [Y/n]") choice = input("> ") while choice.lower() not in ['y', 'yes', 'no', 'n']: choice = input("> ") if choice.lower() in ['n', 'no']: exit() # ------------------------------------------ CHECKING FOR PREVIOUS SETUP ------------------------------------------- # # # ------------------------------------ BACKGROUND SETUP AND INFORMATION FOR USER ---------------------------------- # setup_functions.clear_screen() times = [time.time()] console_width = min(shutil.get_terminal_size().columns, 150) intro_text1 = ( "Beginning setup. During setup you might be prompted to answer whether two sets of messages are from the same " "chat. In this case, setup prints the last 10 messages from the first conversation, as well as the first 10 " "from the second conversation. You will then be asked whether the 20 messages are from the same chat, or two " "different chats.") intro_text2 = ( "A good way to do this is to go to www.facebook.com/messages and search for one of the longer messages that " "appear. When you find the conversation that has this messages, see if all 20 messages can be found " "consecutively. Only if you find them all should you specify \"yes\", that the two conversations are the same. " "Otherwise specify no.")