Пример #1
0
	def initConfiguration(self):
		if not Application.initConfiguration(self):
			return False

		cfg = self.configuration()

		# bind address and port
		try: self._listenAddress = cfg.getString('listenAddress')
		except ConfigException: pass
		try: self._port = cfg.getInt('port')
		except ConfigException: pass

		# maximum number of connections
		try: self._connections = cfg.getInt('connections')
		except ConfigException: pass

		# maximum number of objects per query, used in fdsnws-station and
		# fdsnws-event to limit main memory consumption
		try: self._queryObjects = cfg.getInt('queryObjects')
		except ConfigException: pass

		# restrict end time of request to now-realtimeGap seconds, used in
		# fdsnws-dataselect
		try: self._realtimeGap = cfg.getInt('realtimeGap')
		except ConfigException: pass

		# maximum number of samples (in units of million) per query, used in
		# fdsnws-dataselect to limit bandwidth
		try: self._samplesM = cfg.getDouble('samplesM')
		except ConfigException: pass

		# location of htpasswd file
		try:
			self._htpasswd = cfg.getString('htpasswd')
		except ConfigException: pass
		self._htpasswd = Environment.Instance().absolutePath(self._htpasswd)

		# location of access log file
		try:
			self._accessLogFile = Environment.Instance().absolutePath(
			                      cfg.getString('accessLog'))
		except ConfigException: pass

		# access to restricted inventory information
		try: self._allowRestricted = cfg.getBool('allowRestricted')
		except: pass

		# services to enable
		try: self._serveDataSelect = cfg.getBool('serveDataSelect')
		except: pass
		try: self._serveEvent = cfg.getBool('serveEvent')
		except: pass
		try: self._serveStation = cfg.getBool('serveStation')
		except: pass

		# event filter
		try: self._hideAuthor = cfg.getBool('hideAuthor')
		except: pass
		try:
			name = cfg.getString('evaluationMode')
			if name.lower() == DataModel.EEvaluationModeNames.name(DataModel.MANUAL):
				self._evaluationMode = DataModel.MANUAL
			elif name.lower() == DataModel.EEvaluationModeNames.name(DataModel.AUTOMATIC):
				self._evaluationMode = DataModel.AUTOMATIC
			else:
				print >> sys.stderr, "invalid evaluation mode string: %s" % name
				return False
		except: pass
		try:
			strings = cfg.getStrings('eventType.whitelist')
			if len(strings) > 1 or len(strings[0]):
				self._eventTypeWhitelist = [ s.lower() for s in strings ]
		except: pass
		try:
			strings = cfg.getStrings('eventType.blacklist')
			if len(strings) > 0 or len(strings[0]):
				self._eventTypeBlacklist = [ s.lower() for s in strings ]
		except: pass

		# prefix to be used as default for output filenames
		try: self._fileNamePrefix = cfg.getString('fileNamePrefix')
		except ConfigException: pass

		return True
