本文整理汇总了Python中juliabox.jbox_util.JBoxCfg.get方法的典型用法代码示例。如果您正苦于以下问题:Python JBoxCfg.get方法的具体用法?Python JBoxCfg.get怎么用?Python JBoxCfg.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类juliabox.jbox_util.JBoxCfg
的用法示例。
在下文中一共展示了JBoxCfg.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def configure():
JBoxLoopbackVol.DISK_LIMIT = JBoxCfg.get('disk_limit')
JBoxLoopbackVol.FS_LOC = os.path.expanduser(JBoxCfg.get('mnt_location'))
JBoxLoopbackVol.MAX_DISKS = JBoxCfg.get('numdisksmax')
JBoxLoopbackVol.DISK_RESERVE_SECS = JBoxCfg.get('disk_reserve_secs', 180)
JBoxLoopbackVol.LOCK = threading.Lock()
JBoxLoopbackVol.refresh_disk_use_status()
示例2: chk_and_launch_docker
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def chk_and_launch_docker(self, user_id):
if self.redirect_to_logged_in_instance(user_id):
return
nhops = int(self.get_argument('h', 0))
numhopmax = JBoxCfg.get('numhopmax', 0)
max_hop = nhops > numhopmax
launched = self.try_launch_container(user_id, max_hop=max_hop)
if launched:
self.set_container_initialized(Compute.get_instance_local_ip(), user_id)
self.rendertpl("loading.tpl",
user_id=user_id,
cfg=JBoxCfg.nv,
js_includes=JBPluginHandler.PLUGIN_JAVASCRIPTS)
return
self.unset_affinity()
self.log_debug("at hop %d for user %s", nhops, user_id)
if max_hop:
if JBoxCfg.get('cloud_host.scale_down'):
msg = "JuliaBox is experiencing a sudden surge. Please try in a few minutes while we increase our capacity."
else:
msg = "JuliaBox servers are fully loaded. Please try after sometime."
self.log_error("Server maxed out. Can't launch container at hop %d for user %s", nhops, user_id)
self.rendertpl("index.tpl", cfg=JBoxCfg.nv, state=self.state(error=msg, success=''))
else:
redirect_instance = Compute.get_redirect_instance_id()
if redirect_instance is not None:
redirect_ip = Compute.get_instance_local_ip(redirect_instance)
self.set_redirect_instance_id(redirect_ip)
self.redirect('/?h=' + str(nhops + 1))
示例3: configure
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def configure():
CompEC2.SCALE_UP_AT_LOAD = JBoxCfg.get('cloud_host.scale_up_at_load', 80)
CompEC2.SCALE_UP_POLICY = JBoxCfg.get('cloud_host.scale_up_policy', None)
CompEC2.AUTOSCALE_GROUP = JBoxCfg.get('cloud_host.autoscale_group', None)
CompEC2.INSTALL_ID = JBoxCfg.get('cloud_host.install_id', 'JuliaBox')
CompEC2.REGION = JBoxCfg.get('cloud_host.region', 'us-east-1')
示例4: get
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def get(self):
sessname = self.get_session_id()
user_id = self.get_user_id()
if (sessname is None) or (user_id is None):
self.send_error()
return
user = JBoxUserV2(user_id)
is_admin = sessname in JBoxCfg.get("admin_sessnames", [])
manage_containers = is_admin or user.has_role(JBoxUserV2.ROLE_MANAGE_CONTAINERS)
show_report = is_admin or user.has_role(JBoxUserV2.ROLE_ACCESS_STATS)
cont = SessContainer.get_by_name(sessname)
if cont is None:
self.send_error()
return
if self.handle_if_logout(cont):
return
if self.handle_if_stats(is_admin or show_report):
return
if self.handle_if_show_cfg(is_admin):
return
if self.handle_if_instance_info(is_admin):
return
if self.handle_switch_julia_img(user):
return
if self.handle_if_open_port(sessname, user_id):
return
juliaboxver, _upgrade_available = self.get_upgrade_available(cont)
jimg_type = 0
if user.has_resource_profile(JBoxUserV2.RES_PROF_JULIA_PKG_PRECOMP):
jimg_type = JBoxUserV2.RES_PROF_JULIA_PKG_PRECOMP
expire = JBoxCfg.get('interactive.expire')
d = dict(
manage_containers=manage_containers,
show_report=show_report,
sessname=sessname,
user_id=user_id,
created=isodate.datetime_isoformat(cont.time_created()),
started=isodate.datetime_isoformat(cont.time_started()),
allowed_till=isodate.datetime_isoformat((cont.time_started() + timedelta(seconds=expire))),
mem=cont.get_memory_allocated(),
cpu=cont.get_cpu_allocated(),
disk=cont.get_disk_allocated(),
expire=expire,
juliaboxver=juliaboxver,
jimg_type=jimg_type
)
self.rendertpl("ipnbadmin.tpl", d=d)
示例5: configure
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def configure():
num_disks_max = JBoxCfg.get('numdisksmax')
JBoxEBSVol.DISK_LIMIT = 10
JBoxEBSVol.MAX_DISKS = num_disks_max
JBoxEBSVol.DISK_TEMPLATE_SNAPSHOT = JBoxCfg.get('cloud_host.ebs_template')
JBoxEBSVol.DEVICES = JBoxEBSVol._guess_configured_devices('xvd', num_disks_max)
JBoxEBSVol.log_debug("Assuming %d EBS volumes configured in range xvdba..xvdcz", len(JBoxEBSVol.DEVICES))
JBoxEBSVol.LOCK = threading.Lock()
JBoxEBSVol.refresh_disk_use_status()
示例6: configure
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def configure():
BaseContainer.DCKR = JBoxCfg.dckr
SessContainer.DCKR_IMAGE = JBoxCfg.get('interactive.docker_image')
SessContainer.MEM_LIMIT = JBoxCfg.get('interactive.mem_limit')
SessContainer.ULIMITS = []
limits = JBoxCfg.get('interactive.ulimits')
for (n, v) in limits.iteritems():
SessContainer.ULIMITS.append(Ulimit(name=n, soft=v, hard=v))
SessContainer.CPU_LIMIT = JBoxCfg.get('interactive.cpu_limit')
SessContainer.MAX_CONTAINERS = JBoxCfg.get('interactive.numlocalmax')
示例7: post
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def post(self):
self.log_debug("User management handler got POST request")
sessname = self.get_session_id()
user_id = self.get_user_id()
if (sessname is None) or (user_id is None):
self.send_error()
return
user = JBoxUserV2(user_id)
is_admin = sessname in JBoxCfg.get("admin_sessnames", []) or user.has_role(JBoxUserV2.ROLE_SUPER)
self.log_info("User manager. user_id[%s] is_admin[%r]", user_id, is_admin)
if not is_admin:
self.send_error(status_code=403)
return
if self.handle_get_user(user_id, is_admin):
return
if self.handle_update_user(user_id, is_admin):
return
self.log_error("no handlers found")
# only AJAX requests responded to
self.send_error()
示例8: configure
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def configure():
mail_data = JBoxCfg.get('user_activation')
JBoxd.SENDER_PASSWORD = mail_data['sender_password']
JBoxd.SMTP_URL = mail_data['smtp_url']
JBoxd.SMTP_PORT_NO = mail_data['smtp_port_no']
JBoxd.MAX_24HRS = mail_data['max_24hrs']
JBoxd.MAX_RATE_PER_SEC = mail_data['max_rate_per_sec']
示例9: post
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def post(self):
self.log_debug("API management handler got POST request")
sessname = self.get_session_id()
user_id = self.get_user_id()
if (sessname is None) or (user_id is None):
self.send_error()
return
user = JBoxUserV2(user_id)
is_admin = sessname in JBoxCfg.get("admin_sessnames", []) or user.has_role(JBoxUserV2.ROLE_SUPER)
self.log_info("API manager. user_id[%s] is_admin[%r]", user_id, is_admin)
if user.has_resource_profile(JBoxUserV2.RES_PROF_API_PUBLISHER):
if self.handle_get_api_info(user_id, is_admin):
return
if self.handle_create_api(user_id, is_admin):
return
if self.handle_delete_api(user_id, is_admin):
return
else:
if self.handle_enable_api(user_id, is_admin):
return
self.log_error("no handlers found")
# only AJAX requests responded to
self.send_error()
示例10: get_user_id
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def get_user_id(self, validate=True):
if (self._user_id is None) or (validate and (not self._valid_user)):
try:
jbox_cookie = self.get_cookie(JBoxCookies.COOKIE_AUTH)
if jbox_cookie is None:
return None
jbox_cookie = json.loads(base64.b64decode(jbox_cookie))
if validate:
sign = signstr(jbox_cookie['u'] + jbox_cookie['t'], JBoxCfg.get('sesskey'))
if sign != jbox_cookie['x']:
self.log_info("signature mismatch for " + jbox_cookie['u'])
return None
d = isodate.parse_datetime(jbox_cookie['t'])
age = (datetime.datetime.now(pytz.utc) - d).total_seconds()
if age > JBoxCookies.AUTH_VALID_SECS:
self.log_info("cookie older than allowed days: " + jbox_cookie['t'])
return None
self._valid_user = True
self._user_id = jbox_cookie['u']
except:
self.log_error("exception while reading auth cookie")
traceback.print_exc()
return None
return self._user_id
示例11: configure
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def configure():
pkg_location = os.path.expanduser(JBoxCfg.get('pkg_location'))
make_sure_path_exists(pkg_location)
JBoxDefaultPackagesVol.FS_LOC = pkg_location
JBoxDefaultPackagesVol.LOCK = threading.Lock()
JBoxDefaultPackagesVol.refresh_disk_use_status()
示例12: post
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def post(self):
self.log_debug("Homework handler got POST request")
sessname = self.get_session_id()
user_id = self.get_user_id()
if (sessname is None) or (user_id is None):
self.log_info("Homework handler got invalid sessname[%r] or user_id[%r]", sessname, user_id)
self.send_error()
return
user = JBoxUserV2(user_id)
is_admin = sessname in JBoxCfg.get("admin_sessnames", []) or user.has_role(JBoxUserV2.ROLE_SUPER)
course_owner = is_admin or user.has_role(JBoxUserV2.ROLE_OFFER_COURSES)
cont = SessContainer.get_by_name(sessname)
self.log_info("user_id[%r], is_admin[%r], course_owner[%r]", user_id, is_admin, course_owner)
if cont is None:
self.log_info("user_id[%r] container not found", user_id)
self.send_error()
return
courses_offered = user.get_courses_offered()
if self.handle_if_check(user_id):
return
if self.handle_create_course(user_id):
return
if self.handle_get_metadata(is_admin, courses_offered):
return
if self.handle_if_report(user_id, is_admin, courses_offered):
return
self.log_error("no handlers found")
# only AJAX requests responded to
self.send_error()
示例13: get
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def get(self):
self.log_debug("APIInfo handler got GET request")
key = self.get_argument("key", None)
sign = self.get_argument("sign", None)
if key is None or sign is None:
self.send_error()
return
sign2 = signstr(key, JBoxCfg.get('sesskey'))
if sign != sign2:
self.log_info("signature mismatch. key:%r sign:%r expected:%r", key, sign, sign2)
self.send_error()
return
api_status = APIContainer.get_cluster_api_status()
self.log_info("cluster api status: %r", api_status)
# filter out instances that should not accept more load
filtered_api_status = {k: v for (k, v) in api_status.iteritems() if v['accept']}
preferred_instances = filtered_api_status.keys()
# flip the dict
per_api_instances = dict()
for (inst, status) in filtered_api_status.iteritems():
api_names = status['api_status'].keys()
for api_name in api_names:
v = per_api_instances.get(api_name, [])
v.append(inst)
per_api_instances[" preferred "] = preferred_instances
self.log_info("per api instances: %r", per_api_instances)
self.write(per_api_instances)
return
示例14: configure
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def configure():
polsar_location = os.path.expanduser(JBoxCfg.get("polsar_location"))
make_sure_path_exists(polsar_location)
JBoxPolsarDiskVol.FS_LOC = polsar_location
JBoxPolsarDiskVol.refresh_disk_use_status()
示例15: configure
# 需要导入模块: from juliabox.jbox_util import JBoxCfg [as 别名]
# 或者: from juliabox.jbox_util.JBoxCfg import get [as 别名]
def configure():
dbconf = JBoxCfg.get("db")
JBoxCloudSQL.log_debug("db_conf: %r", dbconf)
if dbconf is not None:
JBoxCloudSQL.USER = dbconf['user']
JBoxCloudSQL.PASSWD = dbconf['passwd']
JBoxCloudSQL.UNIX_SOCKET = dbconf['unix_socket']
JBoxCloudSQL.DB = dbconf['db']