当前位置: 首页>>代码示例>>Python>>正文


Python FileCheckin.execute方法代码示例

本文整理汇总了Python中pyasm.checkin.FileCheckin.execute方法的典型用法代码示例。如果您正苦于以下问题:Python FileCheckin.execute方法的具体用法?Python FileCheckin.execute怎么用?Python FileCheckin.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.checkin.FileCheckin的用法示例。


在下文中一共展示了FileCheckin.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _test_checkin_type

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:27,代码来源:naming_test.py

示例2: _test_copycheckin

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:28,代码来源:checkin_test.py

示例3: copy_sobject

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:62,代码来源:sobject_copy_cmd.py

示例4: _test_base_dir_alias

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:60,代码来源:checkin_test.py

示例5: _test_symlink

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:56,代码来源:checkin_test.py

示例6: execute

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:55,代码来源:scraper_command.py

示例7: _test_data_flow

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:53,代码来源:workflow_test.py

示例8: create_snapshot

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:51,代码来源:naming_test.py

示例9: postprocess

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:51,代码来源:flash_code_update.py

示例10: _parse_form

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:49,代码来源:sobject_upload_wdg.py

示例11: _test_checkin

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:23,代码来源:checkin_test.py

示例12: _check_in_swf

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
 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,代码行数:24,代码来源:flash_render_cmd.py

示例13: _test_file_owner

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:39,代码来源:checkin_test.py

示例14: execute

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    def execute(my):

        project_code = my.kwargs.get("project_code")
        project_title = my.kwargs.get("project_title")
        project_type = my.kwargs.get("project_type")
        if not project_type:
            project_type = "simple"

        is_template = my.kwargs.get("is_template")
        project_theme = my.kwargs.get("project_theme")

        use_default_side_bar = my.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)
        # 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 = my.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()

        # find project's base_type
        base_type = project.get_base_type()

        if not base_type and project_type == "unittest":
            base_type = "unittest"
        elif not base_type:
            base_type = "simple"

#.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:TACTIC,代码行数:103,代码来源:create_project_cmd.py

示例15: _test_file_naming_manual_version

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import execute [as 别名]
    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,代码行数:69,代码来源:naming_test.py


注:本文中的pyasm.checkin.FileCheckin.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。