Exemplo n.º 1
0
    def load(self):
        status = self.get_widget("status")
        helper.run_in_main_thread(status.set_text, _("Loading..."))
        self.items = self.vcs.get_items(self.paths, self.statuses)

        if self.show_ignored:
            for path in self.paths:
                # TODO Refactor
                # TODO SVN support
                # TODO Further fix ignore patterns
                if rabbitvcs.vcs.guess(path)['vcs'] == rabbitvcs.vcs.VCS_GIT:
                    git = self.vcs.git(path)
                    for ignored_path in git.client.get_all_ignore_file_paths(path):
                        should_add = True
                        for item in self.items:
                            if item.path == os.path.realpath(ignored_path):
                                should_add = False

                        if should_add:
                            self.items.append(Status(os.path.realpath(ignored_path), 'unversioned'))



        self.populate_files_table()
        helper.run_in_main_thread(status.set_text, _("Found %d item(s)") % len(self.items))
Exemplo n.º 2
0
    def load(self):
        status = self.get_widget("status")
        helper.run_in_main_thread(status.set_text, _("Loading..."))
        self.items = self.vcs.get_items(self.paths, self.statuses)

        if self.show_ignored:
            for path in self.paths:
                # TODO Refactor
                # TODO SVN support
                # TODO Further fix ignore patterns
                if rabbitvcs.vcs.guess(path)['vcs'] == rabbitvcs.vcs.VCS_GIT:
                    git = self.vcs.git(path)
                    for ignored_path in git.client.get_all_ignore_file_paths(
                            path):
                        should_add = True
                        for item in self.items:
                            if item.path == os.path.realpath(ignored_path):
                                should_add = False

                        if should_add:
                            self.items.append(
                                Status(os.path.realpath(ignored_path),
                                       'unversioned'))

        self.populate_files_table()
        helper.run_in_main_thread(status.set_text,
                                  _("Found %d item(s)") % len(self.items))
Exemplo n.º 3
0
    def close(self, threaded=False):
        window = self.get_widget(self.gtkbuilder_id)
        if window is not None:
            if threaded:
                helper.run_in_main_thread(window.destroy)
            else:
                window.destroy()

        if self.do_gtk_quit:
            Gtk.main_quit()
Exemplo n.º 4
0
    def close(self, threaded=False):
        window = self.get_widget(self.gtkbuilder_id)
        if window is not None:
            if threaded:
                helper.run_in_main_thread(window.destroy)
            else:
                window.destroy()

        if self.do_gtk_quit:
            Gtk.main_quit()
Exemplo n.º 5
0
    def on_repositories_changed(self, widget, data=None):
        url = self.repositories.get_active_text()
        tmp = [x.strip() for x in url.split("/") if x.strip()]
        if tmp and tmp[0].lower() in ("http:", "https:", "file:", "git:"):
            del tmp[0]
        append = tmp[-1] if tmp else ""
        if append.endswith(".git"):
            append = append[:-4]

        helper.run_in_main_thread(self.get_widget("destination").set_text,
                                  os.path.join(self.destination, append))
        self.check_form()
Exemplo n.º 6
0
    def on_repositories_changed(self, widget, data=None):
        url = self.repositories.get_active_text()
        tmp = [x.strip() for x in url.split("/") if x.strip()]
        if tmp and tmp[0].lower() in ("http:", "https:", "file:", "git:"):
            del tmp[0]
        append = tmp[-1] if tmp else ""
        if append.endswith(".git"):
            append = append[:-4]

        helper.run_in_main_thread(
            self.get_widget("destination").set_text,
            S(os.path.join(self.destination, append)).display())
        self.check_form()
Exemplo n.º 7
0
    def get_log_message(self):
        """
        A callback method that retrieves a supplied log message.

        Returns a list where the first element is True/False.  Returning true
        tells the action to continue, false tells it to cancel.  The second
        element is the log message, which is specified by self.message.
        self.message is set by calling the self.set_log_message() method from
        the UI interface class.

        @rtype:  (boolean, string)
        @return: (True=continue/False=cancel, log message)

        """

        should_continue = True
        message = self.message
        if message is None:
            settings = rabbitvcs.util.settings.SettingsManager()
            message = settings.get_multiline("general", "default_commit_message")
            result = helper.run_in_main_thread(lambda: rabbitvcs.ui.dialog.TextChange(_("Log Message"), message).run())
            should_continue = (result[0] == Gtk.ResponseType.OK)
            message = result[1]
        if isinstance(message, bytes):
            message = message.decode()
        if not should_continue:
            self.set_cancel()
        return should_continue, message
Exemplo n.º 8
0
    def get_login(self, realm, username, may_save):
        """
        A callback method that requests a username/password to login to a
        password-protected repository.  This method runs the Authentication
        dialog, which provides a username, password, and saving widget.  The
        dialog returns a tuple, which is returned directly to the VCS caller.

        If the login fails greater than three times, cancel the action.

        The dialog must be called from within a threaded block, otherwise it
        will not be responsive.

        @type   realm:      string
        @param  realm:      The realm of the repository.

        @type   username:   string
        @param  username:   Username passed by the vcs caller.

        @type   may_save:   boolean
        @param  may_save:   Whether or not the authentication can be saved.

        @rtype:             (boolean, string, string, boolean)
        @return:            (True=continue/False=cancel, username,password, may_save)
        """

        if self.login_tries >= 3:
            return (False, "", "", False)

        result = helper.run_in_main_thread(lambda: rabbitvcs.ui.dialog.Authentication(realm, may_save).run)

        if result is not None:
            self.login_tries += 1

        return result
