当前位置: 首页>>代码示例>>Python>>正文


Python Configuration.get方法代码示例

本文整理汇总了Python中configuration.Configuration.get方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.get方法的具体用法?Python Configuration.get怎么用?Python Configuration.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在configuration.Configuration的用法示例。


在下文中一共展示了Configuration.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
 def setUp(self):
     test_config = TestConfig()
     self.data_path = test_config.get_data_path()
     config = Configuration(os.path.join(self.data_path,'build.ini'))
     db_name = config.get('mongodb1','db_name')
     host = config.get('mongodb1','host')
     config = MongoDBConfig(db_name, host)
     self.db = MongoDB(config)
开发者ID:vollov,项目名称:py-lab,代码行数:10,代码来源:mongodb_ut.py

示例2: __init__

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
    def __init__(self, config: Configuration):
        super().__init__('RedisCassandra')
        redis_host = config.get('redis.host')
        redis_port = config.get('redis.port')
        redis_pass = config.get('redis.password')

        #TODO: change to Sentinel so we can handle multiple hosts
        self.redis_conn = StrictRedis(host=redis_host, port=redis_port, password=redis_pass)
        self.cache = get_cache()
开发者ID:Metrink,项目名称:metrink-fe,代码行数:11,代码来源:MetricsExplorer.py

示例3: __init__

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
    def __init__(self, config: Configuration):
        super().__init__()

        redis_host = config.get('redis.host')
        redis_port = config.get('redis.port')

        self.redis_conn = redis.StrictRedis(host=redis_host, port=redis_port)
        logger.info("Redis configured with %s:%d" % (redis_host, redis_port))

        cass_hosts = config.get('cassandra.hosts')
        keyspace = config.get('cassandra.keyspace')

        self.cass_conn = Cluster(cass_hosts).connect(keyspace)
        logger.info("Cassandra configured with hosts %s and keyspace %s" % (','.join(cass_hosts), keyspace))
开发者ID:Metrink,项目名称:metrink-fe,代码行数:16,代码来源:Metrics.py

示例4: _get_download_urls

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
 def _get_download_urls(self, ignore_preferred=False, banned_urls=list()):
     result = []
     if 'downloadUrl' in self._meta:
         # filter if exclusive formats are set
         if Document._is_an_exclusive_format(self.get_meta('mimeType')):
             result = [self._meta['downloadUrl']]
     elif 'exportLinks' in self._meta:
         # no direct download link
         urls = self._meta['exportLinks'].values()
         url_to_ext = dict()
         # filter exclusive and preferred formats
         exclusive = Configuration.get('formats_exclusive')
         preferred = Configuration.get('formats_preferred')
         one_preferred_found = False
         for url in urls:
             # get the extension from the url
             ext_matches = Document._extension_from_url_regex.findall(url)
             if not ext_matches:
                 # shouldn't happen as far as I can tell
                 Log.error(u'No extension found in url: {} '.format(url) +
                           u'for document id {}'.format(self.id))
                 continue
             extension = '.' + ext_matches[0]
             Log.debug(
                 u'Found extension {} for document id {}'.format(
                     extension, self.id
                 )
             )
             if exclusive and extension not in exclusive:
                 Log.debug(u'Ignoring extension {} not '.format(extension) +
                           u'not in exclusive: {}'.format(exclusive))
                 continue
             if not ignore_preferred and extension in preferred:
                 one_preferred_found = True
             url_to_ext[url] = extension
         if one_preferred_found:
             result = [url for url in url_to_ext.keys()
                       if url_to_ext[url] in preferred]
         else:
             result = url_to_ext.keys()
     # filter banned URLs
     if banned_urls:
         result = [url for url in result if url not in banned_urls]
     # and finally, return if anything is left!
     if not result:
         Log.verbose(
             u'No suitable download URL for document id {}'.format(self.id)
         )
     return result
开发者ID:arcan1s,项目名称:Brive,代码行数:51,代码来源:model.py

示例5: load_preferences

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
 def load_preferences(self):
     configuration = Configuration()
     self.image_link = configuration.get('image_link')
     max_size = configuration.get('max_size')
     reduce_size = configuration.get('reduce_size')
     reduce_colors = configuration.get('reduce_colors')
     tbi = configuration.get('time_between_images')
     ttbuffer = Gtk.TextBuffer()
     ttbuffer.set_text(self.image_link)
     self.entry3.set_buffer(ttbuffer)
     self.entry4.set_text(str(max_size))
     self.checkbutton21.set_active(reduce_size)
     self.checkbutton22.set_active(reduce_colors)
     self.entry_slideshow.set_value(tbi)
     pi = Picasa(token_file=comun.TOKEN_FILE)
     self.entry1.set_active(pi.do_refresh_authorization() is not None)
