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


Python config.Configuration类代码示例

本文整理汇总了Python中config.Configuration的典型用法代码示例。如果您正苦于以下问题:Python Configuration类的具体用法?Python Configuration怎么用?Python Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setup

    def setup(self):
        Configuration.load()
        self.url = Configuration.integration_url(Configuration.CIRCULATION_MANAGER_INTEGRATION)

        millenium = Configuration.integration(Configuration.MILLENIUM_INTEGRATION)
        self.test_username = millenium.get(Configuration.AUTHENTICATION_TEST_USERNAME)
        self.test_password = millenium.get(Configuration.AUTHENTICATION_TEST_PASSWORD)
开发者ID:datalogics-tsmith,项目名称:circulation,代码行数:7,代码来源:__init__.py

示例2: main

def main():
    config = Configuration()
    credentials = config.get_credentials()

    # Create an httplib2.Http object to handle our HTTP requests and authorize it
    # with our good Credentials.
    http = httplib2.Http()
    http = credentials.authorize(http)

    # Construct the service object for the interacting with the Admin Reports API.
    service = discovery.build('admin', 'reports_v1', http=http)
    activities = service.activities()

    settings = config.settings
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    try:
        login_list = activities.list(userKey='all', applicationName='login', maxResults=1000).execute()
        DBSession.query(LoginItem).first()

        print("Success!")
    except client.AccessTokenRefreshError:
        print("Failure. Access token is invalid. Please re-run the tool to get a new access token.")
    except OperationalError:
        print("Database has not been initialised. Please run acctwatch_initdb.")
    except:
        print("Some other unknown error occured")
开发者ID:GuardedRisk,项目名称:Google-Apps-Auditing,代码行数:28,代码来源:configcheck.py

示例3: run

 def run(self):
     config = Configuration()
     jid = config.get('connection', 'jid')
     password = config.get('connection', 'password')
     resource = config.get('connection', 'resource')
     debug = config.getboolean('connection', 'debug')
     bot = UpwalkJabberBot(jid, password, resource, debug)
     bot.serve_forever()
开发者ID:lzap,项目名称:upwalk,代码行数:8,代码来源:bot.py

示例4: test_create_config

    def test_create_config(self):
        """
        Tests creation of a blank configuration ensuring that the file is not created on the file system until after the
        save() method is called on the configuration object. Also implicitly tests writing blank config files.

        """
        conf = Configuration(testconfig, create=True)
        if os.path.exists(testconfig):
            self.fail("File should not be written until save() is executed")
        conf.save()
        self.assertTrue(os.path.isfile(testconfig), "File should exist after having been written")
开发者ID:flungo,项目名称:python-yaml-config,代码行数:11,代码来源:config_test.py

示例5: doStuff

	def doStuff():
		global Config
		global yourThread
		with dataLock:
			# Do your stuff with commonDataStruct Here
			logger.info('rereading config file looking for changes - thread {}'.format(threading.current_thread().name))
			Config = Configuration(Default_Config_FilePath)
			logger.debug("Loading system config file from file: " + ConfigFilePath)
			Config.load(ConfigFilePath)

		# Set the next thread to happen
		yourThread = threading.Timer(CONFIG_INTERVAL, doStuff, ())
		yourThread.start()
开发者ID:callumdmay,项目名称:pi-notification-app,代码行数:13,代码来源:light_monitor.py

示例6: __init__

    def __init__(self, mq_server=None, mq_name=None, logger=None):
        """__init__

        :param mq_server:
        :param mq_name:
        """
        self.mq_server = mq_server if mq_server else Configuration.get("mq_server")
        self.mq_name = mq_name if mq_name else Configuration.get("mq_name")
        connection = pika.BlockingConnection(
            pika.ConnectionParameters(host=self.mq_server))
        self.mq_channel = connection.channel()
        self.mq_channel.queue_declare(self.mq_name, durable=True)
        self.logger = logger if logger else Logger.get(self.__class__.__name__)
开发者ID:csyangning,项目名称:stock_tracer,代码行数:13,代码来源:mq_service.py

