def Run(self, args): """Run the delete command.""" project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) logpoints = debuggee.ListBreakpoints( args.location, resource_ids=args.ids, include_all_users=args.all_users, include_inactive=args.include_inactive, restrict_to_type=debugger.LOGPOINT_TYPE) if logpoints: logpoint_list = StringIO.StringIO() resource_printer.Print( logpoints, 'table(location, condition, logLevel, logMessageFormat, id)', logpoint_list) console_io.PromptContinue( message=('This command will delete the following logpoints:' '\n\n{0}\n'.format(logpoint_list.getvalue())), cancel_on_no=True) for s in logpoints: debuggee.DeleteBreakpoint(s.id) # Guaranteed we have at least one logpoint, since ListMatchingBreakpoints # would raise an exception otherwise. if len(logpoints) == 1: log.status.write('Deleted 1 logpoint.\n') else: log.status.write('Deleted {0} logpoints.\n'.format(len(logpoints))) return logpoints
def Run(self, args): """Run the list command.""" if args.include_expired: # The (deprecated, hidden) --include-expired argument is equivalent to # --include_inactive=unlimited log.warn( 'The --include-expired flag has been deprecated. Please use ' '--include-inactive=unlimited instead.') args.include_inactive = None project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) logpoints = debuggee.ListBreakpoints( args.id_or_location_regexp, include_all_users=args.all_users, include_inactive=(args.include_inactive != 0), restrict_to_type=debugger.LOGPOINT_TYPE) # Filter any results more than include_inactive seconds old. # include_inactive may be None, which means we do not want to filter the # results. if args.include_inactive > 0: cutoff_time = (times.Now(times.UTC) - datetime.timedelta(seconds=args.include_inactive)) logpoints = [ lp for lp in logpoints if _ShouldInclude(lp, cutoff_time) ] return logpoints
def Run(self, args): """Run the wait command.""" project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) snapshots = [ s for s in debuggee.ListBreakpoints(args.location, resource_ids=args.ids, include_all_users=args.all_users) ] ids = [s.id for s in snapshots] if not ids: self._is_partial = False return [] if len(ids) == 1: log.status.Print('Waiting for 1 snapshot.') else: log.status.Print('Waiting for {0} snapshots.'.format(len(ids))) snapshots = debuggee.WaitForMultipleBreakpoints(ids, wait_all=args.all, timeout=args.timeout) self._is_partial = args.all and len(snapshots) != len(ids) return snapshots
def Run(self, args): """Run the describe command.""" project_id = properties.VALUES.core.project.Get(required=True) self.user_email = properties.VALUES.core.account.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) return [debuggee.GetBreakpoint(args.id)]
def Run(self, args): """Run the describe command.""" project_id = properties.VALUES.core.project.Get(required=True) self.user_email = properties.VALUES.core.account.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) return debuggee.ListBreakpoints(args.id_or_location_regexp, restrict_to_type=debugger.SNAPSHOT_TYPE)
def Run(self, args): """Run the list command.""" project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) # Include stale debuggees whenever including inactive debuggees. # It is likely not important to expose the ability to display stale versions # without displaying all inactive versions. If users request the feature, # we should add a second flag to allow including stale versions that are # not inactive. return debugger.ListDebuggees(include_inactive=args.include_inactive, include_stale=args.include_inactive)
def Run(self, args): """Run the describe command.""" project_id = properties.VALUES.core.project.Get(required=True) self.user_email = properties.VALUES.core.account.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) return debuggee.ListBreakpoints(args.location, include_all_users=True, resource_ids=args.ids, restrict_to_type=debugger.SNAPSHOT_TYPE, full_details=True)
def Run(self, args): """Run the list command.""" project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) return [ l for l in debuggee.ListBreakpoints( include_all_users=args.all_users, include_inactive=args.include_expired, restrict_to_type=debugger.SNAPSHOT_TYPE) if self._ShouldInclude(args, l)]
def Run(self, args): """Run the create command.""" project_id = properties.VALUES.core.project.Get(required=True) user_email = properties.VALUES.core.account.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) snapshot = debuggee.CreateSnapshot(location=args.location, expressions=args.expression, condition=args.condition, user_email=user_email) final_snapshot = debuggee.WaitForBreakpoint(snapshot.id, args.wait) return final_snapshot or snapshot
def Run(self, args): """Run the delete command.""" project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) logpoints = debuggee.ListMatchingBreakpoints( args.id_or_location_regexp, include_all_users=args.all_users, include_inactive=args.include_inactive, restrict_to_type=debugger.LOGPOINT_TYPE) for s in logpoints: debuggee.DeleteBreakpoint(s.id) return logpoints
def Run(self, args): """Run the delete command.""" project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) snapshots = debuggee.ListMatchingBreakpoints( args.id_or_location_regexp, include_all_users=args.all_users, include_inactive=args.include_inactive, restrict_to_type=debugger.SNAPSHOT_TYPE) print 'Deleting snapshots: {0}\n----'.format(snapshots) for s in snapshots: debuggee.DeleteBreakpoint(s.id) return snapshots
def Run(self, args): """Run the create command.""" project_id = properties.VALUES.core.project.Get(required=True) user_email = properties.VALUES.core.account.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) snapshot = debuggee.CreateSnapshot( location=args.location, expressions=args.expression, condition=args.condition, user_email=user_email) final_snapshot = debuggee.WaitForBreakpointSet(snapshot.id, args.wait, args.location) if args.location != final_snapshot.location: log.status.write( 'The debugger adjusted the snapshot location to {0}'.format( final_snapshot.location)) return final_snapshot or snapshot
def Run(self, args): """Run the list command.""" project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) snapshots = debuggee.ListBreakpoints( args.location, resource_ids=args.ids, include_all_users=args.all_users, include_inactive=(args.include_inactive != 0), restrict_to_type=debugger.SNAPSHOT_TYPE) # Filter any results more than include_inactive seconds old. # include_inactive may be None, which means we do not want to filter the # results. if args.include_inactive: cutoff_time = (times.Now(times.UTC) - datetime.timedelta(seconds=args.include_inactive)) snapshots = [s for s in snapshots if _ShouldInclude(s, cutoff_time)] return snapshots
def Run(self, args): """Run the create command.""" project_id = properties.VALUES.core.project.Get(required=True) user_email = properties.VALUES.core.account.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) logpoint = debuggee.CreateLogpoint( location=args.location, log_level=args.log_level, log_format_string=args.log_format_string, condition=args.condition, user_email=user_email) # Wait a short time to see if the logpoint generates an error. Ideally, # we'd want to wait until we get a response that the logpoint was set # by at least one instance, but the API does not currently support that. final_logpoint = debuggee.WaitForBreakpoint(logpoint.id, args.wait) return final_logpoint or logpoint
def Run(self, args): """Run the wait command.""" project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) debuggee = debugger.FindDebuggee(args.target) ids = set(args.id_or_location_regexp) patterns = [re.compile(r) for r in args.id_or_location_regexp] snapshots = [ s for s in debuggee.ListBreakpoints(include_all_users=args.all_users, include_inactive=True) if _MatchesIdOrRegexp(s, ids, patterns) ] all_ids = set([s.id for s in snapshots]) explicit_ids = [i for i in args.id_or_location_regexp if i in all_ids] # Look for all explicitly-requested snapshots plus any matching snapshots # that are not completed. Completed snapshots which were not requested would # just be noise in the output. snapshots = [ s for s in snapshots if s.id in explicit_ids or not s.isFinalState ] # Preserve the order of any explicitly-requested ids. Put the others in # any order. ids = explicit_ids + [ s.id for s in snapshots if s.id not in explicit_ids ] if not ids: self._is_partial = False return [] if len(ids) == 1: log.status.Print('Waiting for 1 snapshot.') else: log.status.Print('Waiting for {0} snapshots.'.format(len(ids))) snapshots = debuggee.WaitForMultipleBreakpoints(ids, wait_all=args.all, timeout=args.timeout) self._is_partial = args.all and len(snapshots) != len(ids) return snapshots
def Run(self, args): """Run the list command.""" project_id = properties.VALUES.core.project.Get(required=True) debugger = debug.Debugger(project_id) return debugger.ListDebuggees()