Esempio n. 1
0
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")
        ui.message("")

        ui.message("--- Cyphering ---")
        ui.message("Data to cypher: {}\n".format("hello wolrd"))
        ui.message("Celldrawer cyphered data: {}"
                   "".format(celldrawer.cypher("hello world")))
        ui.message("")

        htext = "123580 147*369#8 321457*0#  147*369#8 *74269#8 32470# " \
                "147*538# *74269#8 *7412690 321457*0# *7415369# 15380"
        ui.message("--- Decyphering ---")
        ui.message("Celldrawer text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(celldrawer.decypher(htext)))
        ui.message("")

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to cypher must be acsii lowercase "
                   "letters only:")
        ui.message("Data to cypher: {}\n".format("Hello Wolrd!"))
        try:
            ui.message("Celldrawer cyphered data: {}"
                       "".format(celldrawer.cypher("Hello World!")))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)
        ui.message("")

        ui.message("+ The input text to decypher must be phone digits only:")
        htext = "123580 147*369#8 321457*0#  1N7*369#8 *74269#8 32470# " \
                "147*538# *74269#8 *7412690 321457*0# *741k369# 15380!"
        ui.message("Celldrawer text used as input: {}".format(htext))
        try:
            ui.message("The decyphered data is: {}"
                       "".format(celldrawer.decypher(htext)))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)
        ui.message("")

        ui.get_choice("", [("", "Go back to $menu", "")], oneline=True)
Esempio n. 2
0
    def demo(self, ui):
        ui.message("===== Demo Mode =====")
        ui.message("Running a small demo/testing!")
        ui.message("")

        ui.message("--- Cyphering ---")
        ui.message("Data to cypher: {}\n".format("hello wolrd"))
        ui.message("Celldrawer cyphered data: {}"
                   "".format(celldrawer.cypher("hello world")))
        ui.message("")

        htext = "123580 147*369#8 321457*0#  147*369#8 *74269#8 32470# " \
                "147*538# *74269#8 *7412690 321457*0# *7415369# 15380"
        ui.message("--- Decyphering ---")
        ui.message("Celldrawer text used as input: {}".format(htext))
        ui.message("The decyphered data is: {}"
                   "".format(celldrawer.decypher(htext)))
        ui.message("")

        ui.message("--- Won’t work ---")
        ui.message("+ The input text to cypher must be acsii lowercase "
                   "letters only:")
        ui.message("Data to cypher: {}\n".format("Hello Wolrd!"))
        try:
            ui.message("Celldrawer cyphered data: {}"
                       "".format(celldrawer.cypher("Hello World!")))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)
        ui.message("")

        ui.message("+ The input text to decypher must be phone digits only:")
        htext = "123580 147*369#8 321457*0#  1N7*369#8 *74269#8 32470# " \
                "147*538# *74269#8 *7412690 321457*0# *741k369# 15380!"
        ui.message("Celldrawer text used as input: {}".format(htext))
        try:
            ui.message("The decyphered data is: {}"
                       "".format(celldrawer.decypher(htext)))
        except Exception as e:
            ui.message(str(e), level=ui.ERROR)
        ui.message("")

        ui.get_choice("", [("", "Go back to $menu", "")], oneline=True)
Esempio n. 3
0
    def cypher(self, ui):
        """Interactive version of cypher()."""
        txt = ""
        ui.message("===== Cypher Mode =====")

        while 1:
            done = False
            while 1:
                txt = ui.text_input("Text to cypher to celldrawer")
                if txt is None:
                    break  # Go back to main Cypher menu.

                try:
                    # Will also raise an exception if data is None.
                    txt = celldrawer.cypher(txt)
                    done = True  # Out of those loops, output result.
                    break
                except Exception as e:
                    if utils.DEBUG:
                        import traceback
                        traceback.print_tb(sys.exc_info()[2])
                    ui.message(str(e), level=ui.ERROR)
                    options = [("retry", "*try again", ""),
                               ("menu", "or go back to *menu", "")]
                    answ = ui.get_choice(
                        "Could not convert that data into "
                        "celldrawer, please",
                        options,
                        oneline=True)
                    if answ in {None, "menu"}:
                        return  # Go back to main Sema menu.
                    # Else, retry with another data to hide.

            if done:
                ui.text_output("Text successfully converted", txt,
                               "Celldrawer version of text")

            options = [("redo", "*cypher another text", ""),
                       ("quit", "or go back to *menu", "")]
            answ = ui.get_choice("Do you want to", options, oneline=True)
            if answ in {None, "quit"}:
                return
Esempio n. 4
0
    def cypher(self, ui):
        """Interactive version of cypher()."""
        txt = ""
        ui.message("===== Cypher Mode =====")

        while 1:
            done = False
            while 1:
                txt = ui.text_input("Text to cypher to celldrawer")
                if txt is None:
                    break  # Go back to main Cypher menu.

                try:
                    # Will also raise an exception if data is None.
                    txt = celldrawer.cypher(txt)
                    done = True  # Out of those loops, output result.
                    break
                except Exception as e:
                    if utils.DEBUG:
                        import traceback
                        traceback.print_tb(sys.exc_info()[2])
                    ui.message(str(e), level=ui.ERROR)
                    options = [("retry", "*try again", ""),
                               ("menu", "or go back to *menu", "")]
                    answ = ui.get_choice("Could not convert that data into "
                                         "celldrawer, please", options,
                                         oneline=True)
                    if answ in {None, "menu"}:
                        return  # Go back to main Sema menu.
                    # Else, retry with another data to hide.

            if done:
                ui.text_output("Text successfully converted", txt,
                               "Celldrawer version of text")

            options = [("redo", "*cypher another text", ""),
                       ("quit", "or go back to *menu", "")]
            answ = ui.get_choice("Do you want to", options, oneline=True)
            if answ in {None, "quit"}:
                return