示例7: load

    def load(self):
        """
        Loads a config.json file and run a validation process.
        If the configurations seem valid, returns Configuration object.

        """
        util.set_working_directory()
        # paths relatively to this script's location
        schema_json = util.json_decode(self.schema_path)
        if schema_json is None:
            msg = "Problem has occurred during the decoding procedure" + \
                  " with the following file: " + self.schema_path + "."
            logging.error(msg)
            raise IOError(msg)
        tools_json = util.json_decode(self.tools_path)
        if tools_json is None:
            msg = "Problem has occurred during the decoding procedure" + \
                  " with the following file: " + self.tools_path + "."
            logging.error(msg)
            raise IOError(msg)

        try:
            with open(self.config_path, mode="r") as file:
                config_string = file.read()
            decoder = json.JSONDecoder(object_pairs_hook=checking_hook)
            config_json = decoder.decode(config_string)
        except IOError:
            msg = "The file does not exist or cannot be read:" + \
                  (os.path.split(self.config_path))[1]
            logging.error(msg)
            raise IOError(msg)
        except ValueError as value_error:
            msg = (os.path.split(self.config_path))[1] + " file is not valid"
            logging.error(msg)
            print(value_error)
            raise ValidationError(msg)
        except KeyError as k_error:
            msg = "Duplicate key specified."
            logging.error(msg)
            print(k_error)
            print("Modify: " + (os.path.split(self.config_path))[1])
            raise ValidationError(msg)

        valid = validation.is_valid_json(config_json, schema_json)
        if not valid:
            msg = "Validation failed for " + \
                  (os.path.split(self.config_path))[1] + "."
            logging.error(msg)
            raise ValidationError(msg)

        config = Configuration()
        config.iterations = config_json["IterationCount"]
        config.runs = config_json["Runs"]
        config.queries = config_json["Queries"]
        config.scenarios = config_json["Scenarios"]
        config.sizes = util.get_power_of_two(config_json["MinSize"], config_json["MaxSize"])
        config.tools = config_json["Tools"]
        config.optional_arguments = config_json["OptionalArguments"]

        return config
开发者ID:pappist,项目名称:trainbenchmark,代码行数:60,代码来源:loader.py

示例8: __init__

    def __init__(self, model):
        Logger.info("Created communication")

        self.host = Configuration.get_hostname()
        self.port = Configuration.get_port()
        self.socket = None
        self.model = model
        self.communication_tries = 20
        self.time = 10

        self.role = Configuration.get_role()
        self.json_builder = JsonBuilder(self.role)

        self.prepare_connection()
开发者ID:kamilfocus,项目名称:PKSS,代码行数:14,代码来源:communication.py

示例9: add_configuration_links

 def add_configuration_links(cls, feed):
     for rel, value in (
             ("terms-of-service", Configuration.terms_of_service_url()),
             ("privacy-policy", Configuration.privacy_policy_url()),
             ("copyright", Configuration.acknowledgements_url()),
             ("about", Configuration.about_url()),
     ):
         if value:
             d = dict(href=value, type="text/html", rel=rel)
             if isinstance(feed, OPDSFeed):
                 feed.add_link(**d)
             else:
                 # This is an ElementTree object.
                 link = E.link(**d)
                 feed.append(link)
开发者ID:datalogics-tsmith,项目名称:circulation,代码行数:15,代码来源:opds.py

示例10: fulfill_open_access

    def fulfill_open_access(self, licensepool, delivery_mechanism):
        # Keep track of a default way to fulfill this loan in case the
        # patron's desired delivery mechanism isn't available.
        fulfillment = None
        for lpdm in licensepool.delivery_mechanisms:
            if not (lpdm.resource and lpdm.resource.representation
                    and lpdm.resource.representation.url):
                # We don't actually know how to deliver this
                # allegedly open-access book.
                continue
            if lpdm.delivery_mechanism == delivery_mechanism:
                # We found it! This is how the patron wants
                # the book to be delivered.
                fulfillment = lpdm
                break
            elif not fulfillment:
                # This will do in a pinch.
                fulfillment = lpdm

        if not fulfillment:
            # There is just no way to fulfill this loan.
            raise NoOpenAccessDownload()

        rep = fulfillment.resource.representation
        cdn_host = Configuration.cdn_host(Configuration.CDN_OPEN_ACCESS_CONTENT)
        content_link = cdnify(rep.url, cdn_host)
        media_type = rep.media_type
        return FulfillmentInfo(
            identifier_type=licensepool.identifier.type,
            identifier=licensepool.identifier.identifier,
            content_link=content_link, content_type=media_type, content=None, 
            content_expires=None
        )
开发者ID:datalogics-tsmith,项目名称:circulation,代码行数:33,代码来源:circulation.py