Пример #2
0
    def initConfiguration(self):
        if not Application.initConfiguration(self):
            return False

        # bind address and port
        try:
            self._listenAddress = self.configGetString('listenAddress')
        except Exception:
            pass
        try:
            self._port = self.configGetInt('port')
        except Exception:
            pass

        # maximum number of connections
        try:
            self._connections = self.configGetInt('connections')
        except Exception:
            pass

        # maximum number of objects per query, used in fdsnws-station and
        # fdsnws-event to limit main memory consumption
        try:
            self._queryObjects = self.configGetInt('queryObjects')
        except Exception:
            pass

        # restrict end time of request to now-realtimeGap seconds, used in
        # fdsnws-dataselect
        try:
            self._realtimeGap = self.configGetInt('realtimeGap')
        except Exception:
            pass

        # maximum number of samples (in units of million) per query, used in
        # fdsnws-dataselect to limit bandwidth
        try:
            self._samplesM = self.configGetDouble('samplesM')
        except Exception:
            pass

        try:
            self._recordBulkSize = self.configGetInt('recordBulkSize')
        except Exception:
            pass

        if self._recordBulkSize < 1:
            print >> sys.stderr, "Invalid recordBulkSize, must be larger than 0"
            return False

        # location of htpasswd file
        try:
            self._htpasswd = self.configGetString('htpasswd')
        except Exception:
            pass
        self._htpasswd = Environment.Instance().absolutePath(self._htpasswd)

        # location of access log file
        try:
            self._accessLogFile = Environment.Instance().absolutePath(
                self.configGetString('accessLog'))
        except Exception:
            pass

        # location of request log file
        try:
            self._requestLogFile = Environment.Instance().absolutePath(
                self.configGetString('requestLog'))
        except Exception:
            pass

        # access to restricted inventory information
        try:
            self._allowRestricted = self.configGetBool('allowRestricted')
        except Exception:
            pass

        # use arclink-access bindings
        try:
            self._useArclinkAccess = self.configGetBool('useArclinkAccess')
        except Exception:
            pass

        # services to enable
        try:
            self._serveDataSelect = self.configGetBool('serveDataSelect')
        except Exception:
            pass
        try:
            self._serveEvent = self.configGetBool('serveEvent')
        except Exception:
            pass
        try:
            self._serveStation = self.configGetBool('serveStation')
        except Exception:
            pass
        try:
            self._serveAvailability = self.configGetBool('serveAvailability')
        except Exception:
            pass

        # data availability
        try:
            self._daEnabled = self.configGetBool('dataAvailability.enable')
        except Exception:
            pass
        try:
            self._daCacheDuration = self.configGetInt(
                'dataAvailability.cacheDuration')
        except Exception:
            pass
        try:
            self._daRepositoryName = self.configGetString(
                'dataAvailability.repositoryName')
        except Exception:
            pass
        try:
            self._daDCCName = self.configGetString('dataAvailability.dccName')
        except Exception:
            pass

        if self._serveAvailability and not self._daEnabled:
            print >> sys.stderr, "can't serve availabilty without " \
                                 "dataAvailability.enable set to true"
            return False
        if not bool(re.match(r'^[a-zA-Z0-9_\ -]*$', self._daRepositoryName)):
            print >> sys.stderr, "invalid characters in dataAvailability.repositoryName"
            return False
        if not bool(re.match(r'^[a-zA-Z0-9_\ -]*$', self._daDCCName)):
            print >> sys.stderr, "invalid characters in dataAvailability.dccName"
            return False

        # event filter
        try:
            self._hideAuthor = self.configGetBool('hideAuthor')
        except Exception:
            pass
        try:
            name = self.configGetString('evaluationMode')
            if name.lower() == DataModel.EEvaluationModeNames.name(DataModel.MANUAL):
                self._evaluationMode = DataModel.MANUAL
            elif name.lower() == DataModel.EEvaluationModeNames.name(DataModel.AUTOMATIC):
                self._evaluationMode = DataModel.AUTOMATIC
            else:
                print >> sys.stderr, "invalid evaluation mode string: %s" % name
                return False
        except Exception:
            pass
        try:
            strings = self.configGetStrings('eventType.whitelist')
            if len(strings) > 1 or len(strings[0]):
                self._eventTypeWhitelist = [s.lower() for s in strings]
        except Exception:
            pass
        try:
            strings = self.configGetStrings('eventType.blacklist')
            if len(strings) > 0 or len(strings[0]):
                self._eventTypeBlacklist = [s.lower() for s in strings]
        except Exception:
            pass
        try:
            strings = self.configGetStrings('eventFormats')
            if len(strings) > 1 or len(strings[0]):
                self._eventFormats = [s.lower() for s in strings]
        except Exception:
            pass

        # station filter
        try:
            self._stationFilter = Environment.Instance().absolutePath(
                self.configGetString('stationFilter'))
        except Exception:
            pass

        # dataSelect filter
        try:
            self._dataSelectFilter = Environment.Instance().absolutePath(
                self.configGetString('dataSelectFilter'))
        except Exception:
            pass

        # output filter debug information
        try:
            self._debugFilter = self.configGetBool('debugFilter')
        except Exception:
            pass

        # prefix to be used as default for output filenames
        try:
            self._fileNamePrefix = self.configGetString('fileNamePrefix')
        except Exception:
            pass

        # save request logs in database?
        try:
            self._trackdbEnabled = self.configGetBool('trackdb.enable')
        except Exception:
            pass

        # default user
        try:
            self._trackdbDefaultUser = self.configGetString(
                'trackdb.defaultUser')
        except Exception:
            pass

        # enable authentication extension?
        try:
            self._authEnabled = self.configGetBool('auth.enable')
        except Exception:
            pass

        # GnuPG home directory
        try:
            self._authGnupgHome = self.configGetString('auth.gnupgHome')
        except Exception:
            pass
        self._authGnupgHome = Environment.Instance().absolutePath(self._authGnupgHome)

        # blacklist of users/tokens
        try:
            strings = self.configGetStrings('auth.blacklist')
            if len(strings) > 1 or len(strings[0]):
                self._authBlacklist = strings
        except Exception:
            pass

        # If the database connection is passed via command line or configuration
        # file then messaging is disabled. Messaging is only used to get
        # the configured database connection URI.
        if self.databaseURI() != "":
            self.setMessagingEnabled(self._trackdbEnabled)
        else:
            # Without the event service, a database connection is not
            # required if the inventory is loaded from file and no data
            # availability information should be processed
            if not self._serveEvent and not self._useArclinkAccess and \
               (not self._serveStation or (
                   not self.isInventoryDatabaseEnabled() and not self._daEnabled)):
                self.setMessagingEnabled(self._trackdbEnabled)
                self.setDatabaseEnabled(False, False)

        return True