Exemplo n.º 9
0
    def get_ssl_trust(self, data):
        """
        A callback method that requires the user to either accept or deny
        a certificate from an ssl secured repository.  It opens a dialog that
        shows the user information about the ssl certificate and then gives
        them the option of denying, accepting, or accepting once.

        The dialog must be called from within a threaded block, otherwise it
        will not be responsive.

        @type   data:   dictionary
        @param  data:   A dictionary with SSL certificate info.

        @rtype:         (boolean, int, boolean)
        @return:        (True=Accept/False=Deny, number of accepted failures, remember)
        """

        result = 0
        if data:
            result = helper.run_in_main_thread(
                lambda: rabbitvcs.ui.dialog.Certificate(
                    data["realm"], data["hostname"], data["issuer_dname"],
                    data["valid_from"], data["valid_until"], data[
                        "finger_print"]).run())

        if result == 0:
            #Deny
            return (False, 0, False)
        elif result == 1:
            #Accept Once
            return (True, data["failures"], False)
        elif result == 2:
            #Accept Forever
            return (True, data["failures"], True)
Exemplo n.º 10
0
    def get_client_cert(self, realm, may_save):
        """
        A callback method that is used to get an ssl certificate.

        The dialog must be called from within a threaded block, otherwise it
        will not be responsive.

        @type   realm:      string
        @param  realm:      The certificate realm.

        @type   may_save:   boolean
        @param  may_save:   Whether or not the passphrase can be saved.

        @rtype:             (boolean, string, boolean)
        @return:            (True=continue/False=cancel, password, may save)
        """

        return helper.run_in_main_thread(
            lambda: rabbitvcs.ui.dialog.SSLClientCertPrompt(realm, may_save
                                                            ).run())
Exemplo n.º 11
0
    def get_client_cert(self, realm, may_save):
        """
        A callback method that is used to get an ssl certificate.

        The dialog must be called from within a threaded block, otherwise it
        will not be responsive.

        @type   realm:      string
        @param  realm:      The certificate realm.

        @type   may_save:   boolean
        @param  may_save:   Whether or not the passphrase can be saved.

        @rtype:             (boolean, string, boolean)
        @return:            (True=continue/False=cancel, password, may save)
        """

        return helper.run_in_main_thread(lambda: rabbitvcs.ui.dialog.SSLClientCertPrompt(
                realm,
                may_save
            ).run)
Exemplo n.º 12
0
    def get_log_message(self):
        """
        A callback method that retrieves a supplied log message.

        Returns a list where the first element is True/False.  Returning true
        tells the action to continue, false tells it to cancel.  The second
        element is the log message, which is specified by self.message.
        self.message is set by calling the self.set_log_message() method from
        the UI interface class.

        @rtype:  (boolean, string)
        @return: (True=continue/False=cancel, log message)

        """

        if self.message is None:
            result = helper.run_in_main_thread(lambda: rabbitvcs.ui.dialog.TextChange(_("Log Message")).run)
            should_continue = (result[0] == Gtk.ResponseType.OK)
            return should_continue, result[1].encode("utf-8")
        else:
            return True, self.message.encode("utf-8")
Exemplo n.º 13
0
    def get_ssl_trust(self, data):
        """
        A callback method that requires the user to either accept or deny
        a certificate from an ssl secured repository.  It opens a dialog that
        shows the user information about the ssl certificate and then gives
        them the option of denying, accepting, or accepting once.

        The dialog must be called from within a threaded block, otherwise it
        will not be responsive.

        @type   data:   dictionary
        @param  data:   A dictionary with SSL certificate info.

        @rtype:         (boolean, int, boolean)
        @return:        (True=Accept/False=Deny, number of accepted failures, remember)
        """

        result = 0
        if data:
            result = helper.run_in_main_thread(lambda: rabbitvcs.ui.dialog.Certificate(
                data["realm"],
                data["hostname"],
                data["issuer_dname"],
                data["valid_from"],
                data["valid_until"],
                data["finger_print"]
            ).run)

        if result == 0:
            #Deny
            return (False, 0, False)
        elif result == 1:
            #Accept Once
            return (True, data["failures"], False)
        elif result == 2:
            #Accept Forever
            return (True, data["failures"], True)
Exemplo n.º 14
0
 def newfunc(*args, **kwargs):
     return helper.run_in_main_thread(func, *args, **kwargs)
Exemplo n.º 15
0
 def get_user(self):
     return helper.run_in_main_thread(lambda: rabbitvcs.ui.dialog.NameEmailPrompt().run)
Exemplo n.º 16
0
    def load_logs(self):
        helper.run_in_main_thread(self.get_widget("status").set_text, _("Loading..."))

        self.load_push_log()
        helper.run_in_main_thread(self.load_logs_exit)
Exemplo n.º 17
0
 def newfunc(*args, **kwargs):
     return helper.run_in_main_thread(func, *args, **kwargs)
Exemplo n.º 18
0
    def load_logs(self):
        helper.run_in_main_thread(
            self.get_widget("status").set_text, _("Loading..."))

        self.load_push_log()
        helper.run_in_main_thread(self.load_logs_exit)