commit 3c2a17819b5d310a5fd4f3e14cfb427f5246c5ae Author: Bryn M. Reeves Date: Wed Jan 9 10:48:19 2013 +0000 Report --name and --ticket values as defaults When a user specifies the name and ticket number on the command line sosreport should use these values instead of the built-in defaults (rhn username then hostname) when prompting the user interactively for this information. Resolves: bz822113 diff --git a/sos/policyredhat.py b/sos/policyredhat.py index 64e2e47..a93e92b 100755 --- a/sos/policyredhat.py +++ b/sos/policyredhat.py @@ -210,27 +210,32 @@ class SosPolicy: def preWork(self): # this method will be called before the gathering begins - localname = self.rhnUsername() - if len(localname) == 0: localname = self.hostName() + if self.cInfo['cmdlineopts'].customerName: + localname = self.cInfo['cmdlineopts'].customerName + else: + localname = self.rhnUsername() + if len(localname) == 0: + localname = self.hostName() + + if self.cInfo['cmdlineopts'].ticketNumber: + self.ticketNumber = self.cInfo['cmdlineopts'].ticketNumber if not self.cInfo['cmdlineopts'].batch: try: - self.reportName = raw_input(_("Please enter your first initial and last name [%s]: ") % localname) - self.ticketNumber = raw_input(_("Please enter the case number that you are generating this report for: ")) + self.reportName = raw_input( + _("Please enter your first initial and last name [%s]: ") + % localname) + self.ticketNumber = raw_input( + _("Please enter the case number that you are " + + "generating this report for [%s]: ") + % self.ticketNumber) print except: - print sys.exit(0) if len(self.reportName) == 0: self.reportName = localname - if self.cInfo['cmdlineopts'].customerName: - self.reportName = self.cInfo['cmdlineopts'].customerName - - if self.cInfo['cmdlineopts'].ticketNumber: - self.ticketNumber = self.cInfo['cmdlineopts'].ticketNumber - self.reportName = sanitizeReportName(self.reportName) self.ticketNumber = sanitizeTicketNumber(self.ticketNumber)