Пример #3
0
    def initConfiguration(self):
        if not Application.initConfiguration(self):
            return False

        # bind address and port
        try:
            self._listenAddress = self.configGetString('listenAddress')
        except ConfigException:
            pass
        try:
            self._port = self.configGetInt('port')
        except ConfigException:
            pass

        # maximum number of connections
        try:
            self._connections = self.configGetInt('connections')
        except ConfigException:
            pass

        # maximum number of objects per query, used in fdsnws-station and
        # fdsnws-event to limit main memory consumption
        try:
            self._queryObjects = self.configGetInt('queryObjects')
        except ConfigException:
            pass

        # restrict end time of request to now-realtimeGap seconds, used in
        # fdsnws-dataselect
        try:
            self._realtimeGap = self.configGetInt('realtimeGap')
        except ConfigException:
            pass

        # maximum number of samples (in units of million) per query, used in
        # fdsnws-dataselect to limit bandwidth
        try:
            self._samplesM = self.configGetDouble('samplesM')
        except ConfigException:
            pass

        # location of htpasswd file
        try:
            self._htpasswd = self.configGetString('htpasswd')
        except ConfigException:
            pass
        self._htpasswd = Environment.Instance().absolutePath(self._htpasswd)

        # location of access log file
        try:
            self._accessLogFile = Environment.Instance().absolutePath(
                self.configGetString('accessLog'))
        except ConfigException:
            pass

        # access to restricted inventory information
        try:
            self._allowRestricted = self.configGetBool('allowRestricted')
        except:
            pass

        # use arclink-access bindings
        try:
            self._useArclinkAccess = self.configGetBool('useArclinkAccess')
        except:
            pass

        # services to enable
        try:
            self._serveDataSelect = self.configGetBool('serveDataSelect')
        except:
            pass
        try:
            self._serveEvent = self.configGetBool('serveEvent')
        except:
            pass
        try:
            self._serveStation = self.configGetBool('serveStation')
        except:
            pass

        # event filter
        try:
            self._hideAuthor = self.configGetBool('hideAuthor')
        except:
            pass
        try:
            name = self.configGetString('evaluationMode')
            if name.lower() == DataModel.EEvaluationModeNames.name(
                    DataModel.MANUAL):
                self._evaluationMode = DataModel.MANUAL
            elif name.lower() == DataModel.EEvaluationModeNames.name(
                    DataModel.AUTOMATIC):
                self._evaluationMode = DataModel.AUTOMATIC
            else:
                print >> sys.stderr, "invalid evaluation mode string: %s" % name
                return False
        except:
            pass
        try:
            strings = self.configGetStrings('eventType.whitelist')
            if len(strings) > 1 or len(strings[0]):
                self._eventTypeWhitelist = [s.lower() for s in strings]
        except:
            pass
        try:
            strings = self.configGetStrings('eventType.blacklist')
            if len(strings) > 0 or len(strings[0]):
                self._eventTypeBlacklist = [s.lower() for s in strings]
        except:
            pass

        # station filter
        try:
            self._stationFilter = Environment.Instance().absolutePath(
                self.configGetString('stationFilter'))
        except ConfigException:
            pass

        # dataSelect filter
        try:
            self._dataSelectFilter = Environment.Instance().absolutePath(
                self.configGetString('dataSelectFilter'))
        except ConfigException:
            pass

        # output filter debug information
        try:
            self._debugFilter = self.configGetBool('debugFilter')
        except ConfigException:
            pass

        # prefix to be used as default for output filenames
        try:
            self._fileNamePrefix = self.configGetString('fileNamePrefix')
        except ConfigException:
            pass

        # save request logs in database?
        try:
            self._trackdbEnabled = self.configGetBool('trackdb.enable')
        except ConfigException:
            pass

        # default user
        try:
            self._trackdbDefaultUser = self.configGetString(
                'trackdb.defaultUser')
        except ConfigException:
            pass

        # enable authentication extension?
        try:
            self._authEnabled = self.configGetBool('auth.enable')
        except ConfigException:
            pass

        # GnuPG home directory
        try:
            self._authGnupgHome = self.configGetString('auth.gnupgHome')
        except ConfigException:
            pass
        self._authGnupgHome = Environment.Instance().absolutePath(
            self._authGnupgHome)

        return True
