Ejemplo n.º 1
0
        def _read_lic_selection():
            entropy_client.output(
                darkred(_("Please select an option")),
                header="    ")
            entropy_client.output(
                "(%d) %s" % (
                    1,
                    darkgreen(_("Read the license"))),
                header="      ")
            entropy_client.output(
                "(%d) %s" % (
                    2,
                    brown(_("Accept the license (I've read it)"))),
                header="      ")
            entropy_client.output(
                "(%d) %s" % (
                    3,
                    darkred(_("Accept the license and don't "
                              "ask anymore (I've read it)"))),
                header="      ")
            entropy_client.output(
                "(%d) %s" % (0, bold(_("Quit"))),
                header="      ")

            # wait user interaction
            try:
                action = readtext(
                    "       %s: " % (
                        _("Your choice (type a number and press enter)"),)
                    )
            except EOFError:
                action = None
            return action
Ejemplo n.º 2
0
    def _selfile(self, entropy_client):
        entropy_client.output(
            darkred(
                _("Please choose a file to update by typing "
                  "its identification number.")))

        entropy_client.output(darkred(_("Other options are:")))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("-1")),
            darkgreen(_("Exit")),
        ))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("-3")),
            brown(_("Automerge all the files asking you one by one")),
        ))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("-5")),
            darkred(_("Automerge all the files without questioning")),
        ))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("-7")),
            brown(_("Discard all the files asking you one by one")),
        ))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("-9")),
            darkred(_("Discard all the files without questioning")),
        ))

        # wait user interaction
        try:
            action = readtext(
                _("Your choice (type a number and press enter):") + " ")
        except EOFError:
            action = None
        return action
Ejemplo n.º 3
0
        def _read_lic_selection():
            entropy_client.output(darkred(_("Please select an option")),
                                  header="    ")
            entropy_client.output("(%d) %s" %
                                  (1, darkgreen(_("Read the license"))),
                                  header="      ")
            entropy_client.output(
                "(%d) %s" % (2, brown(_("Accept the license (I've read it)"))),
                header="      ")
            entropy_client.output("(%d) %s" %
                                  (3,
                                   darkred(
                                       _("Accept the license and don't "
                                         "ask anymore (I've read it)"))),
                                  header="      ")
            entropy_client.output("(%d) %s" % (0, bold(_("Quit"))),
                                  header="      ")

            # wait user interaction
            try:
                action = readtext(
                    "       %s: " %
                    (_("Your choice (type a number and press enter)"), ))
            except EOFError:
                action = None
            return action
Ejemplo n.º 4
0
    def _selaction(self, entropy_client):
        entropy_client.output(darkred(
                _("Please choose an action to take for"
                  " the selected file.")))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("-1")),
                darkgreen(_("Come back to the files list")),
                ))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("1")),
                brown(_("Replace original with update")),
                ))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("2")),
                darkred(_("Delete update, keeping original as is")),
                ))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("3")),
                brown(_("Edit proposed file and show diffs again")),
                ))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("4")),
                brown(_("Interactively merge original with update")),
                ))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("5")),
                darkred(_("Show differences again")),
                ))

        # wait user interaction
        try:
            action = readtext(
                _("Your choice (type a number and press enter):")+" ")
        except EOFError:
            action = None
        return action
Ejemplo n.º 5
0
    def _selfile(self, entropy_client):
        entropy_client.output(
            darkred(
                _("Please choose a file to update by typing "
                  "its identification number.")))

        entropy_client.output(
            darkred(_("Other options are:")))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("-1")),
                darkgreen(_("Exit")),
                ))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("-3")),
                brown(_("Automerge all the files asking you one by one")),
                ))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("-5")),
                darkred(_("Automerge all the files without questioning")),
                ))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("-7")),
                brown(_("Discard all the files asking you one by one")),
                ))
        entropy_client.output(
            "  (%s) %s" % (
                blue(const_convert_to_unicode("-9")),
                darkred(_("Discard all the files without questioning")),
                ))

        # wait user interaction
        try:
            action = readtext(
                _("Your choice (type a number and press enter):")+" ")
        except EOFError:
            action = None
        return action
