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


Python ConfigManager.instance方法代码示例

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


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

示例1: __init__

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def __init__(self):
     self.config = ConfigManager.instance()
     self.dbsession = dbsession
     self.cache = pylibmc.Client([self.config.memcached], binary=True)
     self.epoch = None  # Date/time of first snapshot
     self._load()
     self.event_manager = EventManager.instance()
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:9,代码来源:GameHistory.py

示例2: to_xml

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def to_xml(self, parent):
     ''' Convert object to XML '''
     box_elem = ET.SubElement(parent, "box")
     box_elem.set("gamelevel", str(self.game_level.number))
     ET.SubElement(box_elem, "name").text = self.name
     ET.SubElement(box_elem, "operatingsystem").text = self._operating_system
     ET.SubElement(box_elem, "description").text = self._description
     ET.SubElement(box_elem, "difficulty").text = self._difficulty
     ET.SubElement(box_elem, "garbage").text = self.garbage
     flags_elem = ET.SubElement(box_elem, "flags")
     flags_elem.set("count", str(len(self.flags)))
     for flag in self.flags:
         flag.to_xml(flags_elem)
     hints_elem = ET.SubElement(box_elem, "hints")
     hints_elem.set("count", str(len(self.hints)))
     for hint in self.hints:
         hint.to_xml(hints_elem)
     ips_elem = ET.SubElement(box_elem, "ipaddresses")
     ips_elem.set("count", str(len(self.ips)))
     for ip in self.ips:
         ip.to_xml(ips_elem)
     config = ConfigManager.instance()
     with open(config.avatar_dir + self.avatar) as favatar:
         data = favatar.read()
         ET.SubElement(box_elem, "avatar").text = data.encode('base64')
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:27,代码来源:Box.py

示例3: data

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def data(self, value):
     config = ConfigManager.instance()
     if self.uuid is None:
         self.uuid = str(uuid4())
     self.byte_size = len(value)
     with open(config.file_uploads_dir + self.uuid, 'wb') as fp:
         fp.write(value.encode('base64'))
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:9,代码来源:FileUpload.py

示例4: post

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def post(self, *args, **kwargs):
     '''
     Update configuration
     Disabled fields will not be send in the POST, so check for blank values
     '''
     try:
         config = ConfigManager.instance()
         config.game_name = self.get_argument('game_name', '')
         config.restrict_registration = self.get_argument('restrict_registration', '') == 'true'
         config.public_teams = self.get_argument('public_teams', '') == 'true'
         config.max_team_size = self.get_argument('max_team_size', '')
         config.max_password_length = self.get_argument('max_password_length', '')
         self.config_bots(config)
         reward = self.get_argument('bot_reward', '')
         if reward != '':
             config.bot_reward = reward
         config.use_black_market = self.get_argument('use_black_market', '') == 'true'
         upgrade_cost = self.get_argument('password_upgrade_cost', '')
         if upgrade_cost != '':
             config.password_upgrade_cost = upgrade_cost
         bribe_cost = self.get_argument('bribe_cost', '')
         if bribe_cost != '':
             config.bribe_cost = bribe_cost
         config.save()
         self.render('admin/configuration.html', errors=None, config=self.config)
     except Exception as error:
         logging.exception("Configuration update threw an exception")
         self.render('admin/configuration.html', errors=[str(error)], config=self.config)
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:30,代码来源:AdminHandlers.py

示例5: initialize

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def initialize(self):
     ''' Setup sessions, etc '''
     self.session = None
     self.config = ConfigManager.instance()
     session_id = self.get_secure_cookie('session_id')
     if session_id is not None:
         self.session = self._create_session(session_id)
         self.session.refresh()
开发者ID:xidianwlc,项目名称:TornadoAppTemplate,代码行数:10,代码来源:BaseHandlers.py

示例6: _registration_post_token

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def _registration_post_token(self, form):
     config_manager = ConfigManager.instance()
     config_manager.restrict_registration = True
     form["token"] = "NotARealRegToken"
     self.post("/registration", data=form)(self.stop)
     rsp, body = self.wait()
     assert "Invalid registration token" in body
     config_manager.restrict_registration = False
开发者ID:ElmoArmy,项目名称:RootTheBox,代码行数:10,代码来源:testHandlers.py

示例7: initialize

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def initialize(self):
     self.config = ConfigManager.instance()
     self.bot_manager = BotManager.instance()
     self.team_name = None
     if not self.config.use_bots:
         self.close()
     else:
         self.uuid = unicode(uuid4())
         self.opcodes = {"auth": self.auth}
开发者ID:harite,项目名称:RootTheBox,代码行数:11,代码来源:BotnetHandlers.py

示例8: render

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def render(self, *args, **kwargs):
     ''' Includes different CSS themes based on user prefs '''
     if self.handler.session is not None:
         return self.render_string("theme/css.html",
             theme=self.handler.session['theme']
         )
     else:
         config = ConfigManager.instance()
         default_theme = config.default_theme
         return self.render_string("theme/css.html", theme=default_theme)
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:12,代码来源:CssTheme.py

