示例#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')
示例#2
0
文件: test_match.py 项目: abrt/abrt
    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')
示例#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)
示例#4
0
文件: test_match.py 项目: abrt/abrt
    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)
示例#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)
示例#6
0
文件: test_match.py 项目: abrt/abrt
    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)
示例#7
0
文件: test_match.py 项目: abrt/abrt
    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)
示例#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')
示例#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)
示例#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)
示例#11
0
文件: test_match.py 项目: abrt/abrt
    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')
示例#12
0
文件: cli.py 项目: 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))
示例#13
0
文件: cli.py 项目: 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))
示例#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))
示例#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'))
示例#16
0
文件: test_match.py 项目: abrt/abrt
    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)
示例#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)
示例#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)
示例#19
0
文件: cli.py 项目: 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)
示例#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)
示例#21
0
文件: cli.py 项目: 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)
示例#22
0
文件: cli.py 项目: 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)
示例#23
0
文件: cli.py 项目: 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)