Ejemplo n.º 1
0
    def test_match_get_problem_nonexistent(self):
        '''
        Test that match_get_problem exits on non-existent problem
        '''

        with self.assertRaises(SystemExit):
            match_get_problem('nope')
Ejemplo n.º 2
0
    def test_match_get_problem_nonexistent(self):
        '''
        Test that match_get_problem exits on non-existent problem
        '''

        with self.assertRaises(SystemExit):
            match_get_problem('nope')
Ejemplo n.º 3
0
    def test_match_get_problem_multiple(self):
        '''
        Test that match_get_problem fails when multiple problems match
        '''

        with captured_output() as (cap_stdout, cap_stderr):
            with self.assertRaises(SystemExit):
                match_get_problem('pavucontrol')

        stdout = cap_stdout.getvalue()
        self.assertIn("Ambiguous", stdout)
        self.assertIn("pavucontrol@bc60a5c", stdout)
        self.assertIn("pavucontrol@acbea5c", stdout)
Ejemplo n.º 4
0
    def test_match_get_problem_multiple(self):
        '''
        Test that match_get_problem fails when multiple problems match
        '''

        with captured_output() as (cap_stdout, cap_stderr):
            with self.assertRaises(SystemExit):
                match_get_problem('pavucontrol')

        stdout = cap_stdout.getvalue()
        self.assertIn("Ambiguous", stdout)
        self.assertIn("pavucontrol@bc60a5c", stdout)
        self.assertIn("pavucontrol@acbea5c", stdout)
Ejemplo n.º 5
0
    def test_match_get_problem_multiple_allowed(self):
        '''
        Test that match_get_problem matches multiple problems when allowed
        '''

        p = match_get_problem('pavucontrol', allow_multiple=True)
        self.assertEqual(len(p), 2)
Ejemplo n.º 6
0
    def test_match_get_problem_multiple_allowed(self):
        '''
        Test that match_get_problem matches multiple problems when allowed
        '''

        p = match_get_problem('pavucontrol', allow_multiple=True)
        self.assertEqual(len(p), 2)
Ejemplo n.º 7
0
    def test_match_get_problem_last(self):
        '''
        Test that match_get_problem matches last problem
        '''

        p = match_get_problem('last')
        self.assertEqual(p.uid, 1234)
Ejemplo n.º 8
0
    def test_match_get_problem_simple(self):
        '''
        Test that match_get_problem matches unique pattern
        '''

        p = match_get_problem('polkitd')
        self.assertEqual(p.component, 'polkitd')
Ejemplo n.º 9
0
def gdb(args):
    prob = match_get_problem(args.MATCH, auth=args.auth)
    if not isinstance(prob, problem.Ccpp):
        which = 'This'
        if args.MATCH == 'last':
            which = 'Last'

        print('{} problem is not of a C/C++ type. Can\'t run gdb'
              .format(which))
        sys.exit(1)

    prob.chown()

    if args.debuginfo_install:
        di_install(args)

    cmd = config.GDB_CMD.format(di_path=config.DEBUGINFO_PATH)

    with remember_cwd():
        try:
            os.chdir(prob.path)
        except OSError:
            print(_('Permission denied: \'{}\'\n'
                    'If this is a system problem'
                    ' try running this command as root')
                  .format(prob.path))
            sys.exit(1)
        subprocess.call(cmd, shell=True)
Ejemplo n.º 10
0
    def test_match_get_problem_last(self):
        '''
        Test that match_get_problem matches last problem
        '''

        p = match_get_problem('last')
        self.assertEqual(p.uid, 1234)
Ejemplo n.º 11
0
    def test_match_get_problem_simple(self):
        '''
        Test that match_get_problem matches unique pattern
        '''

        p = match_get_problem('polkitd')
        self.assertEqual(p.component, 'polkitd')
Ejemplo n.º 12
0
Archivo: cli.py Proyecto: xsuchy/abrt
def info(args):
    prob = match_get_problem(args.MATCH, allow_multiple=True, auth=args.auth)
    if not args.fmt:
        fmt = config.FULL_FMT

    if args.pretty != 'full':
        fmt = getattr(config, '{}_FMT'.format(args.pretty.upper()))

    print(fmt_problems(prob, fmt=fmt))
