本文整理汇总了Python中pyasm.common.Environment.get_user_name方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_user_name方法的具体用法?Python Environment.get_user_name怎么用?Python Environment.get_user_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.common.Environment
的用法示例。
在下文中一共展示了Environment.get_user_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_defaults
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def get_defaults(self):
# TODO: autogenerate code
defaults = {
"login": Environment.get_user_name()
}
return defaults
示例2: create
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def create(sobject, value, prev_value=None):
if prev_value == value:
return
# if this is successful, the store it in the status_log
#search_type = sobject.get_search_type()
#search_id = sobject.get_id()
#search_code = sobject.get_value("code")
status_log = SearchType.create("sthpw/status_log")
status_log.set_value("login", Environment.get_user_name() )
status_log.set_sobject_value(sobject)
#status_log.set_value("search_type", search_type)
#status_log.set_value("search_code", search_id, no_exception=True)
#status_log.set_value("search_id", search_code, no_exception=True)
if prev_value:
status_log.set_value("from_status", prev_value)
status_log.set_value("to_status", value)
project_code = Project.get_project_name()
status_log.set_value("project_code", project_code)
status_log.commit(cache=False)
return status_log
示例3: get_display
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def get_display(my):
search = Search(Login)
my.set_search_for_options(search, 'login','login')
my.set_option("extra_values", "admin")
if my.kwargs.get('default_user') =='true':
my.set_option('default', Environment.get_user_name())
return super(UserSelectWdg, my).get_display()
示例4: get_subscriptions
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def get_subscriptions(my, category, mode="new"):
search = Search("sthpw/subscription")
search.add_user_filter()
if category:
search.add_filter("category", category)
if mode == "new":
search.add_op("begin")
search.add_filter("last_cleared", '"message"."timestamp"', quoted=False, op="<")
search.add_filter("last_cleared", "NULL", quoted=False, op="is")
search.add_op("or")
#project_code = Project.get_project_code()
#search.add_filter("project_code", project_code )
# use an inner join because if there are no messages, we don't
# want the subscription
search.add_order_by("message.timestamp", direction="desc", join="INNER")
# don't show user message except when category is certain values
user = Environment.get_user_name()
search.add_op("begin")
search.add_filter("login", user, op="!=", table="message")
search.add_filters("category", ["script","default","sobject"], table="message")
search.add_op("or")
else:
search.add_order_by("message.timestamp", direction="desc")
subscriptions = search.get_sobjects()
return subscriptions
示例5: add
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def add(command, kwargs, queue_type, priority, description, message_code=None):
queue = SearchType.create("sthpw/queue")
queue.set_value("project_code", Project.get_project_code())
#queue.set_sobject_value(sobject)
if not queue_type:
queue_type = "default"
queue.set_value("queue", queue_type)
queue.set_value("state", "pending")
queue.set_value("login", Environment.get_user_name())
queue.set_value("command", command)
data = jsondumps(kwargs)
queue.set_value("data", data)
if message_code:
queue.set_value("message_code", message_code)
if not priority:
priority = 9999
queue.set_value("priority", priority)
if description:
queue.set_value("description", description)
queue.set_user()
queue.commit()
return queue
示例6: get_by_key
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def get_by_key(cls, key, user=None, project_code=None, use_cache=True):
if not user:
user = Environment.get_user_name()
# ignore the project_code column for now
dict_key = '%s:%s:%s' %(cls.SEARCH_TYPE, project_code, user)
if use_cache:
settings_dict = Container.get(dict_key)
else:
settings_dict = None
# explicit check for None
if settings_dict == None:
settings_dict = {}
if use_cache:
Container.put(dict_key, settings_dict)
search = Search(cls.SEARCH_TYPE)
search.add_filter("login", user)
if project_code:
search.add_filter("project_code", project_code)
else:
search.add_null_filter("project_code")
# don't filter with the key in order to build a dict
pref_settings = search.get_sobjects()
for setting in pref_settings:
settings_dict[setting.get_value('key')] = setting
pref_setting = settings_dict.get(key)
return pref_setting
示例7: create
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def create(cls, sobject, process, description="", assigned="", supervisor="",\
status=None, depend_id=None, project_code=None, pipeline_code='', \
start_date=None, end_date=None, context='', bid_duration=8):
task = SearchType.create( cls.SEARCH_TYPE )
task.set_parent(sobject)
task.set_value("process", process )
if description:
task.set_value("description", description )
if assigned != None:
task.set_value("assigned", assigned)
if supervisor != None:
task.set_value("supervisor", supervisor)
if not project_code:
project_code = sobject.get_project_code()
task.set_value("project_code", project_code )
task.set_value("pipeline_code", pipeline_code)
if not status:
pipeline = task.get_pipeline()
process_names = pipeline.get_process_names()
if process_names:
status = process_names[0]
if status:
task.set_value("status", status)
if bid_duration:
task.set_value("bid_duration", bid_duration)
if start_date:
task.set_value("bid_start_date", start_date)
if end_date:
task.set_value("bid_end_date", end_date)
# auto map context as process as the default
#if not context:
# context = process
# let get_defaults() set the context properly instead of auto-map
if context:
task.set_value("context", context)
# DEPRECATED
if depend_id:
task.set_value("depend_id", depend_id)
# created by
if task.has_value('login'):
user = Environment.get_user_name()
task.set_value('login', user)
task.commit(triggers=True)
# log the status creation event
StatusLog.create(task, status)
return task
示例8: get_side_bar_cache
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def get_side_bar_cache(my, left_nav_wdg):
project = Project.get()
project_code = project.get_code()
# do it with sobject
#key = "%s_side_bar" % project.get_code()
#cache = Search.get("sthpw/widget_cache")
#cache.add_filter("key", key)
#sobject = cache.get_sobject()
#value = sobject.get_value("cache")
login = Environment.get_user_name()
tmp_dir = "%s/cache/side_bar" % Environment.get_tmp_dir()
filename = "%s__%s.html" % (project_code, login)
path = "%s/%s" % (tmp_dir, filename)
# use files
import os
if os.path.exists(path):
f = open(path, "r")
html = f.read()
f.close()
else:
dirname = os.path.dirname(path)
if not os.path.exists(dirname):
os.makedirs(dirname)
f = open(path, "w")
html = left_nav_wdg.get_buffer_display()
f.write(html)
f.close()
return html
示例9: execute
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def execute(my):
my.search_type = my.kwargs.get("search_type")
my.element_name = my.kwargs.get("element_name")
assert my.search_type
assert my.element_name
interval = my.kwargs.get('interval')
if not interval:
interval = 120
data_type = my.kwargs.get('data_type')
if not data_type:
data_type = 'float'
class_name = 'tactic.ui.app.aggregate_wdg.AggregateCmd'
priority = None
user = Environment.get_user_name()
# these interval jobs need to have a specific code
code = "aggregate|%s|%s" % (my.search_type, my.element_name)
# check to see if the job exists
job = Search.get_by_code("sthpw/queue", code)
if not job:
job = SearchType.create("sthpw/queue")
job.set_value("code", code)
job.set_value("project_code", Project.get_project_code() )
job.set_value("class_name", class_name)
job.set_value("command", class_name)
job.set_value("login", user)
job.set_value("queue", 'interval')
# this is meaningless
job.set_value("priority", 9999)
# not sure what to do here if it already exists
job.set_value("state", 'pending')
# add a column to the table
from pyasm.command import ColumnAddCmd
from pyasm.search import AlterTable
column_name = my.element_name
cmd = ColumnAddCmd(my.search_type, column_name, data_type)
cmd.execute()
# modify the table
#alter = AlterTable(my.search_type)
#alter.modify(my.search_type, data_type)
#print alter.get_statements()
job.set_value("serialized", str(my.kwargs) )
job.set_value("interval", interval)
job.commit()
示例10: get_results
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def get_results(my):
code = my.kwargs.get("code")
script_path = my.kwargs.get("script_path")
file_path = my.kwargs.get("file_path")
# if a script path is specified, then get it from the custom_script
# table
if script_path:
folder = os.path.dirname(script_path)
title = os.path.basename(script_path)
search = Search("config/custom_script")
search.add_filter("folder", folder)
search.add_filter("title", title)
custom_script = search.get_sobject()
if not custom_script:
raise TacticException("Custom script with path [%s/%s] does not exist" % (folder, title) )
code = custom_script.get_value("script")
elif file_path:
f = open(file_path)
code = f.read()
f.close()
server = TacticServerStub.get(protocol='local')
server.login = Environment.get_user_name()
spt_mako_results = {}
#kwargs = {
# 'server': server,
# 'spt_mako_results': spt_mako_results
#}
code = '''
<%%def name='spt_run_code()'>
<%%
%s
%%>
</%%def>
<%%
spt_mako_results['spt_ret_val'] = spt_run_code()
%%>
''' % code
#template = Template(code, output_encoding='utf-8', input_encoding='utf-8')
try:
template = Template(code)
template.render(server=server,spt_mako_results=spt_mako_results, kwargs=my.kwargs,**my.kwargs)
except Exception, e:
print "Error in Mako code: "
print code
raise
示例11: _process_task
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def _process_task(my, task, mode):
project = Project.get_project_code()
if not task.kwargs.get("user"):
user = Environment.get_user_name()
if not task.kwargs.get("project"):
project_code = Project.get_project_code()
task.kwargs['project'] = project_code
task.kwargs['mode'] = mode
示例12: get_defaults
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def get_defaults(self):
'''specifies the defaults for this sobject'''
project_code = Project.get_project_code()
me = Environment.get_user_name()
defaults = {
"project_code": project_code,
"login": me
}
return defaults
示例13: init
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def init(self):
self.task_code = self.kwargs.get('task_code', '')
self.task_pipelines = ''
self.parent_sk = self.kwargs.get('parent_sk', '')
self.parent_pyclass = ''
self.order_sk = self.kwargs.get('order_sk', '')
self.groups = Environment.get_group_names()
if 'user' in self.kwargs.keys():
self.user = str(self.kwargs.get('user'))
else:
self.user = Environment.get_user_name()
示例14: execute
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def execute(my):
assert my.snapshot
assert my.sobject
# add some additional options
my.set_option("snapshot_code", my.snapshot.get_code() )
my.set_option("render_dir", my.get_render_dir() )
input_path = my.get_input_path()
my.set_option("input_path", input_path)
# handle the policy if it exists
policy = my.render_package.get_policy()
if policy:
width = policy.get_value("width")
height = policy.get_value("height")
frame_by = policy.get_value("frame_by")
extra_settings = policy.get_value("extra_settings")
my.set_option("resolution", "%sx%s" % (width, height))
my.set_option("width", width)
my.set_option("height", height)
my.set_option("frame_by", frame_by)
my.set_option("extra_settings", extra_settings)
# get some information from the render context
search_type = my.sobject.get_search_type_obj()
description = "Render %s: %s" % (search_type.get_title(),my.sobject.get_code())
# create queue in tactic related to this submission
if not my.queue:
my.queue = Queue.create(my.sobject, "render", "9999", description)
else:
my.queue.set_sobject_value(my.sobject)
my.queue.set_value('login', Environment.get_user_name())
# have to make sure it is committed to get a queue_id
if my.queue.get_id() == -1:
my.queue.commit()
# submit the job to the dispatcher
dispatcher_id = my.submit()
# store the dispatcher id in the queue object
my.queue.set_value("dispatcher_id", dispatcher_id)
my.queue.commit()
示例15: create
# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_user_name [as 别名]
def create(cls, key, value):
setting = cls.get_by_key(key)
if not setting:
setting = PrefSetting.create_new()
setting.set_value("key", key)
user = Environment.get_user_name()
setting.set_value("login", user)
setting.set_value("value", value)
setting.commit()
return setting