def run_clicked_cb(self, btn):
        # collect method infos
        named_service = self._method.parent.parent.parent
        object_path = self._method.parent.parent.name
        iface_name = self._method.parent.name
        method_name = self._method.name
        if self._param_entry:
            user_params = markup_to_utf8(self._param_entry.entry)
        else:
            user_params = None

        # create the dbus proxy
        obj = bus.get_object(named_service, object_path)
        iface = dbus.Interface(obj, iface_name)
        meth = iface.get_dbus_method(method_name)

        # async method call # TODO make another  example for this
        try:
            if user_params:
                meth(eval(user_params),
                     reply_handler = self.reply_handler,
                     error_handler = self.error_handler)
            else:
                meth(reply_handler = self.reply_handler,
                     error_handler = self.error_handler)
        except Exception as e:
            s = "Error running method<br>Exception: "
            self._return_entry.entry = s + utf8_to_markup(str(e))
Ejemplo n.º 2
0
    def run_clicked_cb(self, btn):
        # collect method infos
        named_service = self._method.parent.parent.parent
        object_path = self._method.parent.parent.name
        iface_name = self._method.parent.name
        method_name = self._method.name
        if self._param_entry:
            user_params = markup_to_utf8(self._param_entry.entry)
        else:
            user_params = None

        # create the dbus proxy
        obj = bus.get_object(named_service, object_path)
        iface = dbus.Interface(obj, iface_name)
        meth = iface.get_dbus_method(method_name)

        # async method call # TODO make another  example for this
        try:
            if user_params:
                meth(eval(user_params),
                     reply_handler=self.reply_handler,
                     error_handler=self.error_handler)
            else:
                meth(reply_handler=self.reply_handler,
                     error_handler=self.error_handler)
        except Exception as e:
            s = "Error running method<br>Exception: "
            self._return_entry.entry = s + utf8_to_markup(str(e))
Ejemplo n.º 3
0
Archivo: ePad.py Proyecto: emctoo/ePad
    def fileSelected(self, fs, file_selected, onStartup=False):
        if not onStartup:
            self.flip.go(ELM_FLIP_INTERACTION_ROTATE)
            # Markup can end up in file names because file_selector name_entry
            #   is an elementary entry. So lets sanitize file_selected.
            file_selected = markup_to_utf8(file_selected)
        if file_selected:
            print("File Selected: {0}".format(file_selected))
            self.lastDir = os.path.dirname(file_selected)
            fs.path_set(self.lastDir)
            # This fails if file_selected does not exist yet
            try:
                fs.selected = file_selected
            except RuntimeError:
                # FIXME: would be nice if I could set fileSelector name entry
                pass

        IsSave = fs.is_save_get()

        if file_selected:
            if IsSave:
                if os.path.isdir(file_selected):
                    current_file = os.path.basename(file_selected)
                    errorMsg = ("<b>'%s'</b> is a folder."
                                "<br><br>Operation failed !!!"
                                % (current_file))
                    errorPopup(self.mainWindow, errorMsg)
                    return
                elif os.path.exists(file_selected):
                    self.fileExistsFlag = True
                    self.fileExists(file_selected)
                    return
        self.doSelected(file_selected)
Ejemplo n.º 4
0
 def commit_button_cb(self, bt):
     if not self.confirmed:
         self.confirmed = True
         bt.text = 'Are you sure?'
     else:
         bt.text = 'Commit'
         self.confirmed = False
         self.repo.commit(self.commit_done_cb,
                          markup_to_utf8(self.msg_entry.text))
Ejemplo n.º 5
0
Archivo: ePad.py Proyecto: emctoo/ePad
 def curChanged(self, entry, label):
     # get linear index into current text
     index = entry.cursor_pos_get()
     # Replace <br /> tag with single char
     #   to simplify (line, col) calculation
     tmp_text = markup_to_utf8(entry.entry_get())
     line = tmp_text[:index].count("\n") + 1
     col = len(tmp_text[:index].split("\n")[-1]) + 1
     # Update label text with line, col
     label.text = "Ln {0} Col {1} ".format(line, col)
Ejemplo n.º 6
0
 def commit_button_cb(self, bt):
     if not self.confirmed:
         self.confirmed = True
         bt.text = 'Are you sure?'
     elif self.revert_commit:
         bt.text = 'Revert'
         self.confirmed = False
         self.app.repo.revert(self.commit_done_cb, self.revert_commit,
                              auto_commit=self.autocommit_chk.state,
                              commit_msg=markup_to_utf8(self.msg_entry.text))
     elif self.cherrypick_commit:
         bt.text = 'Cherry-pick'
         self.confirmed = False
         self.app.repo.cherrypick(self.commit_done_cb, self.cherrypick_commit,
                                  auto_commit=self.autocommit_chk.state,
                                  commit_msg=markup_to_utf8(self.msg_entry.text))
     else:
         bt.text = 'Commit'
         self.confirmed = False
         self.app.repo.commit(self.commit_done_cb,
                              markup_to_utf8(self.msg_entry.text))