示例11: __init__

    def __init__(self):
        
        self._config = Configuration.getInstance().getConfig()
        
        self._driver = Driver()
        self._createSensor(self._config[Configuration.KEY_IMU_CLASS])
        
        #PID constants must have the same length
        self._pidAnglesSpeedKP = self._config[Configuration.PID_ANGLES_SPEED_KP] 
        self._pidAnglesSpeedKI = self._config[Configuration.PID_ANGLES_SPEED_KI]
        self._pidAnglesSpeedKD = self._config[Configuration.PID_ANGLES_SPEED_KD]
        
        #PID constants must have the same length
        self._pidAnglesKP = self._config[Configuration.PID_ANGLES_KP] 
        self._pidAnglesKI = self._config[Configuration.PID_ANGLES_KI]
        self._pidAnglesKD = self._config[Configuration.PID_ANGLES_KD]
        
        self._pidAccelKP = self._config[Configuration.PID_ACCEL_KP]
        self._pidAccelKI = self._config[Configuration.PID_ACCEL_KI]
        self._pidAccelKD = self._config[Configuration.PID_ACCEL_KD]
        
        #PID
        self._pidKP = self._pidAnglesSpeedKP + self._pidAnglesKP + self._pidAccelKP
        self._pidKI = self._pidAnglesSpeedKI + self._pidAnglesKI + self._pidAccelKI
        self._pidKD = self._pidAnglesSpeedKD + self._pidAnglesKD + self._pidAccelKD
        
        self._pid = PID(FlightController.PID_PERIOD, \
                        self._pidKP, self._pidKI, self._pidKD, \
                        self._readPIDInput, self._setPIDOutput, \
                        "stabilization-pid")
        self._pid.setTargets([0.0]*len(self._pidKP))
        

        self._isRunning = False
开发者ID:hisie,项目名称:eaglebone,代码行数:34,代码来源:controller.py

示例12: restoreRegionBackup

 def restoreRegionBackup(self, region, fileName):
     regionName = self.session.api.Region.get_sim_name(region)
     regionOwner = self.session.api.Region.get_master_avatar_uuid(region)
     
     backupStoragePath = os.path.join(Configuration.instance().generateFullOarBackupPath(regionOwner, region), fileName)
     
     #try to copy the OAR to the transfer location
     transferFileName = fileName + "_" + inworldz.util.general.id_generator()
     transferPath = os.path.join(Configuration.instance().transferSharePath, transferFileName)
     
     shutil.copy(backupStoragePath, transferPath)
     
     self.session.api.Region.CopyFileFromTransferLocation(region, transferFileName, True)
     
     if not self.session.api.Region.Restore(region, regionName, fileName, False, False):
         raise Exception("Restore failed for region {0} '{1}'".format(region, regionName))
开发者ID:InWorldz,项目名称:maestro,代码行数:16,代码来源:RestoreTasklet.py

示例13: __init__

    def __init__(self, input_file, sub_file, output_file, log_stdout=False):
        """
        Store information about input and output files and subtitles. Store if
        log stdout and set object's attributes.
        @param input_file str, Path to input file
        @param sub_file str, Path to subtitles file
        @param output_file str, Path to output file
        @param log_stdout bool, Store stdout after process finish
        """
        self.input_file = input_file
        self.sub_file = sub_file
        self.output_file = output_file
        self.log_stdout = log_stdout

        self.config = Configuration()
        self.logger = logging.getLogger(self.__class__.__name__)

        self.process_transport = None
        self.process_protocol = None

        self.started = False
        self.finished = False
        self.paused = False
        self.cancelled = False
        self.deferred = defer.Deferred()
        self.deferred.addErrback(self.process_exited)

        self.pid = None
        self.returncode = None
        self.stderr = None
        self.stdout = None
开发者ID:jakm,项目名称:VideoConvertor,代码行数:31,代码来源:process.py

示例14: from_environment

 def from_environment(cls, redirect_uri, test_mode=False):
     if test_mode:
         return cls('/path', '/callback', test_mode)
     config = dict(Configuration.integration(
         Configuration.GOOGLE_OAUTH_INTEGRATION
     )['web'])
     return cls(config, redirect_uri, test_mode)
开发者ID:dguo,项目名称:circulation,代码行数:7,代码来源:oauth.py

示例15: __init__

    def __init__(self, data_source_name, list_name, metadata_client=None,
                 overwrite_old_data=False,
                 annotation_field='text',
                 annotation_author_name_field='name',
                 annotation_author_affiliation_field='location',
                 first_appearance_field='timestamp',
                 **kwargs
             ):
        super(CustomListFromCSV, self).__init__(data_source_name, **kwargs)
        self.foreign_identifier = list_name
        self.list_name = list_name
        self.overwrite_old_data=overwrite_old_data

        if not metadata_client:
            metadata_url = Configuration.integration_url(
                Configuration.METADATA_WRANGLER_INTEGRATION,
                required=True
            )
            metadata_client = SimplifiedOPDSLookup(metadata_url)
        self.metadata_client = metadata_client

        self.annotation_field = annotation_field
        self.annotation_author_name_field = annotation_author_name_field
        self.annotation_author_affiliation_field = annotation_author_affiliation_field
        self.first_appearance_field = first_appearance_field
开发者ID:NYPL-Simplified,项目名称:server_core,代码行数:25,代码来源:external_list.py


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