本文整理汇总了Python中util.config.Config.get方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get方法的具体用法?Python Config.get怎么用?Python Config.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.config.Config
的用法示例。
在下文中一共展示了Config.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: access_token_for_id
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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))
示例2: initialize
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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])
示例3: get
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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
示例4: __init__
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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
示例5: from_template
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
def from_template(cls, section, level, pos=None, vel=None):
cfg = Config("effects", section)
num_particles = cfg.get("num_particles")
pos_irange = cfg.get("position_irange")
pos = pos if (pos is not None) else cfg.get("position")
vel_irange = cfg.get("velocity_irange")
vel = vel if (vel is not None) else cfg.get("velocity")
duration = cfg.get("duration")
duration_irange = cfg.get("duration_irange")
color_seq = cfg.get("color_sequence")
quad_sz = cfg.get("quad_size")
img_path = cfg.get("image_path")
return cls(
level,
num_particles,
pos,
pos_irange,
vel,
vel_irange,
duration,
duration_irange,
color_seq,
quad_sz,
"resources/images/" + img_path,
)
示例6: __init__
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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()
示例7: __init__
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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()
示例8: __init__
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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)
示例9: __init__
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
def __init__(self, model, ship, level):
self.model = model
self.ship = ship
self.level = level
cfg = Config('game','SimpleMissile')
self.pos = Vector3d(*cfg.get('pos'))
self.initial_velocity = cfg.get('initial_velocity')
self.attraction_vel = cfg.get('attraction_velocity')
self.damage = cfg.get('damage')
self.num_rockets = cfg.get('num_rockets')
示例10: __init__
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
def __init__(self, model, shape, element, level):
Object.__init__(self, model, shape, element)
cfg = Config('physics','Ship')
self.move_force_sz = cfg.get('move_force')
self.spin_velocity = cfg.get('spin_velocity')
self.strafe_force = cfg.get('strafe_force')
self.shape.forces_res.append(cfg.get('vacuum_resistance'))
self.breake_rate = cfg.get('breake_rate')
self.mouse_sensivity = Config('game','Mouse').get('sensivity')
self.level = level
self.rotation = Quaternion.from_axis_rotations(0.,0.,0.)
self.ship_dir = None
self.up_dir = None
self.spinning = {
'up' : False,
'down' : False,
'left' : False,
'right' : False
}
self.vectors = {
'up' : (Vector3d.x_axis(), 1.),
'down' : (Vector3d.x_axis(), -1.),
'left' : (Vector3d.y_axis(), 1.),
'right' : (Vector3d.y_axis(), -1.)
}
self.strafe = {
'forward': False,
'left' : False,
'right' : False,
'breake' : False
}
self.strafe_vectors = {
'forward':Vector3d(0.,0.,-0.7),
'left' : Vector3d(-0.9,0.,0.),
'right' : Vector3d(0.9,0.,0.),
'breake' : Vector3d(0.,0.,1.)
}
self.angles = [0.,0.]
self.mouse_target = [0.,0.]
self.collision_set = set()
self.keep_colliding = set()
示例11: resizeGL
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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)
示例12: __init__
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
def __init__(self, model, ship, level):
self.model = model
self.ship = ship
self.level = level
cfg = Config('game','SimpleGun')
self.duration = cfg.get('duration')
self.pos = Vector3d(*cfg.get('pos'))
self.shoot_period = 1. / cfg.get('shoot_rate')
self.shoot_velocity_sz = cfg.get('shoot_velocity')
self.damage = cfg.get('damage')
self.shooting = False
self.since_last_shoot = 0.0
示例13: __init__
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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))
示例14: from_config
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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)
示例15: index
# 需要导入模块: from util.config import Config [as 别名]
# 或者: from util.config.Config import get [as 别名]
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)