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


Python checkin.FileCheckin类代码示例

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


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


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