def prompt_auth(self, msg):
     import getpass
     print_msg(msg)
     response = getpass.getpass('')
     if len(response) == 0:
         return None
     return response
Example #2
0
 def prompt_auth(self, msg):
     import getpass
     print_msg(msg)
     response = getpass.getpass('')
     if len(response) == 0:
         return None
     return response
Example #3
0
    def runCommand(self):
        command = self.getCommand()
        self.addToHistory(command)

        command = self.getConstruct(command)

        if command:
            tmp_stdout = sys.stdout

            class stdoutProxy():
                def __init__(self, write_func):
                    self.write_func = write_func
                    self.skip = False

                def flush(self):
                    pass

                def write(self, text):
                    if not self.skip:
                        stripped_text = text.rstrip('\n')
                        self.write_func(stripped_text)
                        QtCore.QCoreApplication.processEvents()
                    self.skip = not self.skip

            if type(self.namespace.get(command)) == type(lambda: None):
                self.appendPlainText(
                    "'%s' is a function. Type '%s()' to use it in the Python console."
                    % (command, command))
                self.newPrompt()
                return

            sys.stdout = stdoutProxy(self.appendPlainText)
            try:
                try:
                    # eval is generally considered bad practice. use it wisely!
                    result = eval(command, self.namespace, self.namespace)
                    result = util.json_encode(result)
                    if result != None:
                        if self.is_json:
                            util.print_msg(result)
                        else:
                            self.appendPlainText(repr(result))
                except SyntaxError:
                    # exec is generally considered bad practice. use it wisely!
                    exec command in self.namespace
            except SystemExit:
                self.close()
            except Exception:
                traceback_lines = traceback.format_exc().split('\n')
                # Remove traceback mentioning this file, and a linebreak
                for i in (3, 2, 1, -1):
                    traceback_lines.pop(i)
                self.appendPlainText('\n'.join(traceback_lines))
            sys.stdout = tmp_stdout
        self.newPrompt()
        self.set_json(False)
Example #4
0
    def _send(self, parent, blob):
        def sender_thread():
            try:
                with self._audio_interface() as interface:
                    src = BytesIO(blob)
                    dst = interface.player()
                    amodem.main.send(config=self.modem_config, src=src, dst=dst)
            except Exception:
                traceback.print_exc()

        print_msg('Sending:', repr(blob))
        blob = zlib.compress(blob)

        kbps = self.modem_config.modem_bps / 1e3
        msg = 'Sending to Audio MODEM ({0:.1f} kbps)...'.format(kbps)
        return WaitingDialog(parent=parent, message=msg, run_task=sender_thread)
Example #5
0
 def get_pin(self, msg):
     t = {
         'a': '7',
         'b': '8',
         'c': '9',
         'd': '4',
         'e': '5',
         'f': '6',
         'g': '1',
         'h': '2',
         'i': '3'
     }
     print_msg(msg)
     print_msg("a b c\nd e f\ng h i\n-----")
     o = raw_input()
     return ''.join(map(lambda x: t[x], o))
 def show_message(self, msg):
     print_msg(msg)
 def get_pin(self, msg):
     t = { 'a':'7', 'b':'8', 'c':'9', 'd':'4', 'e':'5', 'f':'6', 'g':'1', 'h':'2', 'i':'3'}
     print_msg(msg)
     print_msg("a b c\nd e f\ng h i\n-----")
     o = raw_input()
     return ''.join(map(lambda x: t[x], o))
 def get_passphrase(self, msg):
     import getpass
     print_msg(msg)
     return getpass.getpass('')
 def get_pin(self, msg):
     t = {"a": "7", "b": "8", "c": "9", "d": "4", "e": "5", "f": "6", "g": "1", "h": "2", "i": "3"}
     print_msg(msg)
     print_msg("a b c\nd e f\ng h i\n-----")
     o = raw_input()
     return "".join(map(lambda x: t[x], o))
Example #10
0
 def on_success(blob):
     if blob:
         blob = zlib.decompress(blob)
         print_msg('Received:', repr(blob))
         parent.setText(blob)
Example #11
0
 def show_message(self, msg):
     print_msg(msg)
Example #12
0
 def get_passphrase(self, msg):
     import getpass
     print_msg(msg)
     return getpass.getpass('')