开发者ID:atareao,项目名称:Picapy,代码行数:18,代码来源:preferences.py

示例6: __init__

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
	def __init__(self):
		conf = Configuration.get()
		hdir = conf['haar_classifiers_dir']
		
		self.haarfiles = [ cv.cvLoadHaarClassifierCascade(str(hdir + h), cv.cvSize(10, 10)) for h in conf['haar_classifiers'] ]

		self.camera_devices = glob(conf['cameras_glob'])
开发者ID:rviscarra,项目名称:pywebsec,代码行数:9,代码来源:camera_manager.py

示例7: __init__

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
 def __init__(self, http):
     self._email, p12_file, self._p12_secret, self._scopes = Configuration.get(
         "google_app_email", "google_app_p12_file", "google_app_p12_secret", "google_api_scopes", not_null=True
     )
     stream = open(p12_file, "r")
     self._p12 = stream.read()
     stream.close()
     # check our credentials are those of a valid app
     self._valid(http, True)
开发者ID:richardtrip,项目名称:Brive,代码行数:11,代码来源:client.py

示例8: _is_an_exclusive_format

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
 def _is_an_exclusive_format(mimeType):
     exclusive = Configuration.get("formats_exclusive")
     if not exclusive:
         return True
     if format not in Document._exclusive_formats:
         possible_exts = set(mimetypes.guess_all_extensions(mimeType, strict=False))
         result = bool(possible_exts.intersection(exclusive))
         Document._exclusive_formats[format] = result
     return Document._exclusive_formats[format]
开发者ID:procule,项目名称:Brive,代码行数:11,代码来源:model.py

示例9: DoubleConfiguration

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
class DoubleConfiguration(object):

    """Class for retrieving environment configuration"""

    def __init__(self, path_local, path_default):
        """Initialization (loading both configurations)

        :path_local: unicode
            path to local configuration file
        :path_default: unicode
            path to default (fallback) configuration file
        # load configuration
        """
        self._local_configuration = Configuration(path_local)
        self._default_configuration = Configuration(path_default)

    def get(self, *args):
        """ Returns information from configration.

        :*args: key (or series of keys in case of nesting)
        """
        try:
            # first, try to find the information in local configuration file
            return self._local_configuration.get(*args)
        except ConfigurationException:
            # as a fallback, use default configuration file
            return self._default_configuration.get(*args)

    def get_nonempty(self, *args):
        """ Returns information from configration.

        :*args: key (or series of keys in case of nesting)
        """
        try:
            # first, try to find the information in local configuration file
            item = self._local_configuration.get(*args)
        except ConfigurationException:
            # as a fallback, use default configuration file
            item = self._default_configuration.get(*args)
        if item is None or item == '':
            raise ConfigurationException(
                'empty configuration item for key {key}'.format(
                    key='/'.join(args)))
        return item
开发者ID:effa,项目名称:wikicorpora,代码行数:46,代码来源:doubleconfiguration.py

示例10: compute

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
 def compute(self,A):
     """ returns all matrix elements. Data is organized as follows:
     
     T.elements[n = eigennumber] [starting configuration] = 
              ={ out_conf_0:coup_0, out_conf_1 : coup_1,...}
     """
     basemax=Configuration.base**Configuration.dimension
     # run over all possible configurations using integer representation
     for k in range(basemax):
         element=Configuration(k)
         n=element.get_count('1')
         self.elements[n][element.get()]=self.compute_column(element,A)
     return None
开发者ID:gmnakamura,项目名称:epidemic-transition-matrix,代码行数:15,代码来源:transition.py

示例11: __init__

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
 def __init__(self, keep_dirs, streaming):
     self._keep_dirs = keep_dirs
     self._streaming = streaming
     self._reset()
     self._creds = Credentials(self._http)
     self._domain, admin_login, users_api_endpoint, \
         self._drv_svc_name, self._drv_svc_version = \
         Configuration.get('google_domain_name',
                           'google_domain_admin_login',
                           'google_api_users_endpoint',
                           'google_api_drive_name',
                           'google_api_drive_version',
                           not_null=True)
     self._admin = User(admin_login, self, False)
     self._users_api_endpoint = \
         users_api_endpoint.format(domain_name=self._domain)
     Log.debug('Client loaded')
开发者ID:skion,项目名称:Brive,代码行数:19,代码来源:client.py

示例12: do_POST

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
	def do_POST(self):
		
		ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))
		if ctype == 'multipart/form-data':
			query=cgi.parse_multipart(self.rfile, pdict)
		user = query.get('user')
		password = query.get('password')
		
		conf = Configuration.get()
		self.usuario_valido = (user[0] == conf['user'] and password[0] == conf['password'])
		# print user[0], conf['user'], password[0], conf['password']
		
		
		if self.usuario_valido:
			
			cm = CameraManager()
			self._render_view('cameras', cameras = cm.get_cameras())
			
		else:
			
			self._render_view('auth_form')