Ejemplo n.º 7
0
    def run_cmd(self, command, done_cb=None):
        '''Run command capture ouput'''
        command = markup_to_utf8(command)
        # pylint: disable=c-extension-no-member
        self.cmd_exe = cmd = ecore.Exe(
            command, ecore.ECORE_EXE_PIPE_READ | ecore.ECORE_EXE_PIPE_ERROR
            | ecore.ECORE_EXE_PIPE_WRITE)
        cmd.on_add_event_add(self.cb_started)
        cmd.on_data_event_add(self.cb_data)
        cmd.on_error_event_add(self.cb_error)
        cmd.on_del_event_add(self.cb_done)

        self.done_cb = done_cb
Ejemplo n.º 8
0
 def runCommand(self, command, done_cb=None):
     command = markup_to_utf8(command)
     self.cmd_exe = cmd = ecore.Exe(
         command,
         ecore.ECORE_EXE_PIPE_READ |
         ecore.ECORE_EXE_PIPE_ERROR |
         ecore.ECORE_EXE_PIPE_WRITE
     )
     cmd.on_add_event_add(self.command_started)
     cmd.on_data_event_add(self.received_data)
     cmd.on_error_event_add(self.received_error)
     cmd.on_del_event_add(self.command_done)
     
     self.done_cb = done_cb
Ejemplo n.º 9
0
    def esudo_ok(self, bt, en):
        password = HTMLParser().unescape(en.entry.encode('utf8'))
        if '&quot;' in self.cmdline.entry:
            #cmd = HTMLParser().unescape(self.cmdline.entry.encode('utf8'))
            cmd = markup_to_utf8(self.cmdline.entry)
        else:
            cmd = self.cmdline.entry
        cmdprts = cmd.split(" ")
        cmdnum = len(cmdprts)
        log.info("Starting '%s'..." % cmd)

        #This seems to break a lot of commands - what was it supposed to do?
        '''
        if cmdnum > 1:
            command = cmdprts[0]
            for i in range(cmdnum):
                if i > 0:
                    path = " ".join(cmdprts[i:])
                    if os.path.exists(path):
                        cmd = "%s '%s'" % (command, path)
                        break

        try:
            arguments = self.kwargs["cmdargs"]
            cmd = "%s %s" % (cmd, arguments)
        except Exception:
            pass'''

        #Old method. Using -E is cleaner
        #if not os.path.exists("/tmp/libesudo"):
        #    os.makedirs("/tmp/libesudo")
        #command  = "cp /home/%s/.Xauthority /tmp/libesudo"%getpass.getuser()
        #ecore.Exe(command, ecore.ECORE_EXE_PIPE_READ|ecore.ECORE_EXE_PIPE_ERROR|ecore.ECORE_EXE_PIPE_WRITE)

        #command  = "cp -a /home/%s/.elementary /tmp/libesudo"%getpass.getuser()
        #ecore.Exe(command, ecore.ECORE_EXE_PIPE_READ|ecore.ECORE_EXE_PIPE_ERROR|ecore.ECORE_EXE_PIPE_WRITE)

        #self.run_command("HOME='/tmp/libesudo' ; sudo -S %s" % (cmd), password)
        if cmd.split()[0] == 'pcmanfm':
            self.run_command("HOME=/root sudo -S %s" % (cmd), password)
        else:
            self.run_command("sudo -ES %s" % (cmd), password)
Ejemplo n.º 10
0
    def esudo_ok(self, bt, en):
        password = HTMLParser().unescape(en.entry.encode('utf8'))
        if '&quot;' in self.cmdline.entry:
            #cmd = HTMLParser().unescape(self.cmdline.entry.encode('utf8'))
            cmd = markup_to_utf8(self.cmdline.entry)
        else:
            cmd = self.cmdline.entry
        cmdprts = cmd.split(" ")
        cmdnum = len(cmdprts)
        log.info("Starting '%s'..." % cmd)

        #This seems to break a lot of commands - what was it supposed to do?
        '''
        if cmdnum > 1:
            command = cmdprts[0]
            for i in range(cmdnum):
                if i > 0:
                    path = " ".join(cmdprts[i:])
                    if os.path.exists(path):
                        cmd = "%s '%s'" % (command, path)
                        break

        try:
            arguments = self.kwargs["cmdargs"]
            cmd = "%s %s" % (cmd, arguments)
        except Exception:
            pass'''

        #Old method. Using -E is cleaner
        #if not os.path.exists("/tmp/libesudo"):
        #    os.makedirs("/tmp/libesudo")
        #command  = "cp /home/%s/.Xauthority /tmp/libesudo"%getpass.getuser()
        #ecore.Exe(command, ecore.ECORE_EXE_PIPE_READ|ecore.ECORE_EXE_PIPE_ERROR|ecore.ECORE_EXE_PIPE_WRITE)

        #command  = "cp -a /home/%s/.elementary /tmp/libesudo"%getpass.getuser()
        #ecore.Exe(command, ecore.ECORE_EXE_PIPE_READ|ecore.ECORE_EXE_PIPE_ERROR|ecore.ECORE_EXE_PIPE_WRITE)

        #self.run_command("HOME='/tmp/libesudo' ; sudo -S %s" % (cmd), password)
        self.run_command("sudo -ES %s" % (cmd), password)
Ejemplo n.º 11
0
 def _exec_clicked_cb(self, bt, entry, exec_cb):
     cmd = markup_to_utf8(entry.text)
     self.delete()
     exec_cb(cmd)