本文整理汇总了Python中util.config.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get
def get(self):
"""Initial request handler for receiving auth code."""
err = self.request.arguments.get('error', [None])[0]
if err is not None:
if err == 'access_denied':
return self.redirect(self.reverse_url('auth_denied'))
return self.send_error(500)
self.http_client = AsyncHTTPClient()
code = self.request.arguments.get('code', [None])[0]
if code is not None:
self.gplus_auth_code = code
# OAuth step #2: Receive authorization code, POST it
# back to Google to get an access token and a refresh token.
post_body = urllib.urlencode({
'code': code,
'client_id': Config.get('oauth', 'client-id'),
'client_secret': Config.get('oauth', 'client-secret'),
'redirect_uri': 'http://%s/oauth2callback' % self.request.host,
'grant_type': 'authorization_code',
})
return self.http_client.fetch(
'https://accounts.google.com/o/oauth2/token',
self.on_token_request_complete,
method='POST',
body=post_body,
request_timeout=20.0,
connect_timeout=15.0,
)
# If we got here, we don't recognize why this endpoint was called.
self.send_error(501) # 501 Not Implemented
开发者ID:astore,项目名称:pluss,代码行数:34,代码来源:oauth.py
示例2: __init__
def __init__(self, config):
"""
__init__()
Purpose: Constructor for the HootPy class.
Parameters: config [type=dictionary]
Dictionary containing the configuration parameters for this run.
"""
self._valid_time = datetime.utcnow()
for key, value in config.iteritems():
setattr(self, "_%s" % key, value)
try:
meta_filename = config['meta_filename']
except KeyError:
meta_filename = "default/meta.hp"
meta = Config(meta_filename)
for key, value in meta.iteritems():
setattr(self, "_%s" % key, value)
self._var_name_cache = []
self._sanitizeHootPy()
self._sanitize()
return
开发者ID:pulsatrixwx,项目名称:PulsatrixWx,代码行数:29,代码来源:hootpy.py
示例3: __init__
def __init__(self):
cfg = Config()
opencv_home = cfg.get("face_detection", "opencv_home")
haarcascade = cfg.get("face_detection", "haarcascade")
self.haarcascade = cv2.CascadeClassifier('{0}/{1}'.format(opencv_home,
haarcascade))
开发者ID:satishkt,项目名称:smart-cam,代码行数:7,代码来源:face_detection_v1.py
示例4: initialize
def initialize():
messages = []
levels = {'NOTSET': logging.NOTSET, 'DEBUG': logging.DEBUG, 'INFO': logging.INFO, 'WARNING': logging.WARNING, 'ERROR': logging.ERROR, 'CRITICAL': logging.CRITICAL}
loglevel = Config.get("logging", "severity")
logfile = Config.get("logging", "logfile")
# If the configfile lists a loglevel that is not valid, assume info.
if(loglevel not in levels):
# Since the logger is not yet initialized, add the logging-message to the messagelist, so that we can
# log it whenever the logger is initialized.
messages.append(("LogLevel is not correctly set in the config-file. Assuming INFO", logging.ERROR))
print "A"
loglevel = "INFO"
rootlogger = logging.getLogger()
formatter = logging.Formatter('%(asctime)s: %(name)s: %(levelname)s - %(message)s')
fh = logging.FileHandler(logfile)
fh.setFormatter(formatter)
rootlogger.addHandler(fh)
rootlogger.setLevel(levels[loglevel])
messages.append(("Logger initialized", logging.INFO))
# Now that the logger is initialized, log the messages that appared during the initialization of the module
logger = logging.getLogger(__name__)
for m in messages:
logger.log(m[1], m[0])
开发者ID:SnowmanRM,项目名称:Snowman,代码行数:28,代码来源:logger.py
示例5: __init__
def __init__(self, message, str = None):
cfg = Config('chats', message)
if (str is None):
self.str = cfg.get('message')
else:
self.str = str
self.str = self.str.replace('\\\n', '').replace('\n','\n\n')
self.duration = cfg.get('duration')
self.font = FontManager.getFont(cfg.get('font'))
self.font.setPointSize(cfg.get('font_size'))
self.font_color = QColor.fromRgb(*cfg.get('font_color'))
self.image = QImage(cfg.get('image_path'))
p = cfg.get('image_pos')
self.image_rect = QRect(0.,0.,self.image.width(),self.image.height())
self.image_rect.moveCenter(QPoint(p[0],p[1]))
self.text_rect = QRect(*cfg.get('text_rect'))
self.has_cursor = True
self.blink_elapsed = 0.
self.blink_time = cfg.get('blink_time')
self.elapsed = 0.
self.message_sz = len(self.str)
开发者ID:giulianoxt,项目名称:pyasteroids,代码行数:30,代码来源:messages.py
示例6: __init__
def __init__(self, level_number):
Level.instance = self
self.number = level_number
self.camera = None
self.controller = None
self.objects = set()
self.asteroids = set()
self.shots = set()
self.planets = set()
self.portals = set()
self.particles = set()
self.missiles = set()
self.ship = None
self.models = {}
self.enemy_shots = set()
self.enemy_ships = set()
self.has_skybox = False
cfg = Config('levels',str(level_number))
level_name = cfg.get('name')
self.load_file(level_name)
skybox = cfg.get('skybox')
if (self.has_skybox):
self.setup_skybox('resources/'+skybox)
self.first = True
开发者ID:giulianoxt,项目名称:pyasteroids,代码行数:33,代码来源:level.py
示例7: access_token_for_id
def access_token_for_id(cls, id, callback):
"""Returns the access token for an id, acquiring a new one if necessary."""
token = Cache.get(cls.auth_cache_key_template % id)
if token:
return IOLoop.instance().add_callback(lambda: callback(token))
# If we don't have an access token cached, see if we have a refresh token
token = TokenIdMapping.lookup_refresh_token(id)
if token:
post_body = urllib.urlencode({
'client_id': Config.get('oauth', 'client-id'),
'client_secret': Config.get('oauth', 'client-secret'),
'refresh_token': token,
'grant_type': 'refresh_token',
})
http_client = AsyncHTTPClient()
return http_client.fetch(
'https://accounts.google.com/o/oauth2/token',
lambda response: cls.on_refresh_complete(response, id, callback),
method='POST',
body=post_body,
request_timeout=20.0,
connect_timeout=15.0,
)
else:
logging.error("Unable to update access token for %s, no refresh token stored.", id)
return IOLoop.instance().add_callback(lambda: callback(None))
开发者ID:astore,项目名称:pluss,代码行数:27,代码来源:oauth.py
示例8: test_config_get_team_for_story_none
def test_config_get_team_for_story_none(self):
config = Config()
class FakeStory:
team = "no-such-team"
team = config.get_team_for_story(FakeStory)
self.assertEqual(team["ga_org_id"], "DEFAULT-ID")
开发者ID:thecarebot,项目名称:carebot,代码行数:8,代码来源:test_config.py
示例9: test_config_get_team_for_story
def test_config_get_team_for_story(self):
config = Config()
class FakeStory:
team = "viz"
team = config.get_team_for_story(FakeStory)
self.assertEqual(team["ga_org_id"], "visuals-sample-id")
开发者ID:thecarebot,项目名称:carebot,代码行数:8,代码来源:test_config.py
示例10: __init__
def __init__(self):
if (Player.instance is None):
Player.instance = self
cfg = Config('game', 'Player')
self.max_hp = cfg.get('max_hp')
self.initial_lifes = cfg.get('initial_lifes')
self.reset()
开发者ID:giulianoxt,项目名称:pyasteroids,代码行数:9,代码来源:state.py
示例11: __init__
def __init__(self, parent):
QGLWidget.__init__(self, parent)
cfg = Config('game','OpenGL')
self.fps = cfg.get('fps')
self.clearColor = cfg.get('clear_color')
self.adjust_widget()
self.adjust_timer()
开发者ID:giulianoxt,项目名称:pyasteroids,代码行数:10,代码来源:opengl.py
示例12: resizeGL
def resizeGL(self, width, height):
QGLWidget.resizeGL(self,width,height)
glViewport(0,0,width,height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
cfg = Config('game','OpenGL')
fovy = cfg.get('y_field_of_view')
z_near = cfg.get('z_near')
z_far = cfg.get('z_far')
gluPerspective(fovy,float(width)/height,z_near,z_far)
开发者ID:giulianoxt,项目名称:pyasteroids,代码行数:13,代码来源:opengl.py
示例13: __parse_config
def __parse_config(self, config_file):
from util.config import Config
config = Config(config_file)
config.set_general_setting()
image_target = config.get_setting("image", "target")
if not image_target:
print(get_msg(Msg.not_any_image_specified_program_exit))
sys.exit()
phrase_target = config.get_setting("phrase", "target")
import glob
self.__image_setting += glob.glob(image_target)
self.__phrase_setting += glob.glob(phrase_target) if phrase_target else []
开发者ID:r-kan,项目名称:reminder,代码行数:14,代码来源:main.py
示例14: __init__
def __init__(self):
self.__mq_server = None
self.__data_db = DB(Constants.HIST_DATA_DB_NAME)
self.__config = Config()
self.__tick_db = FileDB(self.__config.get_config('persistent', 'hist_tick_dir'))
self.__trading_strategy = None
self.__tick_collector = None
开发者ID:sandtower,项目名称:crystalball,代码行数:7,代码来源:strategy_engine.py
示例15: from_config
def from_config(cls, section, interface):
cfg = Config('interface', section)
img_path = cfg.get('image_path')
img_pos = cfg.get('image_pos')
img_scale = cfg.get('image_scale')
img = QImage('resources/images/'+ img_path)
img_w, img_h = img.width(), img.height()
img_rect = QRect(
img_pos[0], img_pos[1],
int(img_w*img_scale), int(img_h*img_scale)
)
view_rect = QRect(*cfg.get('view_rect'))
return cls(img, img_rect, view_rect, interface)
开发者ID:giulianoxt,项目名称:pyasteroids,代码行数:17,代码来源:interface.py
示例16: __init__
def __init__(self, args=None):
QtCore.QObject.__init__(self)
self.app = QtGui.QApplication(["FireSim"])
self.args = args
self.config = Config("data/config.json")
self._selected_fixture_strand = 0
self._selected_fixture_address = 0
self._selected_fixture_pixels = 0
self.selected_fixture = None
self.scene = Scene(os.path.join(self.config.get("scene_root"), self.args.scene) + ".json")
self.scenecontroller = SceneController(app=self, scene=self.scene)
QtDeclarative.qmlRegisterType(CanvasWidget, "FireSim", 1, 0, "SimCanvas")
QtDeclarative.qmlRegisterType(FixtureWidget, "FireSim", 1, 0, "Fixture")
self.view = QtDeclarative.QDeclarativeView()
self.view.setWindowTitle("FireSim")
self.view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView)
self.view.closeEvent = self.on_close
self.context = self.view.rootContext()
self.context.setContextProperty("main", self)
self.fixture_info_list = []
self.context.setContextProperty("fixtureInfoModel", self.fixture_info_list)
self.view.setSource(QtCore.QUrl("ui/qml/FireSimGUI.qml"))
self.root = self.view.rootObject()
self.item_frame = self.root.findChild(QtDeclarative.QDeclarativeItem)
self.canvas = self.root.findChild(CanvasWidget)
self.scenecontroller.set_canvas(self.canvas)
cw, ch = self.scenecontroller.scene.get("extents")
self.canvas.setWidth(cw)
self.canvas.setHeight(ch)
self.root.backdrop_showhide_callback.connect(self.on_btn_backdrop_showhide)
self.root.labels_showhide_callback.connect(self.on_btn_labels_showhide)
self.root.lock_callback.connect(self.on_btn_lock)
self.netcontroller = NetController(self)
self.canvas_timer = QtCore.QTimer(self)
self.canvas_timer.timeout.connect(self.on_canvas_timer)
self.view.setFixedSize(max(640, cw + 130), max(480, ch))
log.info("FireSimGUI Ready.")
self.view.show()
self.canvas_timer.start(300)
开发者ID:nyarasha,项目名称:firesim,代码行数:58,代码来源:firesimgui.py
示例17: index
def index(request):
"""The default view for the update section."""
data = {}
# Create a list over sources.
data["sources"] = createSourceList()
# If something is posted:
if request.POST:
# Create the form based on the posted data
data["manualUpdateForm"] = ManualUpdateForm(request.POST, request.FILES)
# If the form is considered valid:
if data["manualUpdateForm"].is_valid():
# Construct some path where we can work.
workarea = Config.get("storage", "inputFiles")
create = Config.get("storage", "createIfNotExists")
filename = os.path.join(workarea, request.FILES["file"].name)
# Create the working-directories, if needed and wanted.
if os.path.isdir(workarea) == False and create == "true":
os.makedirs(workarea)
# Store the uploaded file.
upload = open(filename, "wb+")
for chunk in request.FILES["file"].chunks():
upload.write(chunk)
upload.close()
# Generate a message for the user
source = Source.objects.get(pk=request.POST["source"])
if source.locked:
data["uploadMessage"] = "There is already an update going for this source!"
else:
data[
"uploadMessage"
] = "The ruleset is now uploaded, and the processing of the file is started. This might take a while however, depending on the size of the file."
# Call the background-update script.
subprocess.call(["/usr/bin/snowman-manualUpdate", filename, source.name])
# If nothing is posted, create an empty form
else:
data["manualUpdateForm"] = ManualUpdateForm()
return render(request, "update/index.tpl", data)
开发者ID:wzr,项目名称:Snowman,代码行数:45,代码来源:updateviews.py
示例18: __init__
def __init__(self, level_number, level):
self.level_number = level_number
self.info = {}
self.fields = set()
self.level = level
self.player_state = Player.get_instance()
cfg = Config('interface', 'Settings')
font_name = cfg.get('field_font')
font_size = cfg.get('field_font_sz')
self.field_font = FontManager.getFont(font_name)
self.field_font.setPointSize(font_size)
self.field_color = QColor.fromRgb(*cfg.get('field_color'))
for f_name in ConfigManager.getOptions('interface', 'Fields'):
s = ConfigManager.getVal('interface', 'Fields', f_name)
s = map(str.strip, s.split('||'))
img = QImage('resources/images/'+s[0])
img_pos = QPoint(*eval(s[1]))
info_rect = QRect(*eval(s[2]))
scale = float(s[3])
if (len(s) >= 5):
font = QFont(self.field_font)
font.setPointSize(int(s[4]))
else:
font = self.field_font
img_w, img_h = img.width(), img.height()
img_rect = QRect(
img_pos.x(), img_pos.y(),
int(img_w*scale), int(img_h*scale)
)
self.info[f_name] = ''
self.fields.add(Field(f_name, img, img_rect, info_rect, font))
self.radar = Radar.from_config('E-Radar', self)
self.missile = GuidedMissile.from_config('GuidedMissile', self)
开发者ID:giulianoxt,项目名称:pyasteroids,代码行数:43,代码来源:interface.py
示例19: __init__
def __init__(self):
"""Initializes internal data-structure, and makes sure that the folder
where we are going to store the configurationfiles actually exists."""
logger = logging.getLogger(__name__)
self.configlocation = Config.get("configfiles", "location")
self.configfiles = []
if(os.path.exists(self.configlocation) == False):
logger.warning("Location for the configfiles does not exist. Creating the folders.")
os.makedirs(self.configlocation, 0755)
开发者ID:SnowmanRM,项目名称:Snowman,代码行数:11,代码来源:files.py
示例20: __init__
def __init__(self, record):
self._name = record['name']
self._basename = record['basename']
# font records usually only have a remote or a local version
# as the version is eventually compared numerically
# they are initialized with zero-string
self._local_version = record.get('local_version', '0')
self._remote_version = record.get('remote_version', '0')
# existing font files in repo
self._otf_files = []
self._svg_files = [] # svg includes woff files
# actions to be performed
self._actions = {}
# determine files and paths
self.archive = os.path.join(Config.font_repo(), "{}.zip".format(self._basename))
self.font_dir = os.path.join(Config.font_repo(), self._basename)
self.otf_dir = os.path.join(self.font_dir, 'otf')
self.svg_dir = os.path.join(self.font_dir, 'svg')
开发者ID:fedelibre,项目名称:lily-fonts,代码行数:21,代码来源:font.py
注:本文中的util.config.Config类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论