def test_beta_channel(self):
     for v in ('1.0dev15','1.0b', '1.0', '1.1.1', '1.1.1b', '1.1.1b2', '1.1.1dev7', '1.4', '1.4.2', '1.4.3dev',
               '1.4.3dev1', '1.4.3b', '1.4.3b1', '1.4.3', '1.4.3', '1.4.4dev', '1.4.4b', '1.4.4', '1.5',
               '1.5.2', '1.5.3dev', '1.5.3dev1', '1.5.3b', '1.5.3b1', '1.5.3b2'):
         self.assertEqual(self.expected_beta, update.checkUpdate(v, channel=update.UPDATE_CHANNEL_BETA))
     for v in ('1.5.3b3', '1.5.3b4', '1.5.3', '1.5.4dev', '1.5.4b', '1.5.4', '1.6dev', '1.6dev4', '1.6dev5',
               '1.6dev6', '1.6b', '1.6b1', '1.6', '1.6.1'):
         self.assertEqual(None, update.checkUpdate(v, channel=update.UPDATE_CHANNEL_BETA))
Beispiel #2
0
def start(configFile, nosetup=False):
    configFile = getAbsolutePath(configFile)
    clearScreen()

    print 'Starting %s\n' % getB3versionString()

    conf = None
    if os.path.exists(configFile):
        print 'Using config file: %s' % configFile
        global _confDir
        _confDir = os.path.dirname(configFile)
        #print 'Config dir is        : %s' % _confDir
        conf = config.load(configFile)
    else:
        # This happens when a config was entered on the commandline, but it does not exist
        if nosetup:
            raise SystemExit('Could not find config file %s' % configFile)
        else:
            Setup(configFile)

    # Check if a newer version of B3 is available
    update_channel = None
    try:
        update_channel = conf.get('update', 'channel')
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
        pass
    _update = checkUpdate(__version__,
                          channel=update_channel,
                          singleLine=False,
                          showErrormsg=True)
    if _update:
        print _update
        time.sleep(5)
    else:
        print "...no update available."
        time.sleep(1)

    try:
        parserType = conf.get('b3', 'parser')
        if not parserType:
            raise SystemExit('You must supply a parser')

        try:
            parser = loadParser(parserType, configFile, nosetup)
        except ImportError, err:
            raise SystemExit(
                "CRITICAL: Cannot find parser '%s'. Check you main config file (b3.xml)\nB3 failed to start.\n%r"
                % (parserType, err))

        extplugins_dir = conf.getpath('plugins', 'external_dir')
        print "Using external plugin directory: %s" % extplugins_dir

        global console
        console = parser(conf)
Beispiel #3
0
def start(configFile, nosetup=False):
    configFile = getAbsolutePath(configFile)
    clearScreen()

    print 'Starting %s\n' % getB3versionString()

    conf = None
    if os.path.exists(configFile):
        print 'Using config file: %s' % configFile
        global _confDir
        _confDir = os.path.dirname(configFile)
        #print 'Config dir is        : %s' % _confDir
        conf = config.load(configFile)
    else:
        # This happens when a config was entered on the commandline, but it does not exist
        if nosetup:
            raise SystemExit('Could not find config file %s' % configFile)
        else:
            Setup(configFile)


    # Check if a newer version of B3 is available
    update_channel = None
    try:
        update_channel = conf.get('update', 'channel')
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
        pass
    _update = checkUpdate(__version__, channel=update_channel, singleLine=False, showErrormsg=True)
    if _update:
        print _update
        time.sleep(5)
    else:
        print "...no update available."
        time.sleep(1)


    try:
        parserType = conf.get('b3', 'parser')
        if not parserType:
            raise SystemExit('You must supply a parser')

        try:
            parser = loadParser(parserType, configFile, nosetup)
        except ImportError, err:
            raise SystemExit("CRITICAL: Cannot find parser '%s'. Check you main config file (b3.xml)\nB3 failed to start.\n%r"% (parserType, err))
    
        extplugins_dir = conf.getpath('plugins', 'external_dir')
        print "Using external plugin directory: %s" % extplugins_dir
        
        global console
        console = parser(conf)
 def test_broken_json(self):
     def urlopen2(*args, **kwargs):
         """
         will fake urllib2.urlopen
         """
         import StringIO
         return StringIO.StringIO("""
             {
                 "B3": {
                     "channels": {
                         "stable": {
                             "url": "http://www.url.stable.fake",
                             "latest-version": "1.4.3"
                         },
                         "be
         """)
     import urllib2
     urllib2.urlopen = urlopen2
     self.assertIn("Could not check updates", update.checkUpdate('1.0', showErrormsg=True))
    def test_default_channel(self):
        for v in ('1.0', '1.1.1', '1.4', '1.4.2'):
            self.assertEqual(self.expected_stable, update.checkUpdate(v))
        for v in ('1.4.3', '1.4.4', '1.5', '1.5.2', '1.5.3', '1.5.4', '1.6', '1.6.1'):
            self.assertEqual(None, update.checkUpdate(v))

        for v in ('1.0b', '1.1.1b', '1.1.1b2', '1.4.3b', '1.4.3b1', '1.4.4b', '1.5.3b', '1.5.3b1', '1.5.3b2'):
            self.assertEqual(self.expected_beta, update.checkUpdate(v))
        for v in ('1.5.3b3', '1.5.3b4', '1.5.4b', '1.6b', '1.6b1'):
            self.assertEqual(None, update.checkUpdate(v))

        for v in ('1.0dev15', '1.1.1dev7', '1.4.3dev', '1.4.3dev1', '1.4.4dev', '1.5.3dev', '1.5.3dev1', '1.5.4dev', '1.6dev', '1.6dev4'):
            self.assertEqual(self.expected_dev, update.checkUpdate(v))
        for v in ('1.6dev5', '1.6dev6', '1.7dev'):
            self.assertEqual(None, update.checkUpdate(v))
 def test_bad_version(self):
     update.checkUpdate('one.two', showErrormsg=True)
 def test_unknown_channel(self):
     self.assertIn("unknown channel 'foo'", update.checkUpdate('1.0', channel="foo", showErrormsg=True))
 def test_not_existing_url(self, mocked_urlopen):
     update.URL_B3_LATEST_VERSION = 'http://no.where.local/'
     mocked_urlopen.side_effect = urllib2.URLError
     result = update.checkUpdate('1.2', singleLine=True, showErrormsg=True)
     self.assertIn('Could not check updates', result)
 def test_official_url(self):
     result = update.checkUpdate('1.2', singleLine=False, showErrormsg=True)
     self.assertIsNotNone(result)
     self.assertNotIn('Could not check updates', result)
