def run(self, arguments): problems = match_get_problems(arguments.patterns, authenticate=arguments.authenticate, executables=arguments.executables, components=arguments.components, since=arguments.since, until=arguments.until, n_latest=arguments.n_latest, not_reported=arguments.not_reported) for problem in problems: if problem.not_reportable and not arguments.unsafe: if reportclient.verbose > 0: print(problem.not_reportable_reason) print(_('Problem \'{0}\' cannot be reported').format(problem.short_id)) sys.exit(1) flags = report.LIBREPORT_WAIT | report.LIBREPORT_RUN_CLI if arguments.unsafe: flags |= report.LIBREPORT_IGNORE_NOT_REPORTABLE problem.chown() print(_("Reporting problem %s\n" % (problem.short_id))) report.report_problem_in_dir(problem.path, flags) if arguments.delete: problem.delete(problem.path)
def run(self, arguments): problems = match_get_problems(arguments.patterns, authenticate=arguments.authenticate, executables=arguments.executables, components=arguments.components, since=arguments.since, until=arguments.until, n_latest=arguments.n_latest, not_reported=arguments.not_reported) for problem in problems: if not isinstance(problem, Ccpp): print( _('The problem is not of a C/C++ type. Can\'t install debuginfo' )) sys.exit(1) problem.chown() with remember_cwd(): try: os.chdir(problem.path) except OSError: print( _('Permission denied: \'{}\'\n' 'If this is a system problem' ' try running this command as root').format( problem.path)) sys.exit(1) subprocess.call(config.DEBUGINFO_INSTALL_CMD, shell=True)
def add_format_arguments(self, default_pretty='full'): group = self._parser.add_mutually_exclusive_group() group.add_argument('--format', type=str, help=_('output format')) group.add_argument('--pretty', type=str, choices=config.FORMATS, default=default_pretty, help=_('built-in output format'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.add_filter_arguments() self.add_match_argument() self.parser.add_argument('-d', '--delete', action='store_true', help=_('remove after reporting')) self.parser.add_argument('--unsafe', action='store_true', help=_('ignore unreportable state'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.add_filter_arguments() self.parser.add_argument('-b', '--bare', action='store_true', help=_('show only the number of problems')) self.parser.add_argument( '-q', '--quiet', action='store_true', help=_('only show output if at least one problem is found'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.add_filter_arguments() self.add_match_argument() group = self.parser.add_mutually_exclusive_group() group.add_argument('-l', '--local', action='store_true', help=_('perform retracing locally')) group.add_argument('-r', '--remote', action='store_true', help=_('submit core dump for remote retracing')) self.parser.add_argument('-f', '--force', action='store_true', help=_('force retracing'))
def __init__(self, option_strings, dest): super().__init__(option_strings=option_strings, dest=dest, nargs=0, default=0, required=False, help=_('increase output verbosity'))
def add_match_argument(self): self._parser.add_argument( 'patterns', nargs='*', type=str, metavar='PATTERN', help=_('path to the problem directory, problem ID or wildcard'))
def match_get_problems(patterns, authenticate=False, executables=None, components=None, since=None, until=None, n_latest=None, not_reported=False): ''' Return problem matching `problem_matches` pattern or exit if there are no such problems. ''' probs = match_lookup(patterns, authenticate=authenticate, executables=executables, components=components, since=since, until=until, n_latest=n_latest, not_reported=not_reported) if not probs: print(_('No matching problems found')) sys.exit(1) return probs
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.add_filter_arguments() self.add_match_argument() self.parser.add_argument('-d', '--debuginfo-install', action='store_true', help=_('install debuginfo packages before launching GDB'))
def run(self, arguments): problems = match_get_problems(arguments.patterns, authenticate=arguments.authenticate, executables=arguments.executables, components=arguments.components, since=arguments.since, until=arguments.until, n_latest=arguments.n_latest, not_reported=arguments.not_reported) for problem in problems: print(format_problems(problem, fmt=config.FULL_FMT), '\n') if not arguments.force: if not ask_yes_no( _('Are you sure you want to delete this problem?')): continue problem.delete() print(_('Removed'), '\n')
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.add_filter_arguments() self.add_match_argument() self.parser.add_argument('-f', '--force', action='store_true', help=_('do not prompt before removal'))
def run(self, arguments): problems = match_get_problems(arguments.patterns, authenticate=arguments.authenticate, executables=arguments.executables, components=arguments.components, since=arguments.since, until=arguments.until, n_latest=arguments.n_latest, not_reported=arguments.not_reported) for problem in problems: if hasattr(problem, 'backtrace'): print(format_problems(problem, fmt=config.BACKTRACE_FMT)) else: print(_('Problem has no backtrace')) if isinstance(problem, Ccpp): if ask_yes_no(_('Start retracing process?')): run_command('retrace', arguments) print( format_problems(problem, fmt=config.BACKTRACE_FMT))
def run(self, arguments): problems = match_lookup(['*'], authenticate=arguments.authenticate, executables=arguments.executables, components=arguments.components, since=arguments.since, until=arguments.until, n_latest=arguments.n_latest, not_reported=arguments.not_reported) if problems: fmt = arguments.format if not fmt: fmt = getattr(config, '%s_FMT' % (arguments.pretty.upper())) print(format_problems(problems, fmt=fmt)) else: print(_('No problems'))
def run(self, arguments): # We don’t get these bad boys when invoked by the “backtrace” command. local = getattr(arguments, 'local', False) remote = getattr(arguments, 'remote', False) force = getattr(arguments, 'force', False) problems = match_get_problems(arguments.patterns, authenticate=arguments.authenticate, executables=arguments.executables, components=arguments.components, since=arguments.since, until=arguments.until, n_latest=arguments.n_latest, not_reported=arguments.not_reported) for problem in problems: if hasattr(problem, 'backtrace') and not force: print(_('Problem already has a backtrace')) print(_('Run abrt retrace with -f/--force to retrace again')) if ask_yes_no(_('Show backtrace?')): print(format_problems(problem, fmt=config.BACKTRACE_FMT)) elif not isinstance(problem, Ccpp): print(_('No retracing possible for this problem type')) else: if not (local or remote): 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 problem.chown() if remote: print(_('Remote retracing')) run_event('analyze_RetraceServer', problem) else: print(_('Local retracing')) run_event('analyze_LocalGDB', problem)
def add_filter_arguments(self): group = self._parser.add_argument_group() def uint(string): index = int(string) if index < 1: raise ArgumentTypeError( _('positive non-zero integer expected')) return index group.add_argument('-N', type=uint, dest='n_latest', metavar='COUNT', help=_('filter last N problems')) group.add_argument('-c', '--component', action='append', type=str, dest='components', metavar='COMPONENT', help=_('filter problems with matching component')) group.add_argument('-n', '--not-reported', action='store_true', help=_('filter unreported problems')) group.add_argument( '-s', '--since', type=int, metavar='TIMESTAMP', help=_('filter problems older than the specified timestamp')) group.add_argument( '-u', '--until', type=int, metavar='TIMESTAMP', help=_('filter problems newer than the specified timestamp')) group.add_argument('-x', '--executable', type=str, dest='executables', metavar='EXECUTABLE', help=_('filter problems with matching executable'))
def uint(string): index = int(string) if index < 1: raise ArgumentTypeError( _('positive non-zero integer expected')) return index
def format_problems(problems, fmt=MEDIUM_FMT): ''' Return preformatted problem data of `problems` according to `fmt` ''' if problems is None: return '' if not isinstance(problems, list): problems = [problems] fmt = fmt.replace('|', '\n') tabular = '#table' in fmt oneline = '\n' not in fmt out = '' for problem in problems: what_field, what = get_human_identifier(problem) context_vars = { 'what': what, 'what_field': what_field, } uid = get_problem_field(problem, 'uid') if uid is not None: username = get_problem_field(problem, 'username') if username: uid_username = ('{0} ({1})'.format(uid, username)) else: uid_username = str(uid) context_vars['uid_username'] = uid_username if problem.not_reportable: context_vars['not_reportable'] = _('Not reportable') reason = problem.not_reportable_reason.rstrip() if tabular: reason = reason.replace('\n', '\n,') context_vars['not_reportable_reason'] = reason if hasattr(problem, 'reported_to'): r_out = '' rtl = problem.reported_to.splitlines() # each reported to line item as separate row # except for BTHASH for rline in rtl: if 'BTHASH' in rline: continue if 'URL=' in rline: rep_to, url = rline.split('URL=', 1) if ': ' in rep_to: rep_to, _rest = rep_to.split(': ') if tabular: r_out += '\n{},{}'.format(rep_to, url) if r_out: context_vars['reported_to'] = r_out if hasattr(problem, 'backtrace'): if not oneline: context_vars['backtrace'] = '\n' + problem.backtrace if not hasattr(problem, 'count'): context_vars['count'] = 1 sfmt = fmt.splitlines() for line in sfmt: if not line.rstrip(): if tabular: out += ',\n' elif not oneline: out += '\n' continue if line[0] == '#': # output mode selector or comment continue template_vars = braces_re.findall(line) missing_var = False for var in template_vars: # try looking up missing context var in problem items if var not in context_vars: val = get_problem_field(problem, var) if val: context_vars[var] = val else: missing_var = True context_vars[var] = '' if not missing_var or oneline: fmtline = line.format(**context_vars) if not oneline: fmtline = upcase_first_letter(fmtline) out += fmtline + '\n' # separator if tabular: out += ',\n' elif not oneline: out += '\n' if tabular: rows = out.splitlines() rows = map(lambda x: x.split(',', 1), rows) out = as_table(list(rows)[:-1]) else: out = out.replace('\n\n', '\n') return out.rstrip()