Пример #4
0
	def initConfiguration(self):
		if not Application.initConfiguration(self):
			return False

		# bind address and port
		try: self._listenAddress = self.configGetString('listenAddress')
		except ConfigException: pass
		try: self._port = self.configGetInt('port')
		except ConfigException: pass

		# maximum number of connections
		try: self._connections = self.configGetInt('connections')
		except ConfigException: pass

		# maximum number of objects per query, used in fdsnws-station and
		# fdsnws-event to limit main memory consumption
		try: self._queryObjects = self.configGetInt('queryObjects')
		except ConfigException: pass

		# restrict end time of request to now-realtimeGap seconds, used in
		# fdsnws-dataselect
		try: self._realtimeGap = self.configGetInt('realtimeGap')
		except ConfigException: pass

		# maximum number of samples (in units of million) per query, used in
		# fdsnws-dataselect to limit bandwidth
		try: self._samplesM = self.configGetDouble('samplesM')
		except ConfigException: pass

		try: self._recordBulkSize = self.configGetInt('recordBulkSize')
		except ConfigException: pass

		if self._recordBulkSize < 1:
			print >> sys.stderr, "Invalid recordBulkSize, must be larger than 0"
			return False

		# location of htpasswd file
		try:
			self._htpasswd = self.configGetString('htpasswd')
		except ConfigException: pass
		self._htpasswd = Environment.Instance().absolutePath(self._htpasswd)

		# location of access log file
		try:
			self._accessLogFile = Environment.Instance().absolutePath(
			                      self.configGetString('accessLog'))
		except ConfigException: pass

		# access to restricted inventory information
		try: self._allowRestricted = self.configGetBool('allowRestricted')
		except: pass

		# use arclink-access bindings
		try: self._useArclinkAccess = self.configGetBool('useArclinkAccess')
		except: pass

		# services to enable
		try: self._serveDataSelect = self.configGetBool('serveDataSelect')
		except: pass
		try: self._serveEvent = self.configGetBool('serveEvent')
		except: pass
		try: self._serveStation = self.configGetBool('serveStation')
		except: pass

		# event filter
		try: self._hideAuthor = self.configGetBool('hideAuthor')
		except: pass
		try:
			name = self.configGetString('evaluationMode')
			if name.lower() == DataModel.EEvaluationModeNames.name(DataModel.MANUAL):
				self._evaluationMode = DataModel.MANUAL
			elif name.lower() == DataModel.EEvaluationModeNames.name(DataModel.AUTOMATIC):
				self._evaluationMode = DataModel.AUTOMATIC
			else:
				print >> sys.stderr, "invalid evaluation mode string: %s" % name
				return False
		except: pass
		try:
			strings = self.configGetStrings('eventType.whitelist')
			if len(strings) > 1 or len(strings[0]):
				self._eventTypeWhitelist = [ s.lower() for s in strings ]
		except: pass
		try:
			strings = self.configGetStrings('eventType.blacklist')
			if len(strings) > 0 or len(strings[0]):
				self._eventTypeBlacklist = [ s.lower() for s in strings ]
		except: pass

		# station filter
		try: self._stationFilter = Environment.Instance().absolutePath(self.configGetString('stationFilter'))
		except ConfigException: pass

		# dataSelect filter
		try: self._dataSelectFilter = Environment.Instance().absolutePath(self.configGetString('dataSelectFilter'))
		except ConfigException: pass

		# output filter debug information
		try: self._debugFilter = self.configGetBool('debugFilter')
		except ConfigException: pass

		# prefix to be used as default for output filenames
		try: self._fileNamePrefix = self.configGetString('fileNamePrefix')
		except ConfigException: pass

		# save request logs in database?
		try: self._trackdbEnabled = self.configGetBool('trackdb.enable')
		except ConfigException: pass

		# default user
		try: self._trackdbDefaultUser = self.configGetString('trackdb.defaultUser')
		except ConfigException: pass

		# enable authentication extension?
		try: self._authEnabled = self.configGetBool('auth.enable')
		except ConfigException: pass

		# GnuPG home directory
		try: self._authGnupgHome = self.configGetString('auth.gnupgHome')
		except ConfigException: pass
		self._authGnupgHome = Environment.Instance().absolutePath(self._authGnupgHome)

		# If the database connection is passed via command line or configuration
		# file then messaging is disabled. Messaging is only used to get
		# the configured database connection URI.
		if self.databaseURI() != "":
			self.setMessagingEnabled(False)
		else:
			# Without the event service, event a database connection is not
			# required if the inventory is loaded from file
			if not self._serveEvent and not self._useArclinkAccess and not self.isInventoryDatabaseEnabled():
				self.setMessagingEnabled(False)
				self.setDatabaseEnabled(False, False)

		return True