本文整理汇总了Python中pyasm.biz.Snapshot.get_latest_by_sobject方法的典型用法代码示例。如果您正苦于以下问题:Python Snapshot.get_latest_by_sobject方法的具体用法?Python Snapshot.get_latest_by_sobject怎么用?Python Snapshot.get_latest_by_sobject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.Snapshot
的用法示例。
在下文中一共展示了Snapshot.get_latest_by_sobject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def execute(my):
from pyasm.flash.widget import FlashLayerCheckboxWdg
web = WebContainer.get_web()
cam_search_key = web.get_form_value(FlashRenderTableElementWdg.RENDER_CAM)
# FIXME: why is this called "context"
context_name = web.get_form_value(FlashRenderTableElementWdg.CONTEXT_NAME)
# submit all the selected sobjects
context = "publish"
for search_key in my.search_keys:
sobject = Search.get_by_search_key(search_key)
snapshot = Snapshot.get_latest_by_sobject(sobject, context)
if not snapshot:
raise TacticException("No checkins of context '%s' for '%s' exists" % (context, sobject.get_code()))
render = FlashGenerateExecuteXml(sobject.get_code())
render.set_snapshot_code(snapshot.get_code())
# render.execute()
# store this in the appropriate queue
dispatch = TacticDispatcher()
dispatch.set_description("Flash Render: %s" % sobject.get_code())
dispatch.execute_slave(render)
my.description = "Submitted: %s" % ", ".join(my.search_keys)
示例2: get_message
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def get_message(my):
search_type_obj = my.sobject.get_search_type_obj()
title = search_type_obj.get_title()
notification_message = my.notification.get_value("message")
message = "%s %s" % (title, my.sobject.get_name())
if notification_message:
message = "%s (%s)" %(message, notification_message)
update_desc = my.sobject.get_update_description()
parent_search_type = my.sobject.get_value('search_type')
grand_parent = None
if 'prod/submission' in parent_search_type:
parent = Search.get_by_id(parent_search_type, my.sobject.get_value('search_id') )
snapshot = Snapshot.get_latest_by_sobject(parent, 'publish')
if snapshot:
file_name = snapshot.get_file_name_by_type('main')
update_desc = '%s \n %s \n' %(update_desc, file_name)
grand_parent = parent.get_parent()
if grand_parent:
update_desc = '%s %s'%(update_desc, grand_parent.get_code())
command_desc = my.command.get_description()
message = '%s\n\nReport from transaction:\n%s\n\n%s' \
% (message, update_desc, command_desc)
return message
示例3: get_xml_value
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def get_xml_value(self):
if self.sobject.has_value(self.name):
return self.sobject.get_xml_value( self.name )
else:
from pyasm.biz import Snapshot
return Snapshot.get_latest_by_sobject(\
self.sobject).get_xml_value( self.name )
示例4: execute
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def execute(my):
search = Search(Submission)
search.set_show_retired(True)
submissions = search.get_sobjects()
for submission in submissions:
snapshot = Snapshot.get_latest_by_sobject(submission, "publish")
paths = snapshot.get_all_lib_paths()
bins = submission.get_bins()
if not bins:
print "Bin for submissin [%s] does not exist" % submission.get_id()
continue
bin = bins[0]
code = bin.get_code()
type = bin.get_value("type")
label = bin.get_value("label")
for path in paths:
if not os.path.exists(path):
print "WARNING: path '%s' does not exist" % path
continue
dirname = os.path.dirname(path)
basename = os.path.basename(path)
new_dirname = "%s/%s/%s/%s" % (dirname,type,label,code)
if not os.path.exists(new_dirname):
os.makedirs(new_dirname)
new_path = "%s/%s" % (new_dirname, basename)
print new_path
FileUndo.move(path, new_path)
示例5: get_xml_value
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def get_xml_value(my):
if my.sobject.has_value(my.name):
return my.sobject.get_xml_value( my.name )
else:
from pyasm.biz import Snapshot
return Snapshot.get_latest_by_sobject(\
my.sobject).get_xml_value( my.name )
示例6: execute
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def execute(my):
print "EXECUTING sample command"
# create the render
render = SearchType.create("prod/render")
render.set_parent(my.prev_command.sobject)
render.set_value("pipeline_code", "turntable")
render.commit()
Task.add_initial_tasks(render)
prev_sobject = my.prev_command.sobject
prev_process = "model"
this_sobject = my.prev_command.sobject
this_process = "turntable"
# get the deliverable
snapshot = Snapshot.get_latest_by_sobject(prev_sobject, prev_process)
if not snapshot:
return
# once we have this snapshot, open the file and process
lib_dir = snapshot.get_lib_dir()
file_name = snapshot.get_name_by_type("maya")
file_path = "%s/%s" % (lib_dir, file_name)
f = open( file_path, 'r')
lines = f.readlines()
f.close()
tmp_dir = Environment.get_tmp_dir()
new_file_name = "whatever.new"
new_file_path = "%s/%s" % (tmp_dir, new_file_name)
f2 = open( new_file_path, 'wb')
for i, line in enumerate(lines):
line = "%s - %s" % ( i,line)
f2.write(line)
f2.close()
file_paths = [new_file_path]
file_types = ['maya']
from pyasm.checkin import FileCheckin
checkin = FileCheckin.get(this_sobject, file_paths, file_types, context=this_process)
checkin.execute()
my.set_event_name("task/approved")
my.set_process("preprocess")
my.set_pipeline_code("turntable")
my.sobjects = [render]
# ???
my.sobject = render
my.set_as_approved()
示例7: _append_xml
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def _append_xml(my, asset, context, inst_mode, uber_xml ):
'''append xml to the uber_xml'''
snapshot = Snapshot.get_latest_by_sobject(asset, context)
loader_context = ProdLoaderContext()
loader_context.set_context(context)
loader_context.set_option('instantiation', inst_mode)
loader = loader_context.get_loader(snapshot)
loader.execute()
execute_xml = loader.get_execute_xml()
xml = execute_xml.get_xml()
xml = Xml(string=xml)
nodes = xml.get_nodes("execute/*")
for node in nodes:
uber_xml.append( " %s" % xml.to_string(node, pretty=False))
示例8: get_display
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def get_display(self):
sobject = self.get_current_sobject()
context = self.kwargs.get('context')
if not context:
context = "publish"
snapshot = Snapshot.get_latest_by_sobject(sobject, context)
if not snapshot:
return "Nothing checked in"
xml = snapshot.get_xml_value("snapshot")
print xml.to_string()
# this is a comp object ... need to find the shot
shot = sobject.get_parent("prod/shot")
# now get all of the layers
layers = shot.get_all_children("prod/layer")
div = DivWdg()
table = Table(css='embed')
# get the renders for each of the references in the snapshot
#ref_nodes = xml.get_nodes("snapshot/file/ref")
ref_nodes = xml.get_nodes("snapshot/input_ref")
unknown_ref_nodes = xml.get_nodes("snapshot/unknown_ref")
if ref_nodes:
table.add_row_cell('Ref:')
self.draw_node(ref_nodes, table)
if unknown_ref_nodes:
table.add_row_cell('Unknown Ref:')
for node in unknown_ref_nodes:
table.add_row()
table.add_cell(xml.get_attribute(node, 'path'))
div.add(table)
return div
示例9: _get_file_info
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def _get_file_info(my, sobject):
''' return the web url and the file name with flash sobject'''
snapshot = web_dir = None
if sobject:
snapshot = my.snapshot_dict.get(sobject.get_search_key())
if not snapshot:
snapshot = Snapshot.get_latest_by_sobject(sobject)
web_dir = sobject.get_remote_web_dir()
if snapshot:
fla = snapshot.get_name_by_type(".fla")
fla_file_name = snapshot.get_file_name_by_type(".fla")
fla_link = "%s/%s" % (web_dir, fla_file_name)
return fla_link, fla
else:
return None, None
示例10: _get_file_info
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def _get_file_info(my, sobject, snapshot=None, file_type='main'):
''' return the web url and the file name with media sobject'''
web_dir = None
if not sobject:
return None, None
if not snapshot:
key = sobject.get_search_key()
# the latest snapshot
snapshot = Snapshot.get_latest_by_sobject(sobject)
if snapshot:
fla = snapshot.get_name_by_type(file_type)
fla_file_name = snapshot.get_file_name_by_type(file_type)
web_dir = sobject.get_remote_web_dir()
fla_link = "%s/%s" % (web_dir, fla_file_name)
return fla_link, fla
else:
return None, None
示例11: get_version_wdg
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def get_version_wdg(self, session, snapshot, node_name):
if not snapshot:
return "---"
session_context = snapshot.get_value("context")
session_version = snapshot.get_value("version")
# get the latest
latest = Snapshot.get_latest_by_sobject(snapshot.get_sobject(),session_context)
latest_context = latest.get_value("context")
latest_version = latest.get_value("version")
version_wdg = LatestVersionContextWdg()
data = {'session_version': session_version, \
'session_context': session_context, \
'latest_context': latest_context, \
'latest_version': latest_version }
version_wdg.set_options(data)
return version_wdg
示例12: get_display
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def get_display(my):
top = my.top
my.set_as_panel(top)
top.add_class("spt_checkout_top")
top.add_color("background", "background")
top.add_style("width: 800px")
inner = DivWdg()
top.add(inner)
snapshot_codes = my.kwargs.get("snapshot_codes")
search_keys = my.kwargs.get("search_keys")
if snapshot_codes:
if isinstance(snapshot_codes, basestring):
snapshots_codes = eval(snapshot_codes)
search = Search("sthpw/snapshot")
search.add_filters("code", snapshot_codes)
snapshots = search.get_sobjects()
elif search_keys:
if isinstance(search_keys, basestring):
search_keys = eval(search_keys)
sobjects = Search.get_by_search_keys(search_keys)
snapshots = []
for sobject in sobjects:
snapshot = Snapshot.get_latest_by_sobject(sobject, process="publish")
if snapshot:
snapshots.append(snapshot)
snapshot_codes = []
for snapshot in snapshots:
snapshot_codes.append( snapshot.get("code") )
if not snapshot_codes:
no_snapshots_div = DivWdg()
no_snapshots_div.add("No files in selection")
inner.add(no_snapshots_div)
return top
sandbox_dir = Environment.get_sandbox_dir("default")
project_code = Project.get_project_code()
sandbox_dir = "%s/%s" % (sandbox_dir, project_code)
base_dir = my.kwargs.get("base_dir")
if base_dir:
title_div = DivWdg()
inner.add(title_div)
title_div.add_color("background", "background3")
title_div.add_color("color", "color3")
title_div.add_style("padding", "15px")
title_div.add_style("font-weight: bold")
title_div.add("Path: %s" % base_dir)
inner.add("Check-out to: %s" % sandbox_dir)
button_div = ButtonRowWdg()
inner.add(button_div)
button = ButtonNewWdg(title="Refresh", icon=IconWdg.REFRESH)
button_div.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_checkout_top");
spt.panel.refresh(top)
'''
} )
web = WebContainer.get_web()
if web.use_applet():
button = ButtonNewWdg(title="Check-out", icon=IconWdg.CHECK_OUT)
button_div.add(button)
button.add_behavior( {
'type': 'click_up',
'snapshot_codes': snapshot_codes,
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_checkout_top");
var progress = top.getElement(".spt_checkout_progress");
var message = top.getElement(".spt_checkout_message");
var snapshot_codes = bvr.snapshot_codes;
var num_snapshots = snapshot_codes.length;
var server = TacticServerStub.get();
for (var i = 0; i < snapshot_codes.length; i++) {
var snapshot_code = snapshot_codes[i];
var percent = parseInt( (i+1) / (num_snapshots-1) * 100);
#.........这里部分代码省略.........
示例13: handle_contents
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def handle_contents(self, set):
self.add(HtmlElement.br())
# get all of the reference nodes
snapshot = Snapshot.get_latest_by_sobject(set, "publish")
if snapshot == None:
self.add(HtmlElement.h3("No Contents"))
return
snapshot_xml = snapshot.get_xml_value("snapshot")
ref_nodes = snapshot_xml.get_nodes("snapshot/ref")
nav = ItemsNavigatorWdg(self.ITEMS_NAV_LABEL, \
len(ref_nodes), self.MAX_ITEMS_PER_PAGE)
items_range = nav.get_value()
self.add(nav)
introspect = IntrospectWdg()
introspect.add_style('padding-bottom: 3px')
self.add(introspect)
# get the contents in the introspection
session = SessionContents.get()
start, end = 1 , self.MAX_ITEMS_PER_PAGE
try:
start, end = items_range.split("-")
except Exception:
pass
ref_nodes = ref_nodes[int(start)-1 : int(end)]
sobjects = []
info = []
for node in ref_nodes:
search_type = Xml.get_attribute(node,"search_type")
search_id = Xml.get_attribute(node,"search_id")
instance = Xml.get_attribute(node,"instance")
version = Xml.get_attribute(node,"version")
latest_context = Xml.get_attribute(node,"context")
# get the latest snapshot
#TODO: this query can be optimized
latest = Snapshot.get_latest(search_type, search_id, \
latest_context)
if latest == None:
latest_version = 0
else:
latest_version = latest.get_value("version")
# add an icon
if latest != None:
sobject = latest.get_sobject()
else:
sobject = None
session_version = session.get_version(instance)
session_context = session.get_context(instance)
sobjects.append(sobject)
info.append({'session_version': session_version, \
'session_context': session_context, \
'latest_context': latest_context, \
'latest_version': latest_version, 'instance': instance})
table = TableWdg('prod/asset','set_items')
table.set_sobjects(sobjects)
table.set_aux_data(info)
self.add(table)
示例14: get_display
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def get_display(self):
self.doc_mode = self.kwargs.get("doc_mode")
path = self.kwargs.get("path")
self.search_type = self.kwargs.get("search_type")
self.last_path = None
doc_key = self.kwargs.get("doc_key")
if doc_key:
self.doc = Search.get_by_search_key(doc_key)
snapshot = Snapshot.get_latest_by_sobject(self.doc)
if snapshot:
self.last_path = snapshot.get_lib_path_by_type('main')
path = self.doc.get_value("link")
# TEST TEST TEST
if not path:
#path = "/home/apache/pdf/mongodb.txt"
#path = "/home/apache/assets/google_docs.html"
#path = "/home/apache/pdf/star_wars.txt"
path = "https://docs.google.com/document/d/1AC_YR8X8wbKsshkJ1h8EjZuFIr41guvqXq3_PXgaqJ0/pub?embedded=true"
path = "https://docs.google.com/document/d/1WPUmXYoSkR2cz0NcyM2vqQYO6OGZW8BAiDL31YEj--M/pub"
#path = "https://docs.google.com/spreadsheet/pub?key=0Al0xl-XktnaNdExraEE4QkxVQXhaOFh1SHIxZmZMQ0E&single=true&gid=0&output=html"
path = "/home/apache/tactic/doc/alias.json"
if not self.search_type:
self.search_type = "test3/shot"
self.column = "description"
top = self.top
top.add_class("spt_document_top")
self.set_as_panel(top)
#table = Table()
table = ResizableTableWdg()
top.add(table)
table.add_row()
table.set_max_width()
left_td = table.add_cell()
left_td.add_style("vertical-align: top")
title = DivWdg()
left_td.add(title)
title.add_style("padding: 10px")
title.add_color("background", "background3")
button = IconButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
title.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.app_busy.show("Reloading Document");
var top = bvr.src_el.getParent(".spt_document_top");
spt.panel.refresh(top);
spt.app_busy.hide();
'''
} )
button.add_style("float: left")
button = IconButtonWdg(title="Save", icon=IconWdg.SAVE)
title.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
'''
} )
button.add_style("float: left")
if not self.doc_mode:
self.doc_mode = "text"
select = SelectWdg("doc_mode")
select.set_option("values", "text|formatted")
title.add(select)
select.set_value(self.doc_mode)
select.add_behavior( {
'type': 'change',
'cbjs_action': '''
spt.app_busy.show("Reloading Document");
var top = bvr.src_el.getParent(".spt_document_top");
var value = bvr.src_el.value;
top.setAttribute("spt_doc_mode", value);
spt.panel.refresh(top);
spt.app_busy.hide();
'''
} )
title.add("<br clear='all'/>")
#.........这里部分代码省略.........
示例15: execute
# 需要导入模块: from pyasm.biz import Snapshot [as 别名]
# 或者: from pyasm.biz.Snapshot import get_latest_by_sobject [as 别名]
def execute(self):
web = WebContainer.get_web()
search_keys = []
# discovery phase to find the sobject to be rendered. This can be
# either a snapshots or sobjects. If it is an sobject, then
# the latest snapshot will be rendered
search_type = web.get_form_value("parent_search_type")
search_id = web.get_form_value("parent_search_id")
if search_type:
search_keys = ["%s|%s" % (search_type, search_id)]
if not search_keys:
if self.sobject:
search_keys = [self.sobject.get_search_key()]
else:
search_keys = web.get_form_values("search_key")
# get the policy
policy = None
if self.sobject:
policy_code = self.sobject.get_value("policy_code")
if policy_code:
policy = RenderPolicy.get_by_code(policy_code)
# render options
options = {}
keys = web.get_form_keys()
for key in keys:
if key.startswith("edit|"):
value = web.get_form_value(key)
new_key = key.replace("edit|", "")
options[new_key] = value
# add the xmlrpc server to the package:
# WARNING: not that there is no / separating the 2 %s.
client_api_url = web.get_client_api_url()
options['client_api_url'] = client_api_url
# go through each of the search keys found from the interface
for search_key in search_keys:
# find the sobject associates with this key
if not search_key:
continue
sobject = Search.get_by_search_key(search_key)
if not sobject:
raise TacticException("Search Key [%s] does not exist" % search_key)
# if the search_keys represented a snapshot, then use this as
# the snapshot and find the parent
if sobject.get_base_search_type() == "sthpw/snapshot":
snapshot = sobject
sobject = sobject.get_sobject()
else:
# else use the latest, assuming a context (really doesn't
# make much sense????!!!???
# FIXME: will deal with this later
context = "publish"
snapshot = Snapshot.get_latest_by_sobject(sobject, context)
if not snapshot:
raise TacticException("No checkins of context '%s' exist for '%s'. Please look at the chekin history" % (context, sobject.get_code()) )
# We provide a render package with a bunch of necessary information
render_package = RenderPackage()
render_package.set_policy(policy)
render_package.set_snapshot(snapshot)
render_package.set_sobject(sobject)
render_package.set_options(options)
# submission class
submit_class = self.get_option("submit")
if not submit_class:
submit_class = Config.get_value("services", "render_submit_class", no_exception=True)
if not submit_class:
submit_class = "pyasm.prod.render.RenderSubmit"
# now we have an sobject and a snapshot, we initiate a job
submit = Common.create_from_class_path(submit_class, [render_package])
# if this is from the EditWdg for queues then use this queue
# entry instead
if self.sobject.get_base_search_type() == "sthpw/queue":
submit.set_queue(self.sobject)
submit.execute()
self.description = "Submitted: %s" % ", ".join(search_keys)