Ejemplo n.º 6
0
    def _selaction(self, entropy_client):
        entropy_client.output(
            darkred(
                _("Please choose an action to take for"
                  " the selected file.")))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("-1")),
            darkgreen(_("Come back to the files list")),
        ))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("1")),
            brown(_("Replace original with update")),
        ))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("2")),
            darkred(_("Delete update, keeping original as is")),
        ))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("3")),
            brown(_("Edit proposed file and show diffs again")),
        ))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("4")),
            brown(_("Interactively merge original with update")),
        ))
        entropy_client.output("  (%s) %s" % (
            blue(const_convert_to_unicode("5")),
            darkred(_("Show differences again")),
        ))

        # wait user interaction
        try:
            action = readtext(
                _("Your choice (type a number and press enter):") + " ")
        except EOFError:
            action = None
        return action
Ejemplo n.º 7
0
def handle_exception(exc_class, exc_instance, exc_tb):

    # restore original exception handler, to avoid loops
    uninstall_exception_handler()

    _text = TextInterface()

    if exc_class is SystemDatabaseError:
        _text.output(
            darkred(_("Installed packages repository corrupted. "
              "Please re-generate it")),
            importance=1,
            level="error")
        os._exit(101)

    generic_exc_classes = (OnlineMirrorError, RepositoryError,
        PermissionDenied, FileNotFound, SPMError, SystemError)
    if exc_class in generic_exc_classes:
        _text.output(
            "%s: %s" % (exc_instance, darkred(_("Cannot continue")),),
            importance=1,
            level="error")
        os._exit(1)

    if exc_class is SystemExit:
        return

    if issubclass(exc_class, IOError): # in Python 3.3+ it's BrokenPipeError
        if exc_instance.errno == errno.EPIPE:
            return

    if exc_class is KeyboardInterrupt:
        os._exit(1)

    t_back = entropy.tools.get_traceback(tb_obj = exc_tb)
    if const_debug_enabled():
        sys.stdout = sys.__stdout__
        sys.stderr = sys.__stderr__
        sys.stdin = sys.__stdin__
        entropy.tools.print_exception(tb_data = exc_tb)
        pdb.set_trace()

    if exc_class in (IOError, OSError):
        if exc_instance.errno == errno.ENOSPC:
            print_generic(t_back)
            _text.output(
                "%s: %s" % (
                    exc_instance,
                    darkred(_("Your hard drive is full! Your fault!")),),
                importance=1,
                level="error")
            os._exit(5)
        elif exc_instance.errno == errno.ENOMEM:
            print_generic(t_back)
            _text.output(
                "%s: %s" % (
                    exc_instance,
                    darkred(_("No more memory dude! Your fault!")),),
                importance=1,
                level="error")
            os._exit(5)

    _text.output(
        darkred(_("Hi. My name is Bug Reporter. "
          "I am sorry to inform you that the program crashed. "
          "Well, you know, shit happens.")),
        importance=1,
        level="error")
    _text.output(
        darkred(_("But there's something you could "
                  "do to help me to be a better application.")),
        importance=1,
        level="error")
    _text.output(
        darkred(
            _("-- BUT, DO NOT SUBMIT THE SAME REPORT MORE THAN ONCE --")),
        importance=1,
        level="error")
    _text.output(
        darkred(
            _("Now I am showing you what happened. "
              "Don't panic, I'm here to help you.")),
        importance=1,
        level="error")

    entropy.tools.print_exception(tb_data = exc_tb)

    exception_data = entropy.tools.print_exception(silent = True,
        tb_data = exc_tb, all_frame_data = True)
    exception_tback_raw = const_convert_to_rawstring(t_back)

    error_fd, error_file = None, None
    try:
        error_fd, error_file = const_mkstemp(
            prefix="entropy.error.report.",
            suffix=".txt")

        with os.fdopen(error_fd, "wb") as ferror:
            ferror.write(
                const_convert_to_rawstring(
                    "\nRevision: %s\n\n" % (
                        etpConst['entropyversion'],))
                )
            ferror.write(
                exception_tback_raw)
            ferror.write(
                const_convert_to_rawstring("\n\n"))
            ferror.write(
                const_convert_to_rawstring(''.join(exception_data)))
            ferror.write(
                const_convert_to_rawstring("\n"))

    except (OSError, IOError) as err:
        _text.output(
            "%s: %s" % (
                err,
                darkred(
                    _("Oh well, I cannot even write to TMPDIR. "
                      "So, please copy the error and "
                      "mail [email protected]."))),
            importance=1,
            level="error")
        os._exit(1)
    finally:
        if error_fd is not None:
            try:
                os.close(error_fd)
            except OSError:
                pass

    _text.output("", level="error")

    ask_msg = _("Erm... Can I send the error, "
                "along with some other information\nabout your "
                "hardware to my creators so they can fix me? "
                "(Your IP will be logged)")
    rc = _text.ask_question(ask_msg)
    if rc == _("No"):
        _text.output(
            darkgreen(_("Ok, ok ok ok... Sorry!")),
            level="error")
        os._exit(2)

    _text.output(
        darkgreen(
            _("If you want to be contacted back "
              "(and actively supported), also answer "
              "the questions below:")
            ),
        level="error")

    try:
        name = readtext(_("Your Full name:"))
        email = readtext(_("Your E-Mail address:"))
        description = readtext(_("What you were doing:"))
    except EOFError:
        os._exit(2)

    try:
        from entropy.client.interfaces.qa import UGCErrorReport
        from entropy.core.settings.base import SystemSettings
        _settings = SystemSettings()
        repository_id = _settings['repositories']['default_repository']
        error = UGCErrorReport(repository_id)
    except (OnlineMirrorError, AttributeError, ImportError,):
        error = None

    result = None
    if error is not None:
        error.prepare(exception_tback_raw, name, email,
            '\n'.join([x for x in exception_data]), description)
        result = error.submit()

    if result:
        _text.output(
            darkgreen(
                _("Thank you very much. The error has been "
                  "reported and hopefully, the problem will "
                  "be solved as soon as possible.")),
            level="error")
    else:
        _text.output(
            darkred(_("Ugh. Cannot send the report. "
                      "Please mail the file below "
                      "to [email protected].")),
            level="error")
        _text.output("", level="error")
        _text.output("==> %s" % (error_file,), level="error")
        _text.output("", level="error")
