本文整理汇总了Python中server.hierarchy.manager.get_current_customer_name函数的典型用法代码示例。如果您正苦于以下问题:Python get_current_customer_name函数的具体用法?Python get_current_customer_name怎么用?Python get_current_customer_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_customer_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
def delete(self):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
try:
tag_id = self.arguments.get('id', None)
if tag_id:
tag = TagsManager(username, customer_name, uri, method)
results = tag.remove_tag(tag_id)
else:
results = (
GenericResults(
username, uri, method
).incorrect_arguments()
)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke('agentids and tag_id', 'delete agents_in_tagid', e)
)
logger.exception(e)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例2: get
def get(self, agent_id):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
try:
count = int(self.get_argument('count', 20))
offset = int(self.get_argument('offset', 0))
sort = self.get_argument('sort', 'desc')
sort_by = self.get_argument('sort_by', OperationKey.CreatedTime)
operations = (
OperationRetriever(
username, customer_name,
uri, method, count, offset,
sort, sort_by
)
)
results = operations.get_all_operations_by_agentid(agent_id)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke('operation', 'search by oper type', e)
)
logger.exception(results)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例3: delete
def delete(self, notification_id):
username = self.get_current_user().encode('utf-8')
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
try:
notification = (
Notifier(
username, customer_name,
uri, method
)
)
results = (
notification.delete_alerting_rule(notification_id)
)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke('delete notification', 'notifications', e)
)
logger.exception(e)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例4: get
def get(self, tag_id):
username = self.get_current_user().encode('utf-8')
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
try:
status = self.get_argument('status', 'available')
start_date = self.get_argument('start_date', None)
end_date = self.get_argument('end_date', None)
if start_date:
start_date = int(start_date)
if end_date:
end_date = int(end_date)
results = (
get_os_apps_history_for_tag(
username, customer_name,
uri, method, tag_id, status,
start_date, end_date
)
)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke('customer os stats', 'os stats', e)
)
logger.exception(results)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例5: get
def get(self):
username = self.get_current_user().encode('utf-8')
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
try:
results = (
get_all_notifications(
username, customer_name,
uri, method
)
)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke('Get list of notifications', 'notifications', e)
)
logger.exception(e)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例6: get
def get(self):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri=self.request.uri
method=self.request.method
try:
self.sched = self.application.scheduler
results = job_lister(
sched=self.sched, username=username,
customer_name=customer_name.encode('utf-8'),
uri=uri, method=method
)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke('getting schedules', '', e)
)
logger.exception(e)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例7: delete
def delete(self, jobname):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri=self.request.uri
method=self.request.method
try:
self.sched = self.application.scheduler
results = (
remove_job(
self.sched, jobname,
uri=uri,method=method,
customer_name=customer_name,
username=username
)
)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke('delete schedule', '', e)
)
logger.exception(e)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例8: get
def get(self):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri=self.request.uri
method=self.request.method
try:
results= None
key=self.get_argument('key')
query=self.get_argument('query')
results = systems_hardware_details(username=username, customer_name=customer_name,
key=key, query=query,
uri=uri, method=method)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke('no stats', '', e)
)
logger.exception(e)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例9: get
def get(self):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri=self.request.uri
method=self.request.method
try:
results= None
os_code=self.get_argument('os_code', None)
tag_id=self.get_argument('tag_id', None)
results = systems_cpu_details(username=username, customer_name=customer_name,
tag_id=tag_id, os_code=os_code,
uri=uri, method=method
)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke('no stats', '', e)
)
logger.exception(e)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例10: post
def post(self):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
try:
mouse_name = self.arguments.get('name')
address = self.arguments.get('address')
customers = self.arguments.get('customers', None)
mm = MightyMouse(username, customer_name, uri, method)
results = mm.add(mouse_name, address, customers)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke(agent_id, '', e)
)
logger.exception(e)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例11: put
def put(self, agent_id):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
try:
oper_id = self.arguments.get('operation_id')
error = self.arguments.get('error', None)
success = self.arguments.get('success')
results = (
AddResults(
username, uri, method, agent_id,
oper_id, success, error
)
)
results_data = results.shutdown()
self.set_status(results_data['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(dumps(results_data, indent=4))
send_notifications(username, customer_name, oper_id, agent_id)
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke(agent_id, 'shutdown results', e)
)
logger.exception(results)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(dumps(results, indent=4))
示例12: get
def get(self, mouse_name):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
try:
mouse = mouse_exists(mouse_name)
mouse = [mouse]
results = (
GenericResults(
username, uri, method
).information_retrieved(mouse, len(mouse))
)
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
results = (
GenericResults(
username, uri, method
).something_broke(mouse_name, 'get mouse', e)
)
logger.exception(e)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例13: post
def post(self):
username = self.get_current_user()
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
name = self.arguments.get('name', None)
release_date = self.arguments.get('release_date', None)
severity = self.arguments.get('severity', 'Optional')
description = self.arguments.get('description', None)
kb = self.arguments.get('kb', '')
support_url = self.arguments.get('support_url', '')
major_version = self.arguments.get('major_version', None)
minor_version = self.arguments.get('minor_version', None)
vendor_name = self.arguments.get('vendor_name', None)
operating_system = self.arguments.get('operating_system', None)
size = self.arguments.get('size', None)
md5 = self.arguments.get('md5_hash', None)
cli_options = self.arguments.get('cli_options', None)
arch = self.arguments.get('arch', None)
uuid = self.arguments.get('id', None)
result = (
store_package_info_in_db(
username, customer_name, uri, method,
size, md5, operating_system, uuid, name,
severity, arch, major_version, minor_version,
release_date, vendor_name, description,
cli_options, support_url, kb
)
)
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(result, indent=4))
示例14: put
def put(self):
username = self.get_current_user().encode('utf-8')
customer_name = get_current_customer_name(username)
uri = self.request.uri
method = self.request.method
try:
app_ids = self.arguments.get('app_ids')
toggle = self.arguments.get('hide', 'toggle')
results = (
update_hidden_status(
username, customer_name, uri,
method, app_ids, toggle,
CustomAppsCollection
)
)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
except Exception as e:
logger.exception(e)
results = (
GenericResults(
username, uri, method
).something_broke(app_ids, 'toggle hidden on custom_apps', e)
)
self.set_status(results['http_status'])
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(results, indent=4))
示例15: post
def post(self):
passed = False
logged_in = False
username = self.get_current_user()
customer_name = get_current_customer_name(username)
mail_host = self.get_argument('host', None)
mail_user = self.get_argument('user', None)
mail_password = self.get_argument('password', None)
mail_port = self.get_argument('port', 25)
from_email = self.get_argument('from_email', None)
to_email = self.get_arguments('to_email')
is_tls = self.get_argument('is_tls', False)
is_ssl = self.get_argument('is_ssl', False)
if is_tls:
is_tls = return_bool(is_tls)
if is_ssl:
is_ssl = return_bool(is_ssl)
if mail_host and mail_user and mail_password and \
mail_port and from_email and len(to_email) >0:
create_or_modify_mail_config(
modifying_username=username, customer_name=customer_name,
server=mail_host, username=mail_user,
password=mail_password, port=mail_port,
is_tls=is_tls, is_ssl=is_ssl,
from_email=from_email, to_email=to_email
)
mail = MailClient(customer_name)
mail.connect()
if mail.logged_in:
message = '%s - Valid Mail Settings' % (username)
logger.info(message)
result = {
'pass': True,
'message': 'Valid Mail Settings'
}
elif not mail.logged_in:
message = '%s - Incorrect Authentication Settings' % (username)
logger.error(message)
result = {
'pass': False,
'message': 'Incorrect Authentication Settings'
}
elif not mail.connnected:
message = '%s - Invalid Connection Settings' % (username)
logger.error(message)
result = {
'pass': False,
'message': 'Invalid Connection Settings'
}
else:
message = '%s - Incorrect Parameters Passed' % (username)
logger.error(message)
result = {
'pass': False,
'message': 'Incorrect Parameters Passed'
}
self.set_header('Content-Type', 'application/json')
self.write(json.dumps(result, indent=4))