示例9: __init__

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def __init__(self):
     config = ConfigManager.instance()
     self.botnet = {}  # Holds refs to wsockets
     self.monitors = {}
     self.sqlite_engine = create_engine(u'sqlite://')
     setattr(self.sqlite_engine, 'echo', config.bot_sql)
     Session = sessionmaker(bind=self.sqlite_engine, autocommit=True)
     self.botdb = Session(autoflush=True)
     MemoryBaseObject.metadata.create_all(self.sqlite_engine)
     self.dbsession = dbsession
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:12,代码来源:BotManager.py

示例10: initialize

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def initialize(self):
     """ Setup sessions, etc """
     self.session = None
     self._dbsession = dbsession
     self.new_events = []
     self.event_manager = self.application.settings["event_manager"]
     self.config = ConfigManager.instance()
     session_id = self.get_secure_cookie("session_id")
     if session_id is not None:
         self.session = self._create_session(session_id)
         self.session.refresh()
开发者ID:harite,项目名称:RootTheBox,代码行数:13,代码来源:BaseHandlers.py

示例11: setup_database

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
def setup_database(db_name):
    # Setup the test database
    logging.debug("Setting up the test database connection ...")
    config_manager = ConfigManager.instance()
    config_manager.db_connection = 'sqlite:///%s.db' % db_name
    assert config_manager.db_connection == 'sqlite:///%s.db' % db_name

    # Create the default tables
    logging.debug("Creating tables ... ")
    from setup.create_database import create_tables, engine, metadata
    create_tables(engine, metadata, False)
    import setup.bootstrap
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:14,代码来源:__init__.py

示例12: avatar

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def avatar(self, image_data):
     if len(image_data) < (1024 * 1024):
         ext = imghdr.what("", h=image_data)
         if ext in ['png', 'jpeg', 'gif', 'bmp']:
             config = ConfigManager.instance()
             if self._avatar is not None and os.path.exists(config.avatar_dir + self._avatar):
                 os.unlink(config.avatar_dir + self._avatar)
             file_path = str(config.avatar_dir + self.uuid + '.' + ext)
             with open(file_path, 'wb') as fp:
                 fp.write(image_data)
             self._avatar = self.uuid + '.' + ext
         else:
             raise ValueError("Invalid image format, avatar must be: .png .jpeg .gif or .bmp")
     else:
         raise ValueError("The image is too large")
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:17,代码来源:User.py

示例13: to_xml

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def to_xml(self, parent):
     '''
     Admins cannot be exported as XML, not that they would be
     exported because they're not on a team, but check anyways
     '''
     if not self.has_permission(ADMIN_PERMISSION):
         user_elem = ET.SubElement(parent, "user")
         ET.SubElement(user_elem, "handle").text = self.handle
         ET.SubElement(user_elem, "password").text = self._password
         bpass_elem = ET.SubElement(user_elem, "bankpassword")
         bpass_elem.text = self._bank_password
         bpass_elem.set("algorithm", self.algorithm)
         config = ConfigManager.instance()
         with open(config.avatar_dir + self.avatar) as fp:
             data = fp.read()
             ET.SubElement(user_elem, "avatar").text = data.encode('base64')
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:18,代码来源:User.py

示例14: create

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
def create():
    ''' Creates/bootstraps the database '''
    from libs.ConfigManager import ConfigManager  # Sets up logging
    print(INFO+'%s : Creating the database ...' % current_time())
    from setup.create_database import create_tables, engine, metadata
    dev = ConfigManager.instance().bootstrap == 'developement'
    create_tables(engine, metadata, dev)
    print(INFO+'%s : Bootstrapping the database ...' % current_time())
    import setup.bootstrap
    # Display Details
    if dev:
        environ = bold + R + "Developement boot strap" + W
        details = ", admin password is 'nimda123'."
    else:
        environ = bold + "Production boot strap" + W
        details = '.'
    print INFO + '%s completed successfully%s' % (environ, details)
开发者ID:bincker,项目名称:RootTheBox,代码行数:19,代码来源:rootthebox.py

示例15: _hash_bank_password

# 需要导入模块: from libs.ConfigManager import ConfigManager [as 别名]
# 或者: from libs.ConfigManager.ConfigManager import instance [as 别名]
 def _hash_bank_password(cls, algorithm_name, password):
     '''
     Hashes the password using Md5/Sha1/Sha256/Sha512
     only used for the admin accounts.  We only allow
     whitespace/non-ascii.
     '''
     config = ConfigManager.instance()
     password = filter(lambda char: char in printable[:-6], password)
     if config.max_password_length < len(password):
         raise ValueError("Bank password is too long")
     if algorithm_name is None:
         algorithm_name = DEFAULT_HASH_ALGORITHM
     if algorithm_name in cls.algorithms:
         algo = cls.algorithms[algorithm_name][0]()
         algo.update(password)
         return algo.hexdigest()
     else:
         raise ValueError("Algorithm %s not supported." % algorithm_name)
开发者ID:AdaFormacion,项目名称:RootTheBox,代码行数:20,代码来源:User.py


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