Esempio n. 1
0
 def test_broken_locale(self):
     def err():
         raise KeyError
     self.patch(locale, 'getdefaultlocale', err)
     config = mock.Mock()
     util.check_functional_environment(config)
     config.error.assert_called_with(mock.ANY)
Esempio n. 2
0
 def test_broken_locale(self):
     def err():
         raise KeyError
     self.patch(locale, 'getdefaultlocale', err)
     config = mock.Mock()
     util.check_functional_environment(config)
     config.error.assert_called_with(mock.ANY)
Esempio n. 3
0
    def __init__(self, basedir, configFileName=None, umask=None, reactor=None, config_loader=None):
        service.AsyncMultiService.__init__(self)

        if reactor is None:
            from twisted.internet import reactor
        self.reactor = reactor

        self.setName("buildmaster")

        self.umask = umask

        self.basedir = basedir
        if basedir is not None:  # None is used in tests
            assert os.path.isdir(self.basedir)

        if config_loader is not None and configFileName is not None:
            raise config.ConfigErrors(["Can't specify both `config_loader` and `configFilename`."])
        elif config_loader is None:
            if configFileName is None:
                configFileName = "master.cfg"
            config_loader = config.FileLoader(self.basedir, configFileName)
        self.config_loader = config_loader
        self.configFileName = configFileName

        # flag so we don't try to do fancy things before the master is ready
        self._master_initialized = False

        # set up child services
        self.create_child_services()

        # db configured values
        self.configured_db_url = None

        # configuration / reconfiguration handling
        self.config = config.MasterConfig()
        self.reconfig_active = False
        self.reconfig_requested = False
        self.reconfig_notifier = None

        # this stores parameters used in the tac file, and is accessed by the
        # WebStatus to duplicate those values.
        self.log_rotation = LogRotation()

        # local cache for this master's object ID
        self._object_id = None

        # Check environment is sensible
        check_functional_environment(self.config)

        # figure out local hostname
        try:
            self.hostname = os.uname()[1]  # only on unix
        except AttributeError:
            self.hostname = socket.getfqdn()

        # public attributes
        self.name = "%s:%s" % (self.hostname, os.path.abspath(self.basedir or "."))
        self.name = self.name.decode("ascii", "replace")
        self.masterid = None
Esempio n. 4
0
    def __init__(self, basedir, configFileName="master.cfg", umask=None, reactor=None):
        service.AsyncMultiService.__init__(self)

        if reactor is None:
            from twisted.internet import reactor
        self.reactor = reactor

        self.setName("buildmaster")

        self.umask = umask

        self.basedir = basedir
        if basedir is not None:  # None is used in tests
            assert os.path.isdir(self.basedir)
        self.configFileName = configFileName

        # flag so we don't try to do fancy things before the master is ready
        self._master_initialized = False

        # set up child services
        self.create_child_services()

        # db configured values
        self.configured_db_url = None

        # configuration / reconfiguration handling
        self.config = config.MasterConfig()
        self.reconfig_active = False
        self.reconfig_requested = False
        self.reconfig_notifier = None

        # this stores parameters used in the tac file, and is accessed by the
        # WebStatus to duplicate those values.
        self.log_rotation = LogRotation()

        # local cache for this master's object ID
        self._object_id = None

        # Check environment is sensible
        check_functional_environment(self.config)

        # figure out local hostname
        try:
            self.hostname = os.uname()[1]  # only on unix
        except AttributeError:
            self.hostname = socket.getfqdn()

        # public attributes
        self.name = ("%s:%s" % (self.hostname,
                                os.path.abspath(self.basedir or '.')))
        self.name = self.name.decode('ascii', 'replace')
        self.masterid = None
Esempio n. 5
0
def run():
    config = Options()
    check_functional_environment(buildbot.config)
    try:
        config.parseOptions(sys.argv[1:])
    except usage.error as e:
        print("{}:  {}".format(sys.argv[0], e))
        print()

        c = getattr(config, 'subOptions', config)
        print(str(c))
        sys.exit(1)

    subconfig = config.subOptions
    subcommandFunction = reflect.namedObject(subconfig.subcommandFunction)
    sys.exit(subcommandFunction(subconfig))
Esempio n. 6
0
def run():
    config = Options()
    check_functional_environment(buildbot.config)
    try:
        config.parseOptions(sys.argv[1:])
    except usage.error as e:
        print("%s:  %s" % (sys.argv[0], e))
        print()

        c = getattr(config, 'subOptions', config)
        print(str(c))
        sys.exit(1)

    subconfig = config.subOptions
    subcommandFunction = reflect.namedObject(subconfig.subcommandFunction)
    sys.exit(subcommandFunction(subconfig))
Esempio n. 7
0
    def __init__(self, basedir, configFileName="master.cfg", umask=None):
        service.AsyncMultiService.__init__(self)
        self.setName("buildmaster")

        self.umask = umask

        self.basedir = basedir
        if basedir is not None:  # None is used in tests
            assert os.path.isdir(self.basedir)
        self.configFileName = configFileName

        # flag so we don't try to do fancy things before the master is ready
        self._master_initialized = False

        # set up child services
        self.create_child_services()

        # db configured values
        self.configured_db_url = None

        # configuration / reconfiguration handling
        self.config = config.MasterConfig()
        self.reconfig_active = False
        self.reconfig_requested = False
        self.reconfig_notifier = None

        # this stores parameters used in the tac file, and is accessed by the
        # WebStatus to duplicate those values.
        self.log_rotation = LogRotation()

        # local cache for this master's object ID
        self._object_id = None

        # Check environment is sensible
        check_functional_environment(self.config)

        # figure out local hostname
        try:
            self.hostname = os.uname()[1]  # only on unix
        except AttributeError:
            self.hostname = socket.getfqdn()

        # public attributes
        self.name = ("%s:%s" % (self.hostname,
                                os.path.abspath(self.basedir or '.')))
        self.name = self.name.decode('ascii', 'replace')
        self.masterid = None
