Пример #1
0
    def generate_icon(my, search_key):

        sobject = Search.get_by_search_key(search_key)
        search_code = sobject.get_code()
        search_type = sobject.get_search_type()
        base_search_type = sobject.get_base_search_type()


        if base_search_type == 'sthpw/snapshot':
            snapshot_code = sobject.get_code()

            file_type = "main"
            path = sobject.get_lib_path_by_type(file_type)

            icon_creator = IconCreator(path)
            icon_creator.execute()

            web_path = icon_creator.get_web_path()
            icon_path = icon_creator.get_icon_path()
            if web_path:
                sub_file_paths = [web_path, icon_path]
                sub_file_types = ['web', 'icon']

            from pyasm.checkin import FileAppendCheckin
            checkin = FileAppendCheckin(snapshot_code, sub_file_paths, sub_file_types, mode="inplace")
            checkin.execute()
            snapshot = checkin.get_snapshot()


        else:

            snapshot = Snapshot.get_snapshot(search_type, search_code, process=['publish',''])

            if not snapshot:
                return

            file_type = "main"
            path = snapshot.get_lib_path_by_type(file_type)


            # use api
            from tactic_client_lib import TacticServerStub
            server = TacticServerStub.get()
            snapshot = server.simple_checkin(search_key, "icon", path, mode="copy")


            # need the actual sobject to get the path to replace the icon
            # in the ui
            snapshot = Search.get_by_search_key(snapshot.get("__search_key__"))


        my.path = snapshot.get_web_path_by_type("icon")
Пример #2
0
    def generate_icon(my, search_key):

        sobject = Search.get_by_search_key(search_key)
        search_code = sobject.get_code()
        search_type = sobject.get_search_type()
        base_search_type = sobject.get_base_search_type()


        if base_search_type == 'sthpw/snapshot':
            snapshot_code = sobject.get_code()

            file_type = "main"
            path = sobject.get_lib_path_by_type(file_type)

            #To check if it is a sequence checkin
            all_snapshots=sobject.get_all_file_objects()
            for single_snapshot in all_snapshots:
                if single_snapshot.get('base_type') == 'sequence':
                    return

            icon_creator = IconCreator(path)
            icon_creator.execute()

            web_path = icon_creator.get_web_path()
            icon_path = icon_creator.get_icon_path()
            if web_path:
                sub_file_paths = [web_path, icon_path]
                sub_file_types = ['web', 'icon']

                from pyasm.checkin import FileAppendCheckin
                checkin = FileAppendCheckin(snapshot_code, sub_file_paths, sub_file_types, mode="inplace")
                checkin.execute()
                snapshot = checkin.get_snapshot()
            else:
                snapshot = sobject


        else:

            snapshot = Snapshot.get_snapshot(search_type, search_code, process=['publish',''])

            if not snapshot:
                return

            #To check if it is a sequence checkin
            all_snapshots=snapshot.get_all_file_objects()
            for single_snapshot in all_snapshots:
                if single_snapshot.get('base_type') == 'sequence':
                    return

            file_type = "main"
            path = snapshot.get_lib_path_by_type(file_type)
            ext = File.get_extension(path)
            ext = ext.lower()
            if ext in File.NORMAL_EXT:

                return

            # use api
            """
            from tactic_client_lib import TacticServerStub
            server = TacticServerStub.get()
            snapshot = server.simple_checkin(search_key, "icon", path, mode="copy")
            """

            icon_creator = IconCreator(path)
            icon_creator.execute()

            web_path = icon_creator.get_web_path()
            icon_path = icon_creator.get_icon_path()
            if web_path and icon_path:
                sub_file_paths = [path, web_path, icon_path]
                sub_file_types = [path, 'web', 'icon']

                from pyasm.checkin import FileCheckin
                checkin = FileCheckin(sobject, sub_file_paths, sub_file_types, context='icon', mode="copy")
                checkin.execute()
                snapshot = checkin.get_snapshot()

            # need the actual sobject to get the path to replace the icon
            # in the ui
            #snapshot = Search.get_by_search_key(snapshot.get("__search_key__"))


        my.path = snapshot.get_web_path_by_type("icon")
Пример #3
0
    def generate_icon(my, search_key):

        sobject = Search.get_by_search_key(search_key)
        search_code = sobject.get_code()
        search_type = sobject.get_search_type()
        base_search_type = sobject.get_base_search_type()


        if base_search_type == 'sthpw/snapshot':
            snapshot_code = sobject.get_code()

            file_type = "main"
            path = sobject.get_lib_path_by_type(file_type)

            #To check if it is a sequence checkin
            all_snapshots=sobject.get_all_file_objects()
            for single_snapshot in all_snapshots:
                if single_snapshot.get('base_type') == 'sequence':
                    return

            icon_creator = IconCreator(path)
            icon_creator.execute()

            web_path = icon_creator.get_web_path()
            icon_path = icon_creator.get_icon_path()
            if web_path:
                sub_file_paths = [web_path, icon_path]
                sub_file_types = ['web', 'icon']

                from pyasm.checkin import FileAppendCheckin
                checkin = FileAppendCheckin(snapshot_code, sub_file_paths, sub_file_types, mode="inplace")
                checkin.execute()
                snapshot = checkin.get_snapshot()
            else:
                snapshot = sobject


        else:

            snapshot = Snapshot.get_snapshot(search_type, search_code, process=['publish',''])

            if not snapshot:
                return

            #To check if it is a sequence checkin
            all_snapshots=snapshot.get_all_file_objects()
            for single_snapshot in all_snapshots:
                if single_snapshot.get('base_type') == 'sequence':
                    return

            file_type = "main"
            path = snapshot.get_lib_path_by_type(file_type)
            ext = File.get_extension(path)
            ext = ext.lower()
            if ext in File.NORMAL_EXT:

                return

            # use api
            """
            from tactic_client_lib import TacticServerStub
            server = TacticServerStub.get()
            snapshot = server.simple_checkin(search_key, "icon", path, mode="copy")
            """

            icon_creator = IconCreator(path)
            icon_creator.execute()

            web_path = icon_creator.get_web_path()
            icon_path = icon_creator.get_icon_path()
            if web_path and icon_path:
                sub_file_paths = [path, web_path, icon_path]
                sub_file_types = ['main', 'web', 'icon']

                from pyasm.checkin import FileCheckin
                checkin = FileCheckin(sobject, sub_file_paths, sub_file_types, context='icon', mode="copy")
                checkin.execute()
                snapshot = checkin.get_snapshot()

            # need the actual sobject to get the path to replace the icon
            # in the ui
            #snapshot = Search.get_by_search_key(snapshot.get("__search_key__"))


        my.path = snapshot.get_web_path_by_type("icon")