Ejemplo n.º 8
0
def handle_exception(exc_class, exc_instance, exc_tb):

    # restore original exception handler, to avoid loops
    uninstall_exception_handler()

    _text = TextInterface()

    if exc_class is SystemDatabaseError:
        _text.output(darkred(
            _("Installed packages repository corrupted. "
              "Please re-generate it")),
                     importance=1,
                     level="error")
        os._exit(101)

    generic_exc_classes = (OnlineMirrorError, RepositoryError,
                           PermissionDenied, FileNotFound, SPMError,
                           SystemError)
    if exc_class in generic_exc_classes:
        _text.output("%s: %s" % (
            exc_instance,
            darkred(_("Cannot continue")),
        ),
                     importance=1,
                     level="error")
        os._exit(1)

    if exc_class is SystemExit:
        return

    if issubclass(exc_class, IOError):  # in Python 3.3+ it's BrokenPipeError
        if exc_instance.errno == errno.EPIPE:
            return

    if exc_class is KeyboardInterrupt:
        os._exit(1)

    t_back = entropy.tools.get_traceback(tb_obj=exc_tb)
    if const_debug_enabled():
        sys.stdout = sys.__stdout__
        sys.stderr = sys.__stderr__
        sys.stdin = sys.__stdin__
        entropy.tools.print_exception(tb_data=exc_tb)
        pdb.set_trace()

    if exc_class in (IOError, OSError):
        if exc_instance.errno == errno.ENOSPC:
            print_generic(t_back)
            _text.output("%s: %s" % (
                exc_instance,
                darkred(_("Your hard drive is full! Your fault!")),
            ),
                         importance=1,
                         level="error")
            os._exit(5)
        elif exc_instance.errno == errno.ENOMEM:
            print_generic(t_back)
            _text.output("%s: %s" % (
                exc_instance,
                darkred(_("No more memory dude! Your fault!")),
            ),
                         importance=1,
                         level="error")
            os._exit(5)

    _text.output(darkred(
        _("Hi. My name is Bug Reporter. "
          "I am sorry to inform you that the program crashed. "
          "Well, you know, shit happens.")),
                 importance=1,
                 level="error")
    _text.output(darkred(
        _("But there's something you could "
          "do to help me to be a better application.")),
                 importance=1,
                 level="error")
    _text.output(darkred(
        _("-- BUT, DO NOT SUBMIT THE SAME REPORT MORE THAN ONCE --")),
                 importance=1,
                 level="error")
    _text.output(darkred(
        _("Now I am showing you what happened. "
          "Don't panic, I'm here to help you.")),
                 importance=1,
                 level="error")

    entropy.tools.print_exception(tb_data=exc_tb)

    exception_data = entropy.tools.print_exception(silent=True,
                                                   tb_data=exc_tb,
                                                   all_frame_data=True)
    exception_tback_raw = const_convert_to_rawstring(t_back)

    error_fd, error_file = None, None
    try:
        error_fd, error_file = const_mkstemp(prefix="entropy.error.report.",
                                             suffix=".txt")

        with os.fdopen(error_fd, "wb") as ferror:
            ferror.write(
                const_convert_to_rawstring("\nRevision: %s\n\n" %
                                           (etpConst['entropyversion'], )))
            ferror.write(exception_tback_raw)
            ferror.write(const_convert_to_rawstring("\n\n"))
            ferror.write(const_convert_to_rawstring(''.join(exception_data)))
            ferror.write(const_convert_to_rawstring("\n"))

    except (OSError, IOError) as err:
        _text.output("%s: %s" %
                     (err,
                      darkred(
                          _("Oh well, I cannot even write to TMPDIR. "
                            "So, please copy the error and "
                            "mail [email protected]."))),
                     importance=1,
                     level="error")
        os._exit(1)
    finally:
        if error_fd is not None:
            try:
                os.close(error_fd)
            except OSError:
                pass

    _text.output("", level="error")

    ask_msg = _("Erm... Can I send the error, "
                "along with some other information\nabout your "
                "hardware to my creators so they can fix me? "
                "(Your IP will be logged)")
    rc = _text.ask_question(ask_msg)
    if rc == _("No"):
        _text.output(darkgreen(_("Ok, ok ok ok... Sorry!")), level="error")
        os._exit(2)

    _text.output(darkgreen(
        _("If you want to be contacted back "
          "(and actively supported), also answer "
          "the questions below:")),
                 level="error")

    try:
        name = readtext(_("Your Full name:"))
        email = readtext(_("Your E-Mail address:"))
        description = readtext(_("What you were doing:"))
    except EOFError:
        os._exit(2)

    try:
        from entropy.client.interfaces.qa import UGCErrorReport
        from entropy.core.settings.base import SystemSettings
        _settings = SystemSettings()
        repository_id = _settings['repositories']['default_repository']
        error = UGCErrorReport(repository_id)
    except (
            OnlineMirrorError,
            AttributeError,
            ImportError,
    ):
        error = None

    result = None
    if error is not None:
        error.prepare(exception_tback_raw, name, email,
                      '\n'.join([x for x in exception_data]), description)
        result = error.submit()

    if result:
        _text.output(darkgreen(
            _("Thank you very much. The error has been "
              "reported and hopefully, the problem will "
              "be solved as soon as possible.")),
                     level="error")
    else:
        _text.output(darkred(
            _("Ugh. Cannot send the report. "
              "Please mail the file below "
              "to [email protected].")),
                     level="error")
        _text.output("", level="error")
        _text.output("==> %s" % (error_file, ), level="error")
        _text.output("", level="error")