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


Python Configuration.instance方法代码示例

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


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

示例1: restoreRegionBackup

# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import instance [as 别名]
 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,代码行数:18,代码来源:RestoreTasklet.py

示例2: main

# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import instance [as 别名]
def main(argv=None):
    '''Command line options.'''
    program_name = os.path.basename(sys.argv[0])
    program_version = "v0.8"
    program_build_date = "%s" % __updated__

    program_version_string = '%%prog %s (%s)' % (program_version, program_build_date)
    #program_usage = '''usage: spam two eggs''' # optional - will be autogenerated by optparse
    program_longdesc = '''''' # optional - give further explanation about what the program does
    program_license = "Copyright 2014 InWorldz LLC, This is unreleased source code of InWorldz, All Rights Reserved."

    if argv is None:
        argv = sys.argv[1:]

    # setup option parser
    parser = OptionParser(version=program_version_string, epilog=program_longdesc, description=program_license)

    parser.add_option("-c", "--config", dest="configPath", help="where the deamon should look for the config file [default: %default]")
    parser.add_option("-a", "--setauth", action="store_true", default=False, dest="setAuth", help="don't start the deamon, but instead set authorization information for the given resource")


    # set defaults
    if sys.platform == 'win32':
        confName=os.path.realpath("taskmanager.conf")
    else:
        confName="/etc/maestro/taskmanager.conf"
    parser.set_defaults(configPath=confName)

    # process options
    (opts, args) = parser.parse_args(argv)

    cfg = Configuration.instance()
    cfg.loadFromFile(opts.configPath)

    CredentialCrypt.SECRET = cfg.getValue("credential_crypt_secret")
    CredentialCrypt.IV = cfg.getValue("credential_crypt_iv")

    print "Loaded "+opts.configPath

    if opts.setAuth:
        #print args
        ComputeResource.setAuth(cfg.getEnvironmentDbConfig(), args[0], args[1], args[2])
    else:
        server = TaskManagerServer(cfg)
        server.run()
开发者ID:InWorldz,项目名称:maestro,代码行数:47,代码来源:taskmanager.py

示例3: storeResultsToDb

# 需要导入模块: from config import Configuration [as 别名]
# 或者: from config.Configuration import instance [as 别名]
 def storeResultsToDb(self, stats):
     dbConfig = Configuration.instance().getEnvironmentDbConfig()
     
     cnx = mysql.connector.connect(**dbConfig)
     
     try:
         insertResourceStatSql = \
             "INSERT INTO computeresourcestats(collected_on, computeresource_id, cpu_used_percentage, " +\
                 "memory_used_percentage, disk_used_percentage) VALUES(NOW(),%s,%s,%s,%s)"
                 
         args = (self.task.resourceId, 
                 stats['computeResourceStats']['cpu_used_percentage'],
                 stats['computeResourceStats']['memory_used_percentage'],
                 stats['computeResourceStats']['disk_used_percentage']
                 )
         
         cursor = cnx.cursor()
         cursor.execute(insertResourceStatSql, args)
         cnx.commit()
         cursor.close()
         
         insertRegionStatSql = \
             "INSERT INTO deployedregionstats(collected_on, region_id, cpu_used_percentage, " +\
                 "memory_used, thread_count, handle_count) VALUES(NOW(),%s,%s,%s,%s,%s)"
         
         for regionData in stats['regionStats']:
             args = (regionData['region_id'], 
                     regionData['cpu_used_percentage'],
                     regionData['memory_used'],
                     regionData['thread_count'],
                     regionData['handle_count']
                     )
             
             cursor = cnx.cursor()
             cursor.execute(insertRegionStatSql, args)
             cnx.commit()
         
         
     finally:
         cnx.close()
开发者ID:InWorldz,项目名称:maestro,代码行数:42,代码来源:CollectStatsTasklet.py


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