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


Python FileCheckin.get_snapshot方法代码示例

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


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

示例1: _test_symlink

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [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

示例2: create_snapshot

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [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

示例3: _test_copycheckin

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [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

示例4: _test_checkin_type

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [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

示例5: _test_base_dir_alias

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [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

示例6: _test_checkin

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [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

示例7: _test_file_owner

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [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

示例8: _test_checkin_type

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [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='', mode='copy')
        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')
        snapshot_xml = my.auto_snapshot4.get_xml_value('snapshot')
        checkin_type = snapshot_xml.get_nodes_attr('/snapshot','checkin_type')
        # un-specified checkin_type with a matching naming will default to "strict"
        my.assertEquals('strict', checkin_type[0])

        # this should pick the auto checkin_type naming convention with the _OO at the end of context
        checkin = FileCheckin(my.person, dir_path4, "main", context='naming_base_test_OO', snapshot_type='directory', checkin_type='', mode='copy')
        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_v001')
        my.assertEquals(lib_dir , 'unittest/cut/generic/phil')
        snapshot_xml = my.auto_snapshot4.get_xml_value('snapshot')
        checkin_type = snapshot_xml.get_nodes_attr('/snapshot','checkin_type')
        # un-specified checkin_type with a matching naming will default to "strict"
        my.assertEquals('auto', checkin_type[0])


        dir_path4 = "./naming_test_folder4"
        checkin = FileCheckin(my.person, dir_path4, "main", context='naming_base_test', snapshot_type='directory', checkin_type='auto')
        checkin.execute()
        my.auto_snapshot5 = checkin.get_snapshot()
        snapshot_xml = my.auto_snapshot5.get_xml_value('snapshot')
        checkin_type = snapshot_xml.get_nodes_attr('/snapshot','checkin_type')
        
        dir_name = my.auto_snapshot5.get_file_name_by_type('main')
        lib_dir = my.auto_snapshot5.get_dir('relative')
        my.assertEquals(dir_name , 'generic_phil_v005')
        my.assertEquals(lib_dir , 'unittest/cut/generic/phil')
        my.assertEquals('auto', checkin_type[0])

        versionless = Snapshot.get_versionless(my.auto_snapshot5.get_value('search_type'), my.auto_snapshot5.get_value('search_id'), 'naming_base_test', mode='latest', create=False)

        dir_name = versionless.get_file_name_by_type('main')
        lib_dir = versionless.get_dir('relative')
        my.assertEquals(dir_name , 'generic_phil')
        my.assertEquals(lib_dir , 'unittest/cut/generic/phil')
        path = versionless.get_lib_path_by_type()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:66,代码来源:naming_test.py

示例9: _test_file_naming_manual_version

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [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

示例10: _test_level

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [as 别名]
    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, snapshot.get_value("level_id") )


        # checkin the file to the level
        my.file_path = "./biz_test_level.txt"
        for i in range(0,4):
            file = open(my.file_path, 'w')
            file.write("whatever")
            file.close()
        checkin = FileCheckin(my.person, my.file_path, "main", context=my.context, level_type=level_type, level_id=level_id)
        checkin.execute()

        snapshot = checkin.get_snapshot()
        version = snapshot.get_version()
        my.assertEquals(1, version)
        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)

        my.assertEquals( level_type, snapshot.get_value("level_type") )
        my.assertEquals( level_id, snapshot.get_value("level_id") )
        my.assertEquals( 1, snapshot.get_value("version") )
        my.assertEquals( True, snapshot.get_value("is_latest") )
        my.assertEquals( True, snapshot.get_value("is_current") )


        # get latest version and revision of the person and make sure 
        # it has its own is_latest
        top_snapshot = Snapshot.get_snapshot(my.search_type, my.search_id, context=my.context, version=-1, revision=-1, use_cache=False)
        version = top_snapshot.get_version()
        my.assertEquals(5, version)
        revision = top_snapshot.get_value('revision')
        my.assertEquals(0, revision)
        my.assertEquals( True, top_snapshot.get_value("is_latest") )
        my.assertEquals( True, top_snapshot.get_value("is_current") )
开发者ID:funic,项目名称:TACTIC,代码行数:84,代码来源:biz_test.py

示例11: _test_snapshot

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


        # create a new test.txt file
        for i in range(0,4):

            # 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()

            checkin = FileCheckin(my.person, my.file_path, "main", context=my.context)
            checkin.execute()

            # get snapshot from database
            snapshot = checkin.get_snapshot()
            code = snapshot.get_value("code")
            s = Search("sthpw/snapshot")
            s.add_filter("code", code)
            snapshot = s.get_sobject()


        # get version -1
        snapshot = Snapshot.get_by_version(my.search_type, my.search_id, context=my.context, version=-1, use_cache=False)
        version = snapshot.get_version()
        my.assertEquals(4, version)

        # latest version
        snapshot = Snapshot.get_latest(my.search_type, my.search_id, context=my.context, use_cache=False)
        version = snapshot.get_version()

        my.assertEquals('biz_test_test_v004.txt', snapshot.get_all_file_names()[0])
        my.assertEquals(4, version)
        revision = snapshot.get_value('revision')
        my.assertEquals(0, revision)

        for i in range(0,2):
            file = open(my.file_path, 'w')
            file.write("whatever")
            file.close()

            # check in 2 current revisions
            checkin = FileCheckin(my.person, my.file_path, "main", context=my.context, is_revision=True, is_current=True)
            checkin.execute()
            snapshot = checkin.get_snapshot()

            # get snapshot from database
            #snapshot = checkin.get_snapshot()
            code = snapshot.get_value("code")
            s = Search("sthpw/snapshot")
            s.add_filter("code", code)
            snapshot = s.get_sobject()


        # get current version and revision latest
        snapshot = Snapshot.get_by_version(my.search_type, my.search_code, context=my.context, version=0, revision=-1, use_cache=False)
        version = snapshot.get_version()
        my.assertEquals(4, version)
        revision = snapshot.get_value('revision')
        my.assertEquals(2, revision)
            
        # get revision
        snapshot = Snapshot.get_snapshot(my.search_type, my.search_id, context=my.context, version=-1, revision=-1, use_cache=False)
        version = snapshot.get_version()
        my.assertEquals(4, version)
        revision = snapshot.get_value('revision')
        my.assertEquals(2, revision)
        is_latest = snapshot.get_value('is_latest')
        my.assertEquals(True, is_latest)
        
        # v4r1 should not be latest
        snapshot = Snapshot.get_by_version(my.search_type, my.search_id, context=my.context, version=4, revision=1, use_cache=False)
        version = snapshot.get_version()
        my.assertEquals(4, version)
        revision = snapshot.get_value('revision')
        my.assertEquals(1, revision)
        is_latest = snapshot.get_value('is_latest')
        my.assertEquals(False, is_latest)

        # is_latest is v4r2, so can't find v4r0 any more
        snapshot = Snapshot.get_snapshot(my.search_type, my.search_id, context=my.context, version=-1, revision=None, use_cache=False)
        
        my.assertEquals(None, snapshot)

        # use max to find v4r0
        snapshot = Snapshot.get_snapshot(my.search_type, my.search_id, context=my.context, version='max', revision=None, use_cache=False)
        version = snapshot.get_version()
        my.assertEquals(4, version)
        revision = snapshot.get_value('revision')
        my.assertEquals(0, revision)
    
        # add 2 non current revisions
        for i in range(0,2):
            file = open(my.file_path, 'w')
            file.write("whatever")
            file.close()

            # check in 2 revisions
#.........这里部分代码省略.........
开发者ID:funic,项目名称:TACTIC,代码行数:103,代码来源:biz_test.py

示例12: postprocess

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [as 别名]
    def postprocess(my):
        sobject = my.sobject
        texture_snapshot = Snapshot.get_latest_by_sobject(sobject)
        web = WebContainer.get_web()

        source_search_key = web.get_form_value("predefined_source")
        if source_search_key and texture_snapshot:
            source = Search.get_by_search_key(source_search_key)
            source_snapshot = Snapshot.get_latest_by_sobject(source)
            
            xml = texture_snapshot.get_xml_value("snapshot")
            builder = SnapshotBuilder(xml)
            builder.add_ref_by_snapshot(source_snapshot)
            texture_snapshot.set_value("snapshot", builder.to_string() )
            texture_snapshot.commit()

            return




        # if no files have been uploaded, don't do anything
        field_storage = web.get_form_value("add_source")
        if field_storage == "":
            return

        # process and get the uploaded files
        upload = FileUpload()
        upload.set_field_storage(field_storage)
        upload.execute()
        files = upload.get_files()
        if not files:
            return

        file_types = upload.get_file_types()
        
        asset_code = sobject.get_value("asset_code")

        # checkin this as a new source
        import os
        source_code = os.path.basename(files[0])
        source_description = "Referred to %s" % my.sobject.get_code()
        source_category = "default"
        source = TextureSource.create(asset_code, source_code, \
            source_category, source_description)

        # add the file as a snapshot to this source
        checkin = FileCheckin(source, files, file_types )
        checkin.execute()

        source_snapshot = Snapshot.get_latest_by_sobject(source)
        xml = source_snapshot.get_xml_value("snapshot")
        builder = SnapshotBuilder(xml)
        builder.add_fref_by_snapshot(texture_snapshot)
        source_snapshot.set_value("snapshot", builder.to_string() )
        source_snapshot.commit()


        # Modify the snapshot in the original texture to reference this
        # source.  This assumes that the other uploaded snapshot has
        # already been dealt with.
        source_snapshot = checkin.get_snapshot()

        # FIXME: what if no texture was uploaded???
        xml = texture_snapshot.get_xml_value("snapshot")
        builder = SnapshotBuilder(xml)
        builder.add_ref_by_snapshot(source_snapshot)
        texture_snapshot.set_value("snapshot", builder.to_string() )
        texture_snapshot.commit()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:71,代码来源:texture_wdg.py

示例13: _test_with_naming

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

        server = Config.get_value("install", "server")
        process = "process"
        person_code = self.person.get_code()

        filename = "filename.jpg"

        process = "naming"

        subdirs = ['']

        # create a naming
        naming = SearchType.create("config/naming")
        naming.set_value("search_type", "unittest/person")
        naming.set_value("context", "naming/*")
        naming.set_value("file_naming", "TEST{basefile}_v{version}.{ext}")
        naming.commit()

        # create 2nd naming where 
        naming = SearchType.create("config/naming")
        naming.set_value("search_type", "unittest/person")
        naming.set_value("context", "naming/empty_dir_test")
        naming.set_value("file_naming", "TEST{basefile}_v{version}.{ext}")
        naming.set_value("dir_naming", "{@GET(.description)}")
        naming.commit()

        # create 3rd latest_versionless naming where 
        naming = SearchType.create("config/naming")
        naming.set_value("search_type", "unittest/person")
        naming.set_value("context", "strict/low")
        naming.set_value("file_naming", "{basefile}_latest.{ext}")
        naming.set_value("dir_naming", "{@GET(.description)}")
        naming.set_value("latest_versionless", "1")
        naming.commit()

        # create 4th current_versionless naming where 
        naming = SearchType.create("config/naming")
        naming.set_value("search_type", "unittest/person")
        naming.set_value("context", "strict/hi")
        naming.set_value("file_naming", "{basefile}_current.{ext}")
        naming.set_value("dir_naming", "{@GET(.description)}")
        naming.set_value("current_versionless", "1")
        naming.commit()

        self.clear_naming()


        for i, subdir in enumerate(subdirs):

            if subdir:
                context = "%s/%s/%s" % (process, subdir, filename)
            else:
                context = "%s/%s" % (process, filename)

            # create a new test.txt file
            file_path = "./%s" % filename
            file = open(file_path, 'w')
            file.write("test")
            file.close()

           
 


            #checkin = FileCheckin(self.person, file_path, context=context, checkin_type='auto')
            #checkin = FileCheckin(self.person, file_path, context=context, checkin_type='strict')
            checkin = FileCheckin(self.person, file_path, context=context)
            checkin.execute()

            # ensure that the check-in type is strict
            checkin_type = checkin.get_checkin_type()
            self.assertEquals("strict", checkin_type)

            snapshot = checkin.get_snapshot()

            checked_context = snapshot.get_value("context")


            path = snapshot.get_path_by_type("main")
            basename = os.path.basename(path)
            expected = "TESTfilename_v001.jpg"
            self.assertEquals(expected, basename)


        # create a new test.txt file
        file_path = "./%s" % filename
        file = open(file_path, 'w')
        file.write("test2")
        file.close()
        checkin = FileCheckin(self.person, file_path, context='naming/empty_dir_test')
        checkin.execute()
开发者ID:mincau,项目名称:TACTIC,代码行数:94,代码来源:checkin_test.py

示例14: _test_strict_checkin

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

        server = Config.get_value("install", "server")
        #process = "process"
        person_code = self.person.get_code()

        filename = "filename.jpg"

        process = "strict"

        subcontexts = [
            '', '', # do 2 checkins
            'hi', 'hi',
            'medium',
            'low',
        ]

        for i, subcontext in enumerate(subcontexts):

            if subcontext:
                context = "%s/%s" % (process, subcontext)
            else:
                context = process

            # create a new test.txt file
            file_path = "./%s" % filename
            file = open(file_path, 'w')
            file.write("test")
            file.close()


            #import time
            #start = time.time()

            checkin = FileCheckin(self.person, file_path, context=context, checkin_type='strict')
            checkin.execute()
            snapshot = checkin.get_snapshot()
            #print "time: ", time.time() - start
            #print "---"

            # make sure there is no latest versionless except for process/low
            versionless = Snapshot.get_versionless(self.person.get_search_type(), self.person.get_id(), context, mode='latest', create=False)

            versionless_current = Snapshot.get_versionless(self.person.get_search_type(), self.person.get_id(), context, mode='current', create=False)

            if context == 'strict/low':
                self.assertNotEquals(None, versionless)
                file_objects = versionless.get_all_file_objects()
                self.assertEquals(1, len(file_objects))

                file_object = file_objects[0]
                relative_dir = file_object.get_value("relative_dir")
                file_name = file_object.get_value("file_name")
                self.assertEquals(file_name ,'filename_latest.jpg')
            else:
                self.assertEquals(None, versionless)

            # make sure there is no current versionless except for process/hi
            if context == 'strict/hi':
                self.assertNotEquals(None, versionless_current)
                file_objects = versionless_current.get_all_file_objects()
                self.assertEquals(1, len(file_objects))

                file_object = file_objects[0]
                relative_dir = file_object.get_value("relative_dir")
                file_name = file_object.get_value("file_name")
                self.assertEquals(file_name, 'filename_current.jpg')
                
            else:
                self.assertEquals(None, versionless_current)

            
            path = snapshot.get_path_by_type("main")

            asset_dir = Config.get_value("checkin", "asset_base_dir", sub_key="default")

            file_objects = snapshot.get_all_file_objects()
            self.assertEquals(1, len(file_objects))

            file_object = file_objects[0]
            relative_dir = file_object.get_value("relative_dir")
            file_name = file_object.get_value("file_name")

            test_path = "%s/%s/%s" % (asset_dir, relative_dir, file_name)
            self.assertEquals(test_path, path)
开发者ID:mincau,项目名称:TACTIC,代码行数:87,代码来源:checkin_test.py

示例15: _test_auto_checkin

# 需要导入模块: from pyasm.checkin import FileCheckin [as 别名]
# 或者: from pyasm.checkin.FileCheckin import get_snapshot [as 别名]
    def _test_auto_checkin(self):
        server = Config.get_value("install", "server")
        process = "process"
        person_code = self.person.get_code()

        filename = "filename.jpg"

        process = "process"

        subdirs = [
            '', '', # do 2 checkins
            'subdir',
            'subdir/subsubdir'
        ]

        for i, subdir in enumerate(subdirs):

            if subdir:
                context = "%s/%s/%s" % (process, subdir, filename)
            else:
                context = "%s/%s" % (process, filename)

            # create a new test.txt file
            file_path = "./%s" % filename
            file = open(file_path, 'w')
            file.write("test")
            file.close()


            #import time
            #start = time.time()

            checkin = FileCheckin(self.person, file_path, context=context, checkin_type='auto')
            checkin.execute()

            #print "time: ", time.time() - start
            #print "---"


            # check the returned snapshot
            snapshot = checkin.get_snapshot()
            self.assertEquals(context, snapshot.get_value("context") )
            if i != 1: # the second checkin is version 2
                version = 1
                self.assertEquals(1, snapshot.get_value("version") )
            else:
                version = 2
            self.assertEquals(version, snapshot.get_value("version") )

            # check the file object data
            file_objects = snapshot.get_all_file_objects()
            self.assertEquals(1, len(file_objects))
            file_object = file_objects[0]
            repo_filename = file_object.get_value("file_name")

            if server:
                expected = "filename_process_%s_v%0.3d.jpg" % (server, version)
            else:
                expected = "filename_process_v%0.3d.jpg" % (version)
            self.assertEquals(expected, repo_filename)

            relative_dir = file_object.get_value("relative_dir")
            if subdir:
                expected = "unittest/person/%s/process/.versions/%s" % (person_code, subdir)
            else:
                expected = "unittest/person/%s/process/.versions" % person_code
            self.assertEquals(expected, relative_dir)

            asset_dir = Config.get_value("checkin", "asset_base_dir", sub_key="default")
            path = "%s/%s/%s" % (asset_dir, relative_dir, repo_filename)


            # make sure the path from the snapshot is correct
            snapshot_path = snapshot.get_path_by_type("main")
            self.assertEquals(path, snapshot_path)


            exists = os.path.exists(path)
            self.assertEquals(True, exists)


            # check that a versionless has been created
            versionless = Snapshot.get_versionless(self.person.get_search_type(), self.person.get_id(), context, mode='latest', create=False)

            self.assertNotEquals( None, versionless)

            self.assertEquals(-1, versionless.get_value("version") )

            versionless_path = versionless.get_path_by_type("main", "lib")
            versionless_dir = os.path.dirname(versionless_path)

            # test that it is a link
            lexists = os.path.lexists(versionless_path)
            self.assertEquals(True, lexists)

            # check the real path links to the versioned path
            real_path = os.path.realpath(versionless_path)
            self.assertEquals(real_path, path)

            # check that it actually points to a valid path
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:checkin_test.py


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