Ejemplo n.º 13
0
Archivo: cli.py Proyecto: jfilak/abrt
def info(args):
    prob = match_get_problem(args.MATCH, allow_multiple=True, auth=args.auth)
    if not args.fmt:
        fmt = config.FULL_FMT

    if args.pretty != "full":
        fmt = getattr(config, "{}_FMT".format(args.pretty.upper()))

    print(fmt_problems(prob, fmt=fmt))
Ejemplo n.º 14
0
def backtrace(args):
    prob = match_get_problem(args.MATCH, auth=args.auth)
    if hasattr(prob, 'backtrace'):
        print(fmt_problems(prob, fmt=config.BACKTRACE_FMT))
    else:
        print(_('Problem has no backtrace'))
        if isinstance(prob, problem.Ccpp):
            ret = ask_yes_no(_('Start retracing process?'))
            if ret:
                retrace(args)
                print(fmt_problems(prob, fmt=config.BACKTRACE_FMT))
Ejemplo n.º 15
0
def remove(args):
    prob = match_get_problem(args.MATCH, auth=args.auth)
    print(fmt_problems(prob, fmt=config.FULL_FMT))

    ret = True
    if not args.f and (args.i or args.MATCH == 'last'):
        # force prompt for last problem to avoid accidents
        ret = ask_yes_no(_('Are you sure you want to delete this problem?'))

    if ret:
        prob.delete()
        print(_('Removed'))
Ejemplo n.º 16
0
    def test_match_get_problem_empty_database(self):
        '''
        Test that match_get_problem handles no problems in database
        '''

        import problem

        with clitests.monkey_patch(problem, 'list', lambda *args, **kwargs: []):
            with captured_output() as (cap_stdout, cap_stderr):
                with self.assertRaises(SystemExit):
                    match_get_problem('nope')

            stdout = cap_stdout.getvalue()
            self.assertIn("No problem(s) matched", stdout)

            # Similar with last
            with captured_output() as (cap_stdout, cap_stderr):
                with self.assertRaises(SystemExit):
                    match_get_problem('last')

            stdout = cap_stdout.getvalue()
            self.assertIn("No problems", stdout)
Ejemplo n.º 17
0
    def test_match_get_problem_empty_database(self):
        '''
        Test that match_get_problem handles no problems in database
        '''

        import problem

        with clitests.monkey_patch(problem, 'list',
                                   lambda *args, **kwargs: []):
            with captured_output() as (cap_stdout, cap_stderr):
                with self.assertRaises(SystemExit):
                    match_get_problem('nope')

            stdout = cap_stdout.getvalue()
            self.assertIn("No problem(s) matched", stdout)

            # Similar with last
            with captured_output() as (cap_stdout, cap_stderr):
                with self.assertRaises(SystemExit):
                    match_get_problem('last')

            stdout = cap_stdout.getvalue()
            self.assertIn("No problems", stdout)
Ejemplo n.º 18
0
def report(args):
    prob = match_get_problem(args.MATCH, auth=args.auth)

    if prob.not_reportable and not args.unsafe:
        if reportclient.verbose > 0:
            print(prob.not_reportable_reason)

        print(_('Problem \'{0}\' cannot be reported').format(prob.short_id))
        sys.exit(1)

    flags = libreport.LIBREPORT_WAIT | libreport.LIBREPORT_RUN_CLI
    if args.unsafe:
        flags |= libreport.LIBREPORT_IGNORE_NOT_REPORTABLE

    prob.chown()

    libreport.report_problem_in_dir(prob.path, flags)
