本文整理匯總了Python中rose.host_select.HostSelector.split方法的典型用法代碼示例。如果您正苦於以下問題:Python HostSelector.split方法的具體用法?Python HostSelector.split怎麽用?Python HostSelector.split使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rose.host_select.HostSelector
的用法示例。
在下文中一共展示了HostSelector.split方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: RoseBushService
# 需要導入模塊: from rose.host_select import HostSelector [as 別名]
# 或者: from rose.host_select.HostSelector import split [as 別名]
class RoseBushService(object):
"""Serves the index page."""
NS = "rose"
UTIL = "bush"
TITLE = "Rose Bush"
CYCLES_PER_PAGE = 100
JOBS_PER_PAGE = 15
JOBS_PER_PAGE_MAX = 300
SUITES_PER_PAGE = 100
VIEW_SIZE_MAX = 10 * 1024 * 1024 # 10MB
def __init__(self, *args, **kwargs):
self.exposed = True
self.suite_engine_proc = SuiteEngineProcessor.get_processor()
rose_conf = ResourceLocator.default().get_conf()
self.logo = rose_conf.get_value(["rose-bush", "logo"])
self.title = rose_conf.get_value(["rose-bush", "title"], self.TITLE)
self.host_name = rose_conf.get_value(["rose-bush", "host"])
if self.host_name is None:
self.host_name = HostSelector().get_local_host()
if self.host_name and "." in self.host_name:
self.host_name = self.host_name.split(".", 1)[0]
self.rose_version = ResourceLocator.default().get_version()
template_env = jinja2.Environment(loader=jinja2.FileSystemLoader(
ResourceLocator.default().get_util_home(
"lib", "html", "template", "rose-bush")))
def urlise(text):
pattern = '((https?):\/\/[^\s\(\)&\[\]\{\}]+)'
replacement = '<a href="\g<1>">\g<1></a>'
text = re.sub(pattern, replacement, text)
return text
template_env.filters['urlise'] = urlise
self.template_env = template_env
@cherrypy.expose
def index(self, form=None):
"""Display a page to input user ID and suite ID."""
# TODO: some way to allow autocomplete of user field?
data = {
"logo": self.logo,
"title": self.title,
"host": self.host_name,
"rose_version": self.rose_version,
"script": cherrypy.request.script_name,
}
if form == "json":
return simplejson.dumps(data)
try:
return self.template_env.get_template("index.html").render(**data)
except Exception as exc:
traceback.print_exc(exc)
@cherrypy.expose
def broadcast_states(self, user, suite, form=None):
"""List current broadcasts of a running or completed suite."""
user_suite_dir = self._get_user_suite_dir(user, suite)
data = {
"logo": self.logo,
"title": self.title,
"host": self.host_name,
"user": user,
"suite": suite,
"rose_version": self.rose_version,
"script": cherrypy.request.script_name,
"method": "broadcast_states",
"states": {},
"time": strftime("%Y-%m-%dT%H:%M:%S+0000", gmtime()),
}
data["states"].update(
self.suite_engine_proc.get_suite_state_summary(user, suite))
data.update(self._get_suite_logs_info(user, suite))
data["broadcast_states"] = (
self.suite_engine_proc.get_suite_broadcast_states(user, suite))
if form == "json":
return simplejson.dumps(data)
try:
template = self.template_env.get_template("broadcast-states.html")
return template.render(**data)
except Exception as exc:
traceback.print_exc(exc)
return simplejson.dumps(data)
@cherrypy.expose
def broadcast_events(self, user, suite, form=None):
"""List broadcasts history of a running or completed suite."""
user_suite_dir = self._get_user_suite_dir(user, suite)
data = {
"logo": self.logo,
"title": self.title,
"host": self.host_name,
"user": user,
"suite": suite,
"rose_version": self.rose_version,
"script": cherrypy.request.script_name,
"method": "broadcast_events",
"states": {},
#.........這裏部分代碼省略.........