Beispiel #10
0
def start(mainconfig, options):
    """
    Main B3 startup.
    :param mainconfig: The B3 configuration file instance :type: b3.config.MainConfig
    :param options: command line options
    """
    clearscreen()
    global confdir
    confdir = os.path.dirname(mainconfig.fileName)

    sys.stdout.write('Starting B3      : %s\n' % getB3versionString())
    sys.stdout.write('Autorestart mode : %s\n' %
                     ('ON' if options.autorestart else 'OFF'))

    sys.stdout.flush()

    try:
        update_channel = mainconfig.get('update', 'channel')
    except (NoSectionError, NoOptionError):
        pass
    else:
        sys.stdout.write('Checking update  : ')
        sys.stdout.flush()
        if update_channel == 'skip':
            sys.stdout.write('SKIP\n')
            sys.stdout.flush()
        else:
            updatetext = checkUpdate(__version__,
                                     channel=update_channel,
                                     singleLine=True,
                                     showErrormsg=True)
            if updatetext:
                sys.stdout.write('%s\n' % updatetext)
                sys.stdout.flush()
                time.sleep(2)
            else:
                sys.stdout.write('no update available\n')
                sys.stdout.flush()
                time.sleep(1)

    # not real loading but the user will get what's configuration he is using
    sys.stdout.write('Loading config   : %s\n' %
                     getShortPath(mainconfig.fileName, True))
    sys.stdout.flush()

    parsertype = mainconfig.get('b3', 'parser')
    sys.stdout.write('Loading parser   : %s\n' % parsertype)
    sys.stdout.flush()

    parser = loadParser(parsertype)
    global console
    console = parser(mainconfig, options)

    def termSignalHandler(signum, frame):
        """
        Define the signal handler so to handle B3 shutdown properly.
        """
        console.bot("TERM signal received: shutting down")
        console.shutdown()
        raise SystemExit(222)

    try:
        # necessary if using the functions profiler,
        # because signal.signal cannot be used in threads
        signal.signal(signal.SIGTERM, termSignalHandler)
    except Exception:
        pass

    try:
        console.start()
    except KeyboardInterrupt:
        console.shutdown()
        print 'Goodbye'
        return
    except SystemExit, msg:
        print 'EXITING: %s' % msg
        raise
def start(mainconfig, options):
    """
    Main B3 startup.
    :param mainconfig: The B3 configuration file instance :type: b3.config.MainConfig
    :param options: command line options
    """
    clearscreen()
    global confdir
    confdir = os.path.dirname(mainconfig.fileName)

    sys.stdout.write('Starting B3      : %s\n' % getB3versionString())
    sys.stdout.write('Autorestart mode : %s\n' % ('ON' if options.autorestart else 'OFF'))

    sys.stdout.flush()

    try:
        update_channel = mainconfig.get('update', 'channel')
    except (NoSectionError, NoOptionError):
        pass
    else:
        sys.stdout.write('Checking update  : ')
        sys.stdout.flush()
        if update_channel == 'skip':
            sys.stdout.write('SKIP\n')
            sys.stdout.flush()
        else:
            updatetext = checkUpdate(__version__, channel=update_channel, singleLine=True, showErrormsg=True)
            if updatetext:
                sys.stdout.write('%s\n' % updatetext)
                sys.stdout.flush()
                time.sleep(2)
            else:
                sys.stdout.write('no update available\n')
                sys.stdout.flush()
                time.sleep(1)

    # not real loading but the user will get what's configuration he is using
    sys.stdout.write('Loading config   : %s\n' % getShortPath(mainconfig.fileName, True))
    sys.stdout.flush()

    parsertype = mainconfig.get('b3', 'parser')
    sys.stdout.write('Loading parser   : %s\n' % parsertype)
    sys.stdout.flush()

    parser = loadParser(parsertype)
    global console
    console = parser(mainconfig, options)

    def termSignalHandler(signum, frame):
        """
        Define the signal handler so to handle B3 shutdown properly.
        """
        console.bot("TERM signal received: shutting down")
        console.shutdown()
        raise SystemExit(222)

    try:
        # necessary if using the functions profiler,
        # because signal.signal cannot be used in threads
        signal.signal(signal.SIGTERM, termSignalHandler)
    except Exception:
        pass

    try:
        console.start()
    except KeyboardInterrupt:
        console.shutdown()
        print 'Goodbye'
        return
    except SystemExit, msg:
        print 'EXITING: %s' % msg
        raise