Ejemplo n.º 19
0
Archivo: cli.py Proyecto: jfilak/abrt
def retrace(args):
    # we might not get these var if called from backtrace
    local, remote, auth = False, False, False

    if hasattr(args, "local"):
        local = args.local
    if hasattr(args, "remote"):
        remote = args.remote
    if hasattr(args, "force"):
        force = args.force

    prob = match_get_problem(args.MATCH, auth=args.auth)
    if hasattr(prob, "backtrace") and not force:
        print(_("Problem already has a backtrace"))
        print(_("Run abrt retrace with -f/--force to retrace again"))
        ret = ask_yes_no(_("Show backtrace?"))
        if ret:
            print(fmt_problems(prob, fmt=config.BACKTRACE_FMT))
    elif not isinstance(prob, problem.Ccpp):
        print(_("No retracing possible for this problem type"))
    else:
        if not (local or remote):  # ask..
            ret = ask_yes_no(
                _(
                    "Upload core dump and perform remote"
                    " retracing? (It may contain sensitive data)."
                    " If your answer is 'No', a stack trace will"
                    " be generated locally. Local retracing"
                    " requires downloading potentially large amount"
                    " of debuginfo data"
                )
            )

            if ret:
                remote = True
            else:
                local = True

        prob.chown()

        if remote:
            print(_("Remote retracing"))
            run_event("analyze_RetraceServer", prob)
        else:
            print(_("Local retracing"))
            run_event("analyze_LocalGDB", prob)
Ejemplo n.º 20
0
def retrace(args):
    # we might not get these var if called from backtrace
    local, remote, auth = False, False, False

    if hasattr(args, 'local'):
        local = args.local
    if hasattr(args, 'remote'):
        remote = args.remote
    if hasattr(args, 'force'):
        force = args.force

    prob = match_get_problem(args.MATCH, auth=args.auth)
    if hasattr(prob, 'backtrace') and not force:
        print(_('Problem already has a backtrace'))
        print(_('Run abrt retrace with -f/--force to retrace again'))
        ret = ask_yes_no(_('Show backtrace?'))
        if ret:
            print(fmt_problems(prob, fmt=config.BACKTRACE_FMT))
    elif not isinstance(prob, problem.Ccpp):
        print(_('No retracing possible for this problem type'))
    else:
        if not (local or remote):  # ask..
            ret = ask_yes_no(
                _('Upload core dump and perform remote'
                  ' retracing? (It may contain sensitive data).'
                  ' If your answer is \'No\', a stack trace will'
                  ' be generated locally. Local retracing'
                  ' requires downloading potentially large amount'
                  ' of debuginfo data'))

            if ret:
                remote = True
            else:
                local = True

        prob.chown()

        if remote:
            print(_('Remote retracing'))
            run_event('analyze_RetraceServer', prob)
        else:
            print(_('Local retracing'))
            run_event('analyze_LocalGDB', prob)
Ejemplo n.º 21
0
Archivo: cli.py Proyecto: jfilak/abrt
def di_install(args):
    prob = match_get_problem(args.MATCH, auth=args.auth)
    if not isinstance(prob, problem.Ccpp):
        which = _("This")
        if args.MATCH == "last":
            which = _("Last")

        print(_("{} problem is not of a C/C++ type. Can't install debuginfo").format(which))
        sys.exit(1)

    prob.chown()

    with remember_cwd():
        try:
            os.chdir(prob.path)
        except OSError:
            print(
                _("Permission denied: '{}'\n" "If this is a system problem" " try running this command as root").format(
                    prob.path
                )
            )
            sys.exit(1)
        subprocess.call(config.DEBUGINFO_INSTALL_CMD, shell=True)
Ejemplo n.º 22
0
Archivo: cli.py Proyecto: xsuchy/abrt
def report(args):
    prob = match_get_problem(args.MATCH, auth=args.auth)
    libreport.report_problem_in_dir(
        prob.path, libreport.LIBREPORT_WAIT | libreport.LIBREPORT_RUN_CLI)
Ejemplo n.º 23
0
Archivo: cli.py Proyecto: jfilak/abrt
def report(args):
    prob = match_get_problem(args.MATCH, auth=args.auth)
    libreport.report_problem_in_dir(prob.path, libreport.LIBREPORT_WAIT | libreport.LIBREPORT_RUN_CLI)