コード例 #1
0
def main():
    try:
        if len(sys.argv) > 1:
            common.set_interactive(False)
            if str(sys.argv[1]).lower() == '-h' or str(
                    sys.argv[1]).lower() == '--help':
                common.do_help(RHHelp())
                sys.exit(0)
            if str(sys.argv[1]).lower() == '-v' or str(
                    sys.argv[1]).lower() == '--version':
                print 'redhat-support-tool %s' % (version.version)
                sys.exit(0)
            # Compose input string.
            var = u' '.join([unicode(i, 'utf8') for i in sys.argv[1:]])
            if not sys.stdin.isatty():
                # Do we have piped input?
                data = unicode(sys.stdin.read(), 'utf8')
                var = u'%s %s' % (var, data)
                var = var.strip()
            # Set the locale for cases where the user pipes to
            # a file or grep.  Without this 'print' will throw
            # an exception on unicode chars.
            if not sys.stdout.encoding:
                # Encoding will be None when piped to a program/file
                # ex: redhat-support-tool listcases | grep Title
                sys.stdout = codecs.getwriter(locale.getpreferredencoding())(
                    sys.stdout)
            if not sys.stdout.isatty():
                # We are piping to a file.  Disable ANSI bolding.
                Constants.BOLD = ''
                Constants.END = ''
            ret = RHHelp().onecmd(var)
            # Some commands return None, some for some reason return '', if
            # we sys.exit('') though, it'll print a blank line and set $? to
            # 1, so lets work around that.
            if ret is not None and ret is not 0 and ret != '':
                sys.exit(ret)
        else:
            RHHelp().cmdloop()
    except KeyboardInterrupt:
        print
    except Exception, e:
        print e
        print _('ERROR: %s') % e
コード例 #2
0
def main():
    try:
        if len(sys.argv) > 1:
            common.set_interactive(False)
            if str(sys.argv[1]).lower() == '-h' or str(sys.argv[1]).lower() == '--help':
                common.do_help(RHHelp())
                sys.exit(0)
            if str(sys.argv[1]).lower() == '-v' or str(sys.argv[1]).lower() == '--version':
                print 'redhat-support-tool %s' % (version.version)
                sys.exit(0)
            # Compose input string.
            var = u' '.join([unicode(i, 'utf8') for i in sys.argv[1:]])
            if not sys.stdin.isatty():
                # Do we have piped input?
                data = unicode(sys.stdin.read(), 'utf8')
                var = u'%s %s' % (var, data)
                var = var.strip()
            # Set the locale for cases where the user pipes to
            # a file or grep.  Without this 'print' will throw
            # an exception on unicode chars.
            if not sys.stdout.encoding:
                # Encoding will be None when piped to a program/file
                # ex: redhat-support-tool listcases | grep Title
                sys.stdout = codecs.getwriter(
                                    locale.getpreferredencoding())(sys.stdout)
            if not sys.stdout.isatty():
                # We are piping to a file.  Disable ANSI bolding.
                Constants.BOLD = ''
                Constants.END = ''
            ret = RHHelp().onecmd(var)
            # Some commands return None, some for some reason return '', if
            # we sys.exit('') though, it'll print a blank line and set $? to
            # 1, so lets work around that.
            if ret is not None and ret is not 0 and ret != '':
                sys.exit(ret)
        else:
            RHHelp().cmdloop()
    except KeyboardInterrupt:
        print
    except Exception, e:
        print e
        print _('ERROR: %s') % e
コード例 #3
0
                                   self.vmcore.coreFilename)
                        except:
                            print _('Unable to upload output to Red Hat'
                                    ' Customer Portal, reverting to displaying'
                                    ' output to console.')
                    else:
                        msg = '%s\nThe following comment was added by ' \
                              'Red Hat Support Tool\nVersion: %s\n' \
                              '%s\n\n%s' % \
                              (str(self.ruler * Constants.MAX_RULE),
                               apihelper.USER_AGENT,
                               str(self.ruler * Constants.MAX_RULE),
                               filtered_string)

                    if msg:
                        common.set_interactive(True)
                        lh = LaunchHelper(AddComment)
                        lh.run('-c %s "%s"' %
                               (self._options['casenumber'], msg))
                        self.no_submenu = True
        except Exception, e:
            msg = _('ERROR: %s') % e
            print msg
            logger.log(logging.ERROR, msg)
            raise e

    def non_interactive_action(self):
        if self.no_submenu:
            return

        doc = u''