本文整理汇总了Python中zato.admin.web.from_utc_to_user函数的典型用法代码示例。如果您正苦于以下问题:Python from_utc_to_user函数的具体用法?Python from_utc_to_user怎么用?Python from_utc_to_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了from_utc_to_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: details
def details(req, source_type, cluster_id, msg_id, topic_name):
item = None
pretty_print = asbool(req.GET.get('pretty_print'))
input_dict = {
'cluster_id': cluster_id,
'msg_id': msg_id,
}
response = req.zato.client.invoke('zato.pubsub.message.get', input_dict)
if response.has_data:
item = Message()
for name in('topic', 'producer', 'priority', 'mime_type', 'expiration', 'creation_time_utc', 'expire_at_utc', 'payload'):
setattr(item, name, getattr(response.data, name, None))
item.creation_time = from_utc_to_user(item.creation_time_utc+'+00:00', req.zato.user_profile)
item.expire_at = from_utc_to_user(item.expire_at_utc+'+00:00', req.zato.user_profile)
return_data = {
'cluster_id': req.zato.cluster_id,
'item': item,
'pretty_print': not pretty_print,
'msg_id': msg_id,
'topic_name': topic_name,
'source_type': source_type,
'sub_key': req.GET.get('sub_key')
}
return TemplateResponse(req, 'zato/pubsub/message/details.html', return_data)
开发者ID:remcoboerma,项目名称:zato,代码行数:30,代码来源:message.py
示例2: slow_response
def slow_response(req, service_name):
items = []
input_dict = {
'name': service_name,
}
zato_message, soap_response = invoke_admin_service(req.zato.cluster,
'zato:service.slow-response.get-list', input_dict)
if zato_path('response.item_list.item').get_from(zato_message) is not None:
for _item in zato_message.response.item_list.item:
item = SlowResponse()
item.cid = _item.cid.text
item.req_ts = from_utc_to_user(_item.req_ts.text+'+00:00', req.zato.user_profile)
item.resp_ts = from_utc_to_user(_item.resp_ts.text+'+00:00', req.zato.user_profile)
item.proc_time = _item.proc_time.text
item.service_name = service_name
items.append(item)
return_data = {
'cluster_id': req.zato.cluster_id,
'service': _get_service(req, service_name),
'items': items,
}
return TemplateResponse(req, 'zato/service/slow-response.html', return_data)
开发者ID:dsuch,项目名称:zato,代码行数:28,代码来源:service.py
示例3: _interval_based_job_def
def _interval_based_job_def(user_profile, start_date, repeats, weeks, days, hours, minutes, seconds):
buf = StringIO()
if start_date:
buf.write('Start on {0} at {1}.'.format(
from_utc_to_user(start_date, user_profile, 'date'),
from_utc_to_user(start_date, user_profile, 'time')))
if not repeats:
buf.write(' Repeat indefinitely.')
else:
if repeats == 1:
buf.write(' Execute once.')
elif repeats == 2:
buf.write(' Repeat twice.')
# .. my hand is itching to add 'repeats thrice.' here ;-)
elif repeats > 2:
buf.write(' Repeat ')
buf.write(str(repeats))
buf.write(' times.')
interval = []
buf.write(' Interval: ')
for name, value in (('week',weeks), ('day',days),
('hour',hours), ('minute',minutes),
('second',seconds)):
if value:
value = int(value)
interval.append('{0} {1}{2}'.format(value, name, 's' if value > 1 else ''))
buf.write(', '.join(interval))
buf.write('.')
return buf.getvalue()
开发者ID:Adniel,项目名称:zato,代码行数:35,代码来源:scheduler.py
示例4: audit_log
def audit_log(req, **kwargs):
out = kwargs
out['req'] = req
out.update(get_js_dt_format(req.zato.user_profile))
for key in('batch_size', 'current_batch', 'start', 'stop', 'state', 'query'):
value = req.GET.get(key)
if value:
out[key] = value
out['form'] = AuditLogEntryList(initial=out)
request = {
'conn_id': out['conn_id'],
'start': out.get('start', ''),
'stop': out.get('stop'),
'current_batch': out.get('current_batch', BATCH_DEFAULTS.PAGE_NO),
'batch_size': out.get('batch_size', BATCH_DEFAULTS.SIZE),
'query': out.get('query', ''),
}
out['items'] = []
response = req.zato.client.invoke('zato.http-soap.get-audit-item-list', request)
if response.ok:
for item in response.data:
item.req_time = from_utc_to_user(item.req_time_utc+'+00:00', req.zato.user_profile)
item.resp_time = from_utc_to_user(item.resp_time_utc+'+00:00', req.zato.user_profile) if item.resp_time_utc else '(None)'
out['items'].append(item)
out.update(**req.zato.client.invoke('zato.http-soap.get-audit-batch-info', request).data)
return TemplateResponse(req, 'zato/http_soap/audit/log.html', out)
开发者ID:chunjieroad,项目名称:zato,代码行数:34,代码来源:http_soap.py
示例5: shift
def shift(utc_base_date, user_start, user_profile, shift_type, duration, format):
""" Shifts the base date by the amount specified and returns resulting start
and stop dates in UTC and user timezone.
"""
if shift_type not in start_delta_kwargs:
raise ValueError('Unknown shift_type:[{}]'.format(shift_type))
_start_delta_kwargs = start_delta_kwargs[shift_type]
# Special-case month duration because UTC '2012-09-30 22:00:00+00:00' (which is 2012-10-01 CEST)
# minus one month happens to be '2012-08-30 22:00:00+00:00' instead of '2012-09-31 22:00:00+00:00'
# so it's 2012-08-30 CEST instead of 2012-09-01. In other words, we would've jumped from Oct 2012 to Aug 2012 directly.
if duration != 'month':
utc_start = utc_base_date + relativedelta(**_start_delta_kwargs)
else:
user_start = datetime.strptime(user_start, user_profile.month_year_format_strptime)
current_month_start = datetime(user_start.year, user_start.month, 1)
prev_month_start = current_month_start + relativedelta(**_start_delta_kwargs)
utc_start = from_local_to_utc(prev_month_start, user_profile.timezone)
_stop_delta_kwargs = stop_delta_kwargs[duration]
utc_stop = utc_start + relativedelta(**_stop_delta_kwargs)
user_start = from_utc_to_user(utc_start, user_profile, format)
user_stop = from_utc_to_user(utc_stop, user_profile, format)
return DateInfo(utc_start.isoformat(), utc_stop.isoformat(), user_start, user_stop)
开发者ID:grenzi,项目名称:ctakes_exploration,代码行数:28,代码来源:stats.py
示例6: _cron_style_job_def
def _cron_style_job_def(user_profile, start_date, cron_definition):
start_date = _get_start_date(start_date)
buf = StringIO()
buf.write('Start on {0} at {1}.'.format(
from_utc_to_user(start_date, user_profile, 'date'),
from_utc_to_user(start_date, user_profile, 'time')))
buf.write('<br/>{0}'.format(cron_definition))
return buf.getvalue()
开发者ID:remcoboerma,项目名称:zato,代码行数:10,代码来源:scheduler.py
示例7: maintenance_delete
def maintenance_delete(req):
start = from_user_to_utc(req.POST['start'], req.zato.user_profile)
stop = from_user_to_utc(req.POST['stop'], req.zato.user_profile)
req.zato.client.invoke('zato.stats.delete', {'start':start, 'stop':stop})
msg = 'Submitted a request to delete statistics from [{}] to [{}]. Check the server logs for details.'.format(
from_utc_to_user(start.isoformat() + '+00:00', req.zato.user_profile),
from_utc_to_user(stop.isoformat() + '+00:00', req.zato.user_profile))
messages.add_message(req, messages.INFO, msg, extra_tags='success')
return redirect('{}?cluster={}'.format(reverse('stats-maintenance'), req.zato.cluster_id))
开发者ID:grenzi,项目名称:ctakes_exploration,代码行数:13,代码来源:stats.py
示例8: slow_response_details
def slow_response_details(req, cid, service_name):
item = None
service = _get_service(req, service_name)
pretty_print = asbool(req.GET.get('pretty_print'))
input_dict = {
'cid': cid,
'name': service_name,
}
response = req.zato.client.invoke('zato.service.slow-response.get', input_dict)
if response.has_data:
cid = response.data.cid
if cid != ZATO_NONE:
item = SlowResponse()
item.cid = response.data.cid
item.req_ts = from_utc_to_user(response.data.req_ts+'+00:00', req.zato.user_profile)
item.resp_ts = from_utc_to_user(response.data.resp_ts+'+00:00', req.zato.user_profile)
item.proc_time = response.data.proc_time
item.service_name = service_name
item.threshold = service.slow_threshold
for name in('req', 'resp'):
value = getattr(response.data, name)
if value:
#value = value.decode('base64')
if isinstance(value, dict):
value = dumps(value)
data_format = 'json'
else:
data_format = known_data_format(value)
if data_format:
if pretty_print:
value = get_pretty_print(value, data_format)
attr_name = name + '_html'
setattr(item, attr_name, highlight(value,
data_format_lexer[data_format](), HtmlFormatter(linenos='table')))
return_data = {
'cluster_id': req.zato.cluster_id,
'service': service,
'item': item,
'pretty_print': not pretty_print,
}
return TemplateResponse(req, 'zato/service/slow-response-details.html', return_data)
开发者ID:catroot,项目名称:zato,代码行数:48,代码来源:service.py
示例9: slow_response_details
def slow_response_details(req, cid, service_name):
item = None
service = _get_service(req, service_name)
pretty_print = asbool(req.GET.get("pretty_print"))
input_dict = {"cid": cid, "name": service_name}
response = req.zato.client.invoke("zato.service.slow-response.get", input_dict)
if response.has_data:
cid = response.data.cid
if cid != ZATO_NONE:
item = SlowResponse()
item.cid = response.data.cid
item.req_ts = from_utc_to_user(response.data.req_ts + "+00:00", req.zato.user_profile)
item.resp_ts = from_utc_to_user(response.data.resp_ts + "+00:00", req.zato.user_profile)
item.proc_time = response.data.proc_time
item.service_name = service_name
item.threshold = service.slow_threshold
for name in ("req", "resp"):
value = getattr(response.data, name)
if value:
# value = value.decode('base64')
if isinstance(value, dict):
value = dumps(value)
data_format = "json"
else:
data_format = known_data_format(value)
if data_format:
if pretty_print:
value = get_pretty_print(value, data_format)
attr_name = name + "_html"
setattr(
item,
attr_name,
highlight(value, data_format_lexer[data_format](), HtmlFormatter(linenos="table")),
)
return_data = {
"cluster_id": req.zato.cluster_id,
"service": service,
"item": item,
"pretty_print": not pretty_print,
}
return TemplateResponse(req, "zato/service/slow-response-details.html", return_data)
开发者ID:barowski,项目名称:zato,代码行数:48,代码来源:service.py
示例10: _common_edit_message
def _common_edit_message(client, success_msg, id, name, host, up_status, up_mod_date, cluster_id, user_profile, fetch_lb_data=True):
""" Returns a common JSON message for both the actual 'edit' and 'add/remove to/from LB' actions.
"""
return_data = {
'id': id,
'name': name,
'host': host if host else '(unknown)',
'up_status': up_status if up_status else '(unknown)',
'up_mod_date': from_utc_to_user(up_mod_date+'+00:00', user_profile) if up_mod_date else '(unknown)',
'cluster_id': cluster_id if cluster_id else '',
'lb_state': '(unknown)',
'lb_address': '(unknown)',
'in_lb': '(unknown)',
'message': success_msg.format(name)
}
if fetch_lb_data:
lb_server_data = _get_server_data(client, name)
return_data.update({
'lb_state': lb_server_data.state,
'lb_address': lb_server_data.lb_address,
'in_lb': lb_server_data.in_lb,
})
return HttpResponse(dumps(return_data), mimetype='application/javascript')
开发者ID:barowski,项目名称:zato,代码行数:28,代码来源:cluster.py
示例11: post_process_return_data
def post_process_return_data(self, return_data):
is_active = False
for name in('is_active', 'edit-is_active'):
if name in self.req.POST:
is_active = True
break
return_data['is_active'] = is_active
return_data['topic_name'] = self.req.POST['topic_name']
return_data['message'] = 'Successfully {} consumer `{}`'.format(self.verb, return_data['name'])
return_data['last_seen'] = None
return_data['current_depth'] = 0
client_id = self.req.POST.get('id')
if client_id:
response = self.req.zato.client.invoke('zato.pubsub.consumers.get-info', {'id': client_id})
if response.ok:
return_data['current_depth'] = response.data.current_depth
return_data['in_flight_depth'] = response.data.in_flight_depth
return_data['sub_key'] = response.data.sub_key
if response.data.last_seen:
return_data['last_seen'] = from_utc_to_user(response.data.last_seen + '+00:00', self.req.zato.user_profile)
return return_data
开发者ID:Aayush-Kasurde,项目名称:zato,代码行数:26,代码来源:consumers.py
示例12: _common_edit_message
def _common_edit_message(
client, success_msg, id, name, host, up_status, up_mod_date, cluster_id, user_profile, fetch_lb_data=True
):
""" Returns a common JSON message for both the actual 'edit' and 'add/remove to/from LB' actions.
"""
return_data = {
"id": id,
"name": name,
"host": host if host else "(unknown)",
"up_status": up_status if up_status else "(unknown)",
"up_mod_date": from_utc_to_user(up_mod_date + "+00:00", user_profile) if up_mod_date else "(unknown)",
"cluster_id": cluster_id if cluster_id else "",
"lb_state": "(unknown)",
"lb_address": "(unknown)",
"in_lb": "(unknown)",
"message": success_msg.format(name),
}
if fetch_lb_data:
lb_server_data = _get_server_data(client, name)
return_data.update(
{"lb_state": lb_server_data.state, "lb_address": lb_server_data.lb_address, "in_lb": lb_server_data.in_lb}
)
return HttpResponse(dumps(return_data), mimetype="application/javascript")
开发者ID:dsuch,项目名称:zato,代码行数:26,代码来源:cluster.py
示例13: __call__
def __call__(self, req, initial_input_dict={}, initial_return_data={}, *args, **kwargs):
edit_name = req.POST.get('edit-name')
name = req.POST.get('name', edit_name)
initial_return_data = {
'current_depth': 0,
'consumers_count': 0,
'producers_count': 0,
'last_pub_time': None,
'cluster_id': req.zato.cluster_id,
'name': name,
}
if edit_name:
response = req.zato.client.invoke('zato.pubsub.topics.get-info', {
'cluster_id': req.zato.cluster_id,
'name': edit_name
})
if response.ok:
initial_return_data.update(response.data)
initial_return_data['last_pub_time'] = from_utc_to_user(
initial_return_data['last_pub_time'] + '+00:00', req.zato.user_profile)
return super(_CreateEdit, self).__call__(
req, initial_input_dict={}, initial_return_data=initial_return_data, *args, **kwargs)
开发者ID:azazel75,项目名称:zato,代码行数:27,代码来源:topics.py
示例14: test_shift_prev_week_by_day
def test_shift_prev_week_by_day(self):
now = parse('2012-03-21T00:39:19+00:00')
info = shift(now, from_utc_to_user(now, self.user_profile), self.user_profile, 'today_prev_day_week', 'day', 'date')
eq_(info.utc_start, '2012-03-14T00:39:19+00:00')
eq_(info.utc_stop, '2012-03-15T00:39:19+00:00')
eq_(info.user_start, '14-03-2012')
eq_(info.user_stop, '15-03-2012')
eq_(info.step, None)
开发者ID:remcoboerma,项目名称:zato,代码行数:8,代码来源:test_stats.py
示例15: test_shift_prev_month_by_month
def test_shift_prev_month_by_month(self):
now = parse('2012-10-01T00:00:00+00:00')
info = shift(now, from_utc_to_user(now, self.user_profile, 'month_year'), self.user_profile, 'this_month_prev_month', 'month', 'month_year')
eq_(info.utc_start, '2012-08-31T22:00:00+00:00')
eq_(info.utc_stop, '2012-09-30T22:00:00+00:00')
eq_(info.user_start, '09-2012')
eq_(info.user_stop, '10-2012')
eq_(info.step, None)
开发者ID:remcoboerma,项目名称:zato,代码行数:8,代码来源:test_stats.py
示例16: test_shift_prev_year_by_year
def test_shift_prev_year_by_year(self):
now = parse('2012-01-01T00:00:00+00:00')
info = shift(now, from_utc_to_user(now, self.user_profile), self.user_profile, 'this_year_prev', 'year', 'year')
eq_(info.utc_start, '2011-01-01T00:00:00+00:00')
eq_(info.utc_stop, '2012-01-01T00:00:00+00:00')
eq_(info.user_start, '2011')
eq_(info.user_stop, '2012')
eq_(info.step, None)
开发者ID:remcoboerma,项目名称:zato,代码行数:8,代码来源:test_stats.py
示例17: test_shift_prev_week_by_week
def test_shift_prev_week_by_week(self):
now = parse('2012-10-22T00:00:00+00:00')
info = shift(now, from_utc_to_user(now, self.user_profile), self.user_profile, 'today_prev_day_week', 'week', 'date')
eq_(info.utc_start, '2012-10-15T00:00:00+00:00')
eq_(info.utc_stop, '2012-10-22T00:00:00+00:00')
eq_(info.user_start, '15-10-2012')
eq_(info.user_stop, '22-10-2012')
eq_(info.step, None)
开发者ID:remcoboerma,项目名称:zato,代码行数:8,代码来源:test_stats.py
示例18: slow_response_details
def slow_response_details(req, cid, service_name):
item = None
service = _get_service(req, service_name)
pretty_print = asbool(req.GET.get('pretty_print'))
input_dict = {
'cid': cid,
'name': service_name,
}
zato_message, soap_response = invoke_admin_service(req.zato.cluster,
'zato:service.slow-response.get', input_dict)
if zato_path('response.item').get_from(zato_message) is not None:
_item = zato_message.response.item
cid = _item.cid.text
if cid != ZATO_NONE:
item = SlowResponse()
item.cid = _item.cid.text
item.req_ts = from_utc_to_user(_item.req_ts.text+'+00:00', req.zato.user_profile)
item.resp_ts = from_utc_to_user(_item.resp_ts.text+'+00:00', req.zato.user_profile)
item.proc_time = _item.proc_time.text
item.service_name = service_name
item.threshold = service.slow_threshold
for name in('req', 'resp'):
value = getattr(_item, name)
if value:
value = value.text.decode('base64')
data_format = known_data_format(value)
if data_format:
if pretty_print:
value = get_pretty_print(value, data_format)
attr_name = name + '_html'
setattr(item, attr_name, highlight(value,
data_format_lexer[data_format](), HtmlFormatter(linenos='table')))
return_data = {
'cluster_id': req.zato.cluster_id,
'service': service,
'item': item,
'pretty_print': not pretty_print,
}
return TemplateResponse(req, 'zato/service/slow-response-details.html', return_data)
开发者ID:dsuch,项目名称:zato,代码行数:45,代码来源:service.py
示例19: slow_response
def slow_response(req, service_name):
items = []
input_dict = {"name": service_name}
for _item in req.zato.client.invoke("zato.service.slow-response.get-list", input_dict):
item = SlowResponse()
item.cid = _item.cid
item.req_ts = from_utc_to_user(_item.req_ts + "+00:00", req.zato.user_profile)
item.resp_ts = from_utc_to_user(_item.resp_ts + "+00:00", req.zato.user_profile)
item.proc_time = _item.proc_time
item.service_name = service_name
items.append(item)
return_data = {"cluster_id": req.zato.cluster_id, "service": _get_service(req, service_name), "items": items}
return TemplateResponse(req, "zato/service/slow-response.html", return_data)
开发者ID:barowski,项目名称:zato,代码行数:18,代码来源:service.py
示例20: test_shift_prev_week
def test_shift_prev_week(self):
with patch('zato.common.util._utcnow', self._utcnow):
now = utcnow()
info = shift(now, from_utc_to_user(now, self.user_profile), self.user_profile, 'today_prev_day_week', 'hour', 'date_time')
eq_(info.utc_start, '2012-02-23T00:47:24.054903+00:00')
eq_(info.utc_stop, '2012-02-23T01:47:24.054903+00:00')
eq_(info.user_start, '23-02-2012 01:47:24')
eq_(info.user_stop, '23-02-2012 02:47:24')
eq_(info.step, None)
开发者ID:remcoboerma,项目名称:zato,代码行数:9,代码来源:test_stats.py
注:本文中的zato.admin.web.from_utc_to_user函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论