开发者ID:rviscarra,项目名称:pywebsec,代码行数:23,代码来源:monitor_server.py

示例13: _view_camera

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
	
	def _view_camera(self, *args):
		
		device = self.cmb_cameras.get_active_text()
		
		proc = Process(target = MainWindow._start_camera_monitor, 
			args = (device,) )
			
		proc.start()
	
	@staticmethod
	def _start_monitor_server(port):
		
		os.popen(' '.join(('python', 'monitor_server.py', '-p', port)))
	
	@staticmethod
	def _start_camera_monitor(device):
		
		os.popen(' '.join(('python', 'camera_manager.py', '-d', device, '-f')))
		
	
	def main(self):
		self.win_main.show_all()
		gtk.main()

if __name__ == "__main__":
	
	config = Configuration.get()
	mainWin = MainWindow(config)
	mainWin.main()
开发者ID:rviscarra,项目名称:pywebsec,代码行数:32,代码来源:video_surveillance.py

示例14: Motion

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
class Motion():
    def __init__(self, motion_conf='motion.json', id_conf='id.json'):
        self.logger = logging.getLogger("motion")

        self.config = Configuration(motion_conf)

        quality = self.config.get('quality', 80)
        options = self.config.get('camera_options', {})

        save_width = self.config.get('save_width', 1296)
        save_height = self.config.get('save_height', 972)

        scratch_width = self.config.get('scratch_width', 100)
        scratch_height = self.config.get('scratch_height', 75)

        self.camera = Camera(resolution=(save_width, save_height), scratch=(scratch_width, scratch_height), quality=quality, options=options)

        # When the main image uploader threads can't keep up, buffer excess frames here.
        # They are popped off the queue by uploaders when more become available.
        self.capture_stream_queue = []
        self.capture_stream_queue_max = 80

        self.threshold = self.config.get('threshold', 30)
        self.sensitivity = self.config.get('sensitivity', 30)

        self.buffer = self.camera.capture_test_image()

    def detect_motion(self, auto_append=True):
        #self.logger.debug("Detecting motion...")

        changed_pixels = 0

        buffer = self.camera.capture_test_image()

        motion_detected = False

        max_pixdiff = 0

        if buffer:
            for x in range(0, self.camera.scratch_width):
                for y in range(0, self.camera.scratch_height):
                    pixdiff = abs(self.buffer[x,y][1] - buffer[x,y][1])

                    # Statistics, we want to know how far these pixels are changing
                    if (pixdiff > max_pixdiff):
                        max_pixdiff = pixdiff

                    if pixdiff > self.threshold:
                        changed_pixels += 1

                    if changed_pixels > self.sensitivity:
                        # motion detected, capture image and break from vertical loop
                        motion_detected = True
                        break
                # motion detected, break from horizontal loop
                if motion_detected:
                    break

        if motion_detected:
            self.logger.debug("Motion detected:")
            self.logger.debug("Ratio (max_pixdiff / threshold) = %s/%s" % (max_pixdiff, self.threshold))
            if auto_append:
                self.capture_to_stream_queue()

        # swap local and global buffer for next comparison
        self.buffer = buffer

        return motion_detected

    # Determine if any images were added to the stack of captured images.
    # Best use this to determine if any uploading needs to be done.
    # Remember to pop images off the stack when processed.
    def get_capture_queue_length(self):
        return len(self.capture_stream_queue)

    # Snaps a full-res picture and inserts left into the internal image queue.
    def capture_to_stream_queue(self):
        if (self.get_capture_queue_length() > self.capture_stream_queue_max):
            self.logger.critical("Stream queue is overloaded - discarded an image!")
            # Discard oldest image - this is very bad!
            self.pop_capture_stream_queue()

        (stream, buffer) = self.camera.capture_image()
        self.capture_stream_queue.insert(0, stream)
        self.logger.debug("Motion - Capture buffer length: (%i)" % len(self.capture_stream_queue))

    # Grabs the oldest image from the right of the internal image queue.
    def pop_capture_stream_queue(self):
        return self.capture_stream_queue.pop(0)

    def close(self):
        self.logger.info("Closing motion module.")
        self.camera.close()
开发者ID:razodactyl,项目名称:seclient,代码行数:95,代码来源:motion.py

示例15: test_get

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import get [as 别名]
    def test_get(self):
        config = Configuration('../configuration.yml')

        print(config.get('redis.host'))
开发者ID:Metrink,项目名称:metrink-fe,代码行数:6,代码来源:configuration_test.py


注:本文中的configuration.Configuration.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。