本文整理汇总了Python中pyasm.checkin.FileCheckin类的典型用法代码示例。如果您正苦于以下问题:Python FileCheckin类的具体用法?Python FileCheckin怎么用?Python FileCheckin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileCheckin类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _test_copycheckin
def _test_copycheckin(self):
# create a new copy_test.txt file
file_path = "./copy_test.txt"
file = open(file_path, 'w')
file.write("copy contents")
file.close()
file_paths = [file_path]
file_types = ['main']
context = "publish"
from pyasm.checkin import FileCheckin
checkin = FileCheckin(
self.person,
file_paths=file_paths,
file_types=file_types,
context=context,
mode="copy"
)
checkin.execute()
self.assertEquals(True, os.path.exists(file_path) )
snap = checkin.get_snapshot()
file_obj = snap.get_file_by_type('main')
file_name = file_obj.get_file_name()
self.assertEquals(file_name, 'copy_test_publish_v002.txt')
开发者ID:mincau,项目名称:TACTIC,代码行数:26,代码来源:checkin_test.py
示例2: copy_sobject
def copy_sobject(my, sobject, dst_search_type, context=None, checkin_mode='inplace'):
new_sobject = SearchType.create(dst_search_type)
search_type = SearchType.get(dst_search_type)
columns = SearchType.get_columns(dst_search_type)
data = sobject.get_data()
for name, value in data.items():
if name in ['id','pipeline_code']:
continue
if name not in columns:
continue
if not value:
continue
if name == "code":
value = Common.get_next_sobject_code(sobject, 'code')
if not value:
continue
new_sobject.set_value(name, value)
if SearchType.column_exists(dst_search_type, "project_code"):
project_code = Project.get_project_code()
new_sobject.set_value("project_code", project_code)
new_sobject.commit()
# get all of the current snapshots and file paths associated
if not context:
snapshots = Snapshot.get_all_current_by_sobject(sobject)
else:
snapshots = [Snapshot.get_current_by_sobject(sobject, context)]
if not snapshots:
return
msgs = []
for snapshot in snapshots:
#file_paths = snapshot.get_all_lib_paths()
file_paths_dict = snapshot.get_all_paths_dict()
file_types = file_paths_dict.keys()
if not file_types:
continue
# make sure the paths match the file_types
file_paths = [file_paths_dict.get(x)[0] for x in file_types]
mode = checkin_mode
# checkin the files (inplace)
try:
context = snapshot.get_value('context')
checkin = FileCheckin(new_sobject, context=context, file_paths=file_paths, file_types=file_types, mode=mode)
checkin.execute()
#print "done: ", context, new_sobject.get_related_sobjects("sthpw/snapshot")
except CheckinException, e:
msgs.append('Post-process Check-in Error for %s: %s ' %(context, e.__str__()))
开发者ID:0-T-0,项目名称:TACTIC,代码行数:60,代码来源:sobject_copy_cmd.py
示例3: _test_checkin_type
def _test_checkin_type(my):
my.assertEquals(my.auto_snapshot.get_version(), 2)
dir_name = my.auto_snapshot.get_file_name_by_type('main')
my.assertEquals(dir_name , 'naming_test_folder_naming_base_test_v002')
dir_name = my.auto_snapshot2.get_file_name_by_type('main')
my.assertEquals(1, my.auto_snapshot2.get_version())
my.assertEquals(dir_name , '.tactic_test_naming_folder_test_v001')
dir_name = my.auto_snapshot3.get_file_name_by_type('main')
# this takes the auto generated name
my.assertEquals(dir_name , 'naming_test_folder3_naming_base_test_v003')
# this one would take into account of the new naming entry introduced in _test_get_naming
# test a blank checkin_type
dir_path4 = "./naming_test_folder4"
checkin = FileCheckin(my.person, dir_path4, "main", context='naming_base_test', snapshot_type='directory', checkin_type='')
checkin.execute()
my.auto_snapshot4 = checkin.get_snapshot()
dir_name = my.auto_snapshot4.get_file_name_by_type('main')
lib_dir = my.auto_snapshot4.get_dir('relative')
my.assertEquals(dir_name , 'generic_phil_v004')
my.assertEquals(lib_dir , 'unittest/cut/generic/phil')
开发者ID:blezek,项目名称:TACTIC,代码行数:25,代码来源:naming_test.py
示例4: _test_base_dir_alias
def _test_base_dir_alias(my):
Config.set_value("checkin", "asset_base_dir", {
'default': '/tmp/tactic/default',
'alias': '/tmp/tactic/alias',
'alias2': '/tmp/tactic/alias2',
});
asset_dict = Environment.get_asset_dirs()
default_dir = asset_dict.get("default")
my.assertEquals( "/tmp/tactic/default", default_dir)
aliases = asset_dict.keys()
# "plugins" is assumed in some branch
if 'plugins' in aliases:
my.assertEquals( 4, len(aliases))
else:
my.assertEquals( 3, len(aliases))
my.assertNotEquals( None, "alias" in aliases )
# create a naming
naming = SearchType.create("config/naming")
naming.set_value("search_type", "unittest/person")
naming.set_value("context", "alias")
naming.set_value("dir_naming", "alias")
naming.set_value("file_naming", "text.txt")
naming.set_value("base_dir_alias", "alias")
naming.commit()
# create 2nd naming where
naming = SearchType.create("config/naming")
naming.set_value("search_type", "unittest/person")
naming.set_value("context", "alias2")
naming.set_value("dir_naming", "alias2")
naming.set_value("base_dir_alias", "alias2")
naming.set_value("file_naming", "text.txt")
naming.set_value("checkin_type", "auto")
naming.commit()
my.clear_naming()
# create a new test.txt file
for context in ['alias', 'alias2']:
file_path = "./test.txt"
file = open(file_path, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(my.person, file_path, context=context)
checkin.execute()
snapshot = checkin.get_snapshot()
lib_dir = snapshot.get_lib_dir()
expected = "/tmp/tactic/%s/%s" % (context, context)
my.assertEquals(expected, lib_dir)
path = "%s/text.txt" % (lib_dir)
exists = os.path.exists(path)
my.assertEquals(True, exists)
开发者ID:hellios78,项目名称:TACTIC,代码行数:58,代码来源:checkin_test.py
示例5: execute
def execute(my):
import urllib
from pyasm.checkin import FileCheckin
from pyasm.search import Search
pic_dict = {}
pics = []
order_dict = {}
for ocode in my.orders:
order = my.server.eval("@SOBJECT(twog/order['code','%s'])" % ocode)[0]
ord_s = Search('twog/order')
ord_s.add_filter('code',ocode)
order = ord_s.get_sobject()
if order:
order_dict[ocode] = order
poster = order.get_value('imdb_poster_url')
if poster not in pics:
pics.append(poster)
pic_dict[poster] = [ocode]
else:
pic_dict[poster].append(ocode)
pic_places = {}
number = 0
for pic in pics:
extension_s = pic.split('.')
extension = extension_s[len(extension_s) - 1]
place = '/var/www/html/imdb_images/associator%s.%s' % (number, extension)
f = open(place,'wb')
f.write(urllib.urlopen(pic).read())
f.close()
pic_places[pic] = place
number = number + 1
for pic in pics:
server_path = pic_places[pic]
linked_orders = pic_dict[pic]
for ocode in linked_orders:
sobject = order_dict[ocode]
if sobject:
file_types = ['main']
context = "icon"
checkin = FileCheckin(
sobject,
file_paths=server_path,
file_types=file_types,
context=context,
mode="copy"
)
checkin.execute()
return ''
开发者ID:Smurgledwerf,项目名称:custom,代码行数:53,代码来源:scraper_command.py
示例6: _test_data_flow
def _test_data_flow(my):
# create a dummy sobject
sobject = SearchType.create("unittest/city")
sobject.commit()
# check in a file to the city
file_path = "./ttteeesssttt.txt"
file = open(file_path, 'w')
file.write("test test test")
file.close()
file_paths = [file_path]
file_types = ['main']
context = "publish"
from pyasm.checkin import FileCheckin
checkin = FileCheckin(
sobject,
file_paths=file_paths,
file_types=file_types,
context="fla",
mode="move"
)
checkin.execute()
# create a pipeline
pipeline_xml = '''
<pipeline>
<process type="auto" name="a"/>
<process type="auto" name="b"/>
<process type="approval" name="c"/>
<connect from="a" to="b"/>
<connect from="b" to="c"/>
</pipeline>
'''
pipeline, processes = my.get_pipeline(pipeline_xml)
sobject.set_value("pipeline_code", pipeline.get_code())
sobject.commit()
process = processes.get("a")
process.set_json_value("workflow", {
'output': {
'sobject': 'sobject',
'process': 'fla',
'version': 'latest',
}
'checkin': ['fla'],
} )
开发者ID:0-T-0,项目名称:TACTIC,代码行数:51,代码来源:workflow_test.py
示例7: postprocess
def postprocess(my):
if my.sobject.is_general_asset():
return
# check to see if there are any snapshots
# context is specified here to ignore any icon snapshots
snapshot = Snapshot.get_latest_by_sobject(my.sobject, context='publish')
if snapshot:
return
column = "snapshot"
new_file_paths = []
file_paths = []
# copy the default file to /tmp
template_code = my.get_default_code()
template = my.get_template_obj()
if template:
template_code = template.get_value('code')
tmpl_snapshot = Snapshot.get_latest_by_sobject(template)
file_paths = tmpl_snapshot.get_all_lib_paths()
else:
file_types = ['.fla','.png','_icon.png','.swf']
# TODO: this is a web depedency we don't need
from pyasm.web import WebContainer
web = WebContainer.get_web()
for type in file_types:
file_paths.append('%s/template/%s%s' % (web.get_context_dir(), \
template_code, type))
for file_path in file_paths:
# rename and copy each file to /tmp
base_name = os.path.basename(file_path)
base_name = File.remove_file_code(base_name)
base_name = base_name.replace(template_code, \
my.get_naming().get_current_code(my.sobject) )
# do a straight copy : No undo
tmp_dir = Environment.get_tmp_dir()
new_file_path = "%s/download/%s" % (tmp_dir,base_name)
shutil.copyfile(file_path, new_file_path)
new_file_paths.append(new_file_path)
file_types = [".fla", ".png", "icon",".swf"]
checkin = FileCheckin( my.sobject, new_file_paths, file_types, \
snapshot_type="flash", column=column )
checkin.execute()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:49,代码来源:flash_code_update.py
示例8: postprocess
def postprocess(self):
web = get_web_container()
self.files = []
self.file_types = []
self._upload_zipped_files()
context = self.get_value("%s|context" % self.name)
description = self.get_value("%s|description" % self.name)
# let checkin take care of moving files to the lib
from pyasm.checkin import FileCheckin
for sobject in self.sobject_dict.keys():
files, file_types = self.sobject_dict.get(sobject)
self.checkin = FileCheckin.get( sobject, files, file_types, \
context=context, snapshot_type="file" )
self.checkin.set_description(description)
self.checkin.execute()
# remove the files in upload area
for key in self.sobject_dict.keys():
files, file_types = self.sobject_dict.get(key)
for file in files:
os.unlink(file)
开发者ID:mincau,项目名称:TACTIC,代码行数:26,代码来源:edit_wdg_action.py
示例9: _parse_form
def _parse_form(my):
# get the downloaded files and sort them
web = WebContainer.get_web()
my.upload_values.sort()
filenames = []
ticket = web.get_cookie("login_ticket")
# create a new entry for every file
for upload_value in my.upload_values:
tmp_dir = Environment.get_tmp_dir()
basename = os.path.basename(upload_value)
file_path = "%s/upload/%s/%s" % (tmp_dir, ticket, basename)
filenames.append(basename)
creator = IconCreator(file_path)
creator.create_icons()
my.file_paths = [file_path]
file_types = ["main"]
web_path = creator.get_web_path()
if web_path != None:
my.file_paths.append(web_path)
file_types.append("web")
icon_path = creator.get_icon_path()
if icon_path != None:
my.file_paths.append(icon_path)
file_types.append("icon")
sobject = None
if my.search_key:
sobject = Search.get_by_search_key(my.search_key)
else:
sobject = SObjectFactory.create(my.search_type)
sobject.commit()
checkin = FileCheckin(sobject, my.file_paths, file_types, column=my.column)
checkin.set_description(web.get_form_value(SObjectUploadCmd.PUBLISH_COMMENT))
checkin.execute()
my.repo_file_list.append(checkin.file_dict)
my.description = "Added files: %s" % filenames
开发者ID:hellios78,项目名称:TACTIC,代码行数:47,代码来源:sobject_upload_wdg.py
示例10: execute
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()
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:57,代码来源:command.py
示例11: _test_symlink
def _test_symlink(self):
if os.name == 'nt':
return
# create a new test.txt file
file_path = "./symlink.txt"
file = open(file_path, 'w')
file.write("symlink test")
file.close()
file_path2 = "./symlink_append.txt"
file = open(file_path2, 'w')
file.write("append test")
file.close()
checkin = FileCheckin(self.person, file_path, context="sym_test", checkin_type='auto')
checkin.execute()
snap = checkin.get_snapshot()
versionless_snap = Snapshot.get_versionless(self.person.get_search_type(), self.person.get_id(), "sym_test", mode='latest', create=False)
self.assertEquals(True, isinstance(versionless_snap, Snapshot))
main_lib_path = snap.get_lib_path_by_type('main')
self.assertEquals(main_lib_path.endswith('/sym_test/.versions/symlink_sym_test_v001.txt'), True)
if versionless_snap:
lib_path =versionless_snap.get_lib_path_by_type('main')
self.assertEquals(True, os.path.exists(lib_path))
rel_path = os.readlink(lib_path)
lib_dir = os.path.dirname(lib_path)
# this is essentially handle_link() in FileUndo class
wd = os.getcwd()
os.chdir(lib_dir)
real_path = os.path.join(lib_dir, os.path.abspath(rel_path))
# lib_path points to real_path
expected_rel_path = Common.relative_path(lib_path, real_path)
self.assertEquals(True, os.path.exists(real_path))
self.assertEquals(expected_rel_path, rel_path)
os.chdir(wd)
# if not inplace or preallocate mode, keep_file_name should be False
checkin = FileAppendCheckin(snap.get_code(), [file_path2], file_types=['add'], keep_file_name=False, checkin_type='auto')
checkin.execute()
snap = checkin.get_snapshot()
main_lib_path = snap.get_lib_path_by_type('add')
self.assertEquals(snap.get_value('is_current'), True)
self.assertEquals(snap.get_value('is_latest'), True)
self.assertEquals(main_lib_path.endswith('/sym_test/.versions/symlink_append_sym_test_v001.txt'), True)
versionless_snap = Snapshot.get_versionless(self.person.get_search_type(), self.person.get_id(), "sym_test", mode='latest', create=False)
if versionless_snap:
lib_path = versionless_snap.get_lib_path_by_type('add')
self.assertEquals(lib_path.endswith('/sym_test/symlink_append_sym_test.txt'), True)
self.assertEquals(os.path.exists(lib_path), True)
开发者ID:mincau,项目名称:TACTIC,代码行数:54,代码来源:checkin_test.py
示例12: _test_checkin
def _test_checkin(self):
# create a new test.txt file
file_path = "./test.txt"
file = open(file_path, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(self.person, file_path, "test")
checkin.execute()
# check that the file exists
snapshot = checkin.get_snapshot()
xml = snapshot.get_xml_value("snapshot")
file_code = xml.get_value("snapshot/file/@file_code")
file_name = xml.get_value("snapshot/file/@name")
self.assertNotEqual(None, file)
lib_path = "%s/%s" % (snapshot.get_lib_dir(),file_name)
self.assertEquals(True, os.path.exists(lib_path) )
开发者ID:mincau,项目名称:TACTIC,代码行数:21,代码来源:checkin_test.py
示例13: _check_in_swf
def _check_in_swf(my, snapshot, sobject, render, pat, final_pat, render_dir, filenames):
final_path = icon_path = ''
for name in filenames:
if pat.match(name):
final_name = pat.sub(final_pat, name)
shutil.move(render_dir + "/" + name, render_dir \
+ "/" + final_name)
src_path = "%s/%s" % (render_dir, final_name)
if final_name.endswith('.png'):
icon_creator = IconCreator(src_path)
icon_creator.create_icons()
icon_path = icon_creator.get_icon_path()
elif final_name.endswith('.swf'):
final_path = src_path
types = ["main"]
paths = [final_path]
if icon_path:
paths.append(icon_path)
types.append('icon')
checkin = FileCheckin(render, paths, types, context="render", column="images")
checkin.execute()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:22,代码来源:flash_render_cmd.py
示例14: check
def check(my):
web = WebContainer.get_web()
if web.get_form_value(MayaShotCheckinWdg.PUBLISH_SET_BUTTON) == "":
return False
if not my._check_context():
return False
# if there is publish error, exit
error_path = '%s/error.txt' %FileCheckin.get_upload_dir()
if os.path.exists(error_path):
return False
return True
开发者ID:0-T-0,项目名称:TACTIC,代码行数:14,代码来源:prod_checkin_cbk.py
示例15: _test_file_owner
def _test_file_owner(self):
# FIXME: this test has hard coded st_uids that only work on very
# specific conditions
return
if os.name == 'nt':
return
# create a new test.txt file
file_path = "./test2.txt"
file = open(file_path, 'w')
file.write("whatever")
file.close()
# owned by root
os.system('echo south123paw | sudo -S chown root.root \"%s\"'%file_path)
stat = os.stat(file_path)
self.assertEquals(stat.st_uid, 0)
checkin = FileCheckin(self.person, file_path, "test")
checkin.execute()
# check that the file exists
snapshot = checkin.get_snapshot()
xml = snapshot.get_xml_value("snapshot")
file_code = xml.get_value("snapshot/file/@file_code")
file_name = xml.get_value("snapshot/file/@name")
self.assertNotEqual(None, file)
lib_path = "%s/%s" % (snapshot.get_lib_dir(),file_name)
self.assertEquals(True, os.path.exists(lib_path) )
stat = os.stat(lib_path)
if Config.get_value("checkin", "sudo_no_password") == 'true':
self.assertEquals(stat.st_uid, 48)
else:
# if not set, it will remain owned by root
self.assertEquals(stat.st_uid, 0)
开发者ID:mincau,项目名称:TACTIC,代码行数:37,代码来源:checkin_test.py
示例16: _test_file_naming_manual_version
def _test_file_naming_manual_version(my):
my.clear_naming()
naming = SearchType.create('config/naming')
naming.set_value('search_type','unittest/person')
naming.set_value('context', 'naming_test')
naming.set_value('dir_naming', '{project.code}/cut/{sobject.code}')
naming.set_value('file_naming', '{sobject.code}_v{snapshot.version}.{ext}')
naming.commit()
from pyasm.common import Environment
base_dir = Environment.get_asset_dir()
preallocated = my.snapshot.get_preallocated_path(file_type='maya', file_name='what_v005.ma',ext='ma')
my.assertEquals('%s/unittest/cut/phil/phil_v001.ma'%base_dir, preallocated)
# now turn on manual_version
naming.set_value('manual_version', True)
naming.commit()
my.clear_naming()
preallocated = my.snapshot.get_preallocated_path(file_type='maya', file_name='what_v005.ma',ext='ma')
my.assertEquals('%s/unittest/cut/phil/phil_v005.ma'%base_dir, preallocated)
# Uppercase V and more digits
preallocated = my.snapshot.get_preallocated_path(file_type='maya', file_name='what_V0010.ma',ext='ma')
my.assertEquals('%s/unittest/cut/phil/phil_v010.ma'%base_dir, preallocated)
#my.snapshot.commit()
# zero or negative version is ignored
# create a new manual version test.txt file
file_path = "./naming_v0000_test.txt"
for i in range(0,4):
file = open(file_path, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(my.person, file_path, "main", context='naming_test')
checkin.execute()
my.snapshot = checkin.get_snapshot()
my.assertEquals(11, my.snapshot.get_version())
# zero or negative version is ignored
# create a new manual version test.txt file
file_path = "./naming_v-23_test.txt"
for i in range(0,4):
file = open(file_path, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(my.person, file_path, "main", context='naming_test')
checkin.execute()
my.snapshot = checkin.get_snapshot()
my.assertEquals(12, my.snapshot.get_version())
file_path = "./naming_v025_test.txt"
for i in range(0,4):
file = open(file_path, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(my.person, file_path, "main", context='naming_test')
checkin.execute()
my.snapshot = checkin.get_snapshot()
my.assertEquals(25, my.snapshot.get_version())
naming.delete()
my.clear_naming()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:67,代码来源:naming_test.py
示例17: create_snapshot
def create_snapshot(my):
# set up a real person and snapshot (as opposed to virtual)
code = 'phil'
my.person = SearchType.create( 'unittest/person' )
my.person.set_value("code",code)
my.person.set_value("name_first", "Philip")
my.person.commit()
# create a new test.txt file
file_path = "./naming_test.txt"
for i in range(0,4):
file = open(file_path, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(my.person, file_path, "main", context='naming_test')
checkin.execute()
my.snapshot = checkin.get_snapshot()
# create another test_base.txt file
file_path = "./naming_base_test.txt"
for i in range(0,4):
file = open(file_path, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(my.person, file_path, "main", context='naming_base_test')
checkin.execute()
my.base_snapshot = checkin.get_snapshot()
dir_path = "./naming_test_folder"
dir_path2 = "./.tactic_test" # test . folder
dir_path3 = "./naming_test_folder3"
dir_path4 = "./naming_test_folder4"
for path in [dir_path, dir_path2, dir_path3, dir_path4]:
if not os.path.exists(path):
os.makedirs(path)
checkin = FileCheckin(my.person, dir_path, "main", context='naming_base_test', checkin_type='auto')
checkin.execute()
my.auto_snapshot = checkin.get_snapshot()
checkin = FileCheckin(my.person, dir_path2, "main", context='naming_folder_test', snapshot_type='directory', checkin_type='auto')
checkin.execute()
my.auto_snapshot2 = checkin.get_snapshot()
# test a blank checkin_type
checkin = FileCheckin(my.person, dir_path3, "main", context='naming_base_test', snapshot_type='directory', checkin_type='')
checkin.execute()
my.auto_snapshot3 = checkin.get_snapshot()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:49,代码来源:naming_test.py
示例18: execute
def execute(self):
project_code = self.kwargs.get('project_code')
project_title = self.kwargs.get('project_title')
project_type = self.kwargs.get('project_type')
project_description = self.kwargs.get("description")
if not project_type:
project_type = "simple"
is_template = self.kwargs.get('is_template')
project_theme = self.kwargs.get('project_theme')
use_default_side_bar = self.kwargs.get('use_default_side_bar')
if use_default_side_bar in [False, 'false']:
use_default_side_bar = False
else:
use_default_side_bar = True
assert project_code
assert project_type
if project_type:
# check to see if it exists
search = Search("sthpw/project_type")
search.add_filter("code", project_type)
project_type_sobj = search.get_sobject()
if not project_type_sobj:
# just create a default one in this case if it is named
# after the project code
if not is_template and project_type == project_code:
project_type = 'default'
# create a new project type
search = Search("sthpw/project_type")
search.add_filter("code", project_type)
project_type_sobj = search.get_sobject()
if not project_type_sobj:
project_type_sobj = SearchType.create("sthpw/project_type")
project_type_sobj.set_value("code", project_type)
project_type_sobj.set_value("type", "simple")
project_type_sobj.commit()
# set the current project to Admin
Project.set_project("admin")
# create a new project sobject
project = SearchType.create("sthpw/project")
project.set_value("code", project_code)
project.set_value("title", project_title)
project.set_value("type", project_type)
if project_description:
project.set_value("description", project_description)
# set the update of the database to current (this is obsolete)
#project.set_value("last_db_update", "now()")
project.set_value("last_version_update", "2.5.0.v01")
if is_template in ['true', True, 'True']:
project.set_value("is_template", True)
else:
project.set_value("is_template", False)
if project_type != "default":
category = Common.get_display_title(project_type)
project.set_value("category", category)
project.commit()
# if there is an image, check it in
upload_path = self.kwargs.get("project_image_path")
if upload_path:
if not os.path.exists(upload_path):
raise TacticException("Cannot find upload image for project [%s]" % upload_path)
file_type = 'main'
file_paths = [upload_path]
file_types = [file_type]
source_paths = [upload_path]
from pyasm.biz import IconCreator
if os.path.isfile(upload_path):
icon_creator = IconCreator(upload_path)
icon_creator.execute()
web_path = icon_creator.get_web_path()
icon_path = icon_creator.get_icon_path()
if web_path:
file_paths = [upload_path, web_path, icon_path]
file_types = [file_type, 'web', 'icon']
from pyasm.checkin import FileCheckin
checkin = FileCheckin(project, context='icon', file_paths=file_paths, file_types=file_types)
checkin.execute()
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:101,代码来源:create_project_cmd.py
示例19: _test_notification
def _test_notification(self):
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 001: a new item has been added.')
sobject.set_value("event",'insert|unittest/country')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 002: an item has been updated.')
sobject.set_value("event",'update|unittest/country')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 003: New notes added.')
sobject.set_value("event",'insert|sthpw/note')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 004: New task assigned.')
sobject.set_value("event",'change|sthpw/task|status')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 005: task status has been changed.')
sobject.set_value("event",'change|sthpw/task|assigned')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 006: Files are checked in.')
sobject.set_value("event",'checkin|unittest/country')
sobject.commit()
# Item added
self.clear_notification()
sobject1 = SearchType.create("unittest/country")
sobject1.set_value('code', 'test_update_trigger')
sobject1.commit()
# Updated item
sobject1.set_value('code','success')
sobject1.commit()
# Note added
Note.create(self.person, "test note2", context='default2')
# Task assigned
sobject = Task.create(self.person,'hi','hellotest',assigned="test assigned")
# Task status changed
tasks = Task.get_by_sobject(self.person)
tasks[0].set_value('process','success')
tasks[0].commit()
# Files are checked in
file_path = "./notification_test_check.txt"
for i in range(0,4):
file = open(file_path, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(sobject1, file_path, "main", context='test', checkin_type='auto')
checkin.execute()
Trigger.call_all_triggers()
if os.path.exists(file_path):
os.remove(file_path)
开发者ID:mincau,项目名称:TACTIC,代码行数:65,代码来源:notification_test.py
示例20: _test_level
def _test_level(my):
# add a country
sobject = SearchType.create("unittest/country")
sobject.set_value("code", "canada")
sobject.commit()
# add a city
sobject = SearchType.create("unittest/city")
sobject.set_value("code", "toronto")
sobject.set_value("country_code", "canada")
sobject.commit()
my.person.set_value("city_code", "toronto")
my.person.commit()
level_type = "unittest/city"
level_code = "toronto"
level = Search.get_by_code(level_type, level_code)
level_id = level.get_id()
# create a new test.txt file
my.file_path = "./biz_test.txt"
for i in range(0,4):
file = open(my.file_path, 'w')
file.write("whatever")
file.close()
# creating version 5
checkin = FileCheckin(my.person, my.file_path, "main", context=my.context)
checkin.execute()
my.file_path = "./biz_fulltest.txt"
file = open(my.file_path, 'w')
file.write("whatever")
file.close()
# for checkin using test/subtest
checkin = FileCheckin(my.person, my.file_path, "main", context=my.full_context)
checkin.execute()
snapshot = Snapshot.get_snapshot(my.search_type, my.search_id, my.context, version=-1, use_cache=True, level_type=level_type, level_id=level_id)
# make sure we get the top level one
my.assertEquals( 5, snapshot.get_value("version") )
my.assertEquals( "", snapshot.get_value("level_type") )
# integer None is now converted to 0
my.assertEquals( 0, s
|
请发表评论