Esempio n. 8
0
    def __init__(self, basedir, configFileName="master.cfg", umask=None):
        service.MultiService.__init__(self)
        self.setName("buildmaster")

        self.umask = umask

        self.basedir = basedir
        assert os.path.isdir(self.basedir)
        self.configFileName = configFileName

        # set up child services
        self.create_child_services()

        # loop for polling the db
        self.db_loop = None
        # db configured values
        self.configured_db_url = None
        self.configured_poll_interval = None

        # configuration / reconfiguration handling
        self.config = config.MasterConfig()
        self.reconfig_active = False
        self.reconfig_requested = False
        self.reconfig_notifier = None

        # this stores parameters used in the tac file, and is accessed by the
        # WebStatus to duplicate those values.
        self.log_rotation = LogRotation()

        # subscription points
        self._change_subs = \
            subscription.SubscriptionPoint("changes")
        self._new_buildrequest_subs = \
            subscription.SubscriptionPoint("buildrequest_additions")
        self._new_buildset_subs = \
            subscription.SubscriptionPoint("buildset_additions")
        self._complete_buildset_subs = \
            subscription.SubscriptionPoint("buildset_completion")

        # local cache for this master's object ID
        self._object_id = None

        # Check environment is sensible
        check_functional_environment(self.config)
Esempio n. 9
0
    def __init__(self, basedir, configFileName="master.cfg", umask=None):
        service.MultiService.__init__(self)
        self.setName("buildmaster")

        self.umask = umask

        self.basedir = basedir
        assert os.path.isdir(self.basedir)
        self.configFileName = configFileName

        # set up child services
        self.create_child_services()

        # loop for polling the db
        self.db_loop = None
        # db configured values
        self.configured_db_url = None
        self.configured_poll_interval = None

        # configuration / reconfiguration handling
        self.config = config.MasterConfig()
        self.reconfig_active = False
        self.reconfig_requested = False
        self.reconfig_notifier = None

        # this stores parameters used in the tac file, and is accessed by the
        # WebStatus to duplicate those values.
        self.log_rotation = LogRotation()

        # subscription points
        self._change_subs = \
            subscription.SubscriptionPoint("changes")
        self._new_buildrequest_subs = \
            subscription.SubscriptionPoint("buildrequest_additions")
        self._new_buildset_subs = \
            subscription.SubscriptionPoint("buildset_additions")
        self._complete_buildset_subs = \
            subscription.SubscriptionPoint("buildset_completion")

        # local cache for this master's object ID
        self._object_id = None

        # Check environment is sensible
        check_functional_environment(self.config)
Esempio n. 10
0
 def test_broken_locale(self):
     environ = {'LANG': 'NINE.UTF-8'}
     self.patch(os, 'environ', environ)
     config = mock.Mock()
     util.check_functional_environment(config)
     config.error.assert_called()
Esempio n. 11
0
 def test_working_locale(self):
     environ = {'LANG': 'en_GB.UTF-8'}
     self.patch(os, 'environ', environ)
     config = mock.Mock()
     util.check_functional_environment(config)
     self.assertEqual(config.error.called, False)
Esempio n. 12
0
 def test_working_locale(self):
     environ = {'LANG': 'en_GB.UTF-8'}
     self.patch(os, 'environ', environ)
     config = mock.Mock()
     util.check_functional_environment(config)
     self.assertEqual(config.error.called, False)
Esempio n. 13
0
    def __init__(self, basedir, configFileName=None, umask=None, reactor=None, config_loader=None):
        super().__init__()

        if reactor is None:
            from twisted.internet import reactor
        self.reactor = reactor

        self.setName("buildmaster")

        self.umask = umask

        self.basedir = basedir
        if basedir is not None:  # None is used in tests
            assert os.path.isdir(self.basedir)

        if config_loader is not None and configFileName is not None:
            raise config.ConfigErrors([
                "Can't specify both `config_loader` and `configFilename`.",
            ])
        if config_loader is None:
            if configFileName is None:
                configFileName = 'master.cfg'
            config_loader = config.FileLoader(self.basedir, configFileName)
        self.config_loader = config_loader
        self.configFileName = configFileName

        # flag so we don't try to do fancy things before the master is ready
        self._master_initialized = False
        self.initLock = defer.DeferredLock()

        # set up child services
        self._services_d = self.create_child_services()

        # db configured values
        self.configured_db_url = None

        # configuration / reconfiguration handling
        self.config = config.MasterConfig()
        self.config_version = 0  # increased by one on each reconfig
        self.reconfig_active = False
        self.reconfig_requested = False
        self.reconfig_notifier = None

        # this stores parameters used in the tac file, and is accessed by the
        # WebStatus to duplicate those values.
        self.log_rotation = LogRotation()

        # local cache for this master's object ID
        self._object_id = None

        # Check environment is sensible
        check_functional_environment(self.config)

        # figure out local hostname
        try:
            self.hostname = os.uname()[1]  # only on unix
        except AttributeError:
            self.hostname = socket.getfqdn()

        # public attributes
        self.name = (f"{self.hostname}:{os.path.abspath(self.basedir or '.')}")
        if isinstance(self.name, bytes):
            self.name = self.name.decode('ascii', 'replace')
        self.masterid = None
Esempio n. 14
0
 def test_broken_locale(self):
     environ = {'LANG': 'NINE.UTF-8'}
     self.patch(os, 'environ', environ)
     config = mock.Mock()
     util.check_functional_environment(config)
     config.error.assert_called()