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


Python Environment.get_asset_dir方法代码示例

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


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

示例1: get_file_paths

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def get_file_paths(my, transaction, mode='lib'):

        transaction_xml = transaction.get_xml_value("transaction")
        if not transaction_xml:
            return []

        from pyasm.common import Xml, Environment

        if isinstance(transaction_xml, basestring):
            xml = Xml()
            xml.read_string(transaction_xml)
        else:
            xml = transaction_xml


        base_dir = Environment.get_asset_dir()
        paths = []


        # get all of the file nodes
        nodes = xml.get_nodes("transaction/file")
        for node in nodes:

            if xml.get_attribute(node, "type") == 'create':
                src = xml.get_attribute(node, "src")

                if mode == 'relative':
                    path = src
                else:
                    path = "%s/%s" % (base_dir, src)
                paths.append(path)

        return paths
开发者ID:0-T-0,项目名称:TACTIC,代码行数:35,代码来源:sync_utils.py

示例2: add_file_behaviors

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def add_file_behaviors(self, item_div, dirname, basename):
        """
        item_div.add_behavior( {
        'type': 'click_up',
        'dirname': dirname,
        'basename': basename,
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_repo_browser_top");
        var content = top.getElement(".spt_repo_browser_content");
        var class_name = "tactic.ui.tools.repo_browser_wdg.RepoBrowserContentWdg";
        var kwargs = {
          dirname: bvr.dirname,
          basename: bvr.basename
        };
        spt.panel.load(content, class_name, kwargs);
        '''
        } )
        """

        # convert this to a repo directory
        asset_dir = Environment.get_asset_dir()


        # FIXME: not sure how general this
        webdirname = "/assets/%s" % dirname.replace(asset_dir, "")

        item_div.add_behavior( {
        'type': 'click_up',
        'webdirname': webdirname,
        'basename': basename,
        'cbjs_action': '''
        window.open(bvr.webdirname + "/" + bvr.basename, '_blank');
        '''
        } )
开发者ID:mincau,项目名称:TACTIC,代码行数:36,代码来源:dependency_wdg.py

示例3: execute

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def execute(my):
        filename = my.kwargs.get("filename")
        ticket = my.kwargs.get("ticket")
        upload_dir = Environment.get_upload_dir(ticket=ticket)
        # can't rely on that
        #ticket = Environment.get_ticket()
        asset_temp_dir = "%s/temp/%s" % (Environment.get_asset_dir(), ticket)

        if not os.path.exists(asset_temp_dir):
            os.makedirs(asset_temp_dir)

        from_path = "%s/%s" % (upload_dir, filename)
        icon_creator = IconCreator(from_path)
        icon_creator.execute()
        icon_path = icon_creator.get_icon_path()

        to_path = "%s/%s" % (asset_temp_dir, filename)
        
        if icon_path:
            shutil.copy(icon_path, to_path)
            my.info = {
                "web_path": "/assets/temp/%s/%s" % (ticket, filename),
                "lib_path": to_path
            }
        else:
            my.info = {}
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:28,代码来源:create_project_cmd.py

示例4: delete_sobject

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def delete_sobject(my, sobject):

        search_type = sobject.get_base_search_type()

        # this is used by API method delete_sobject
        auto_discover = my.kwargs.get("auto_discover")
        
        values = my.kwargs.get("values")
        if values:
            related_types = values.get("related_types")
        elif auto_discover:
            related_types = SearchType.get_related_types(search_type, direction="children")
        else:
            related_types = None

        # always delete notes and task and snapshot
        #if not related_types:
        #    related_types = ['sthpw/note', 'sthpw/task', 'sthpw/snapshot']
        #related_types = my.schema.get_related_search_types(search_type)
        if related_types:
            for related_type in related_types:
                if not related_type or related_type == search_type:
                    continue

                # snapshots take care of sthpw/file in the proper manner, so
                # skip them here
                if related_type == 'sthpw/file':
                    continue

                related_sobjects = sobject.get_related_sobjects(related_type)
                for related_sobject in related_sobjects:
                    if related_type == 'sthpw/snapshot':
                        my.delete_snapshot(related_sobject)
                    else:
                        related_sobject.delete()


        # implicitly remove "directory" files associated with the sobject
        search = Search("sthpw/file")
        search.add_op("begin")
        search.add_filter("file_name", "")
        search.add_null_filter("file_name")
        search.add_op("or")
        search.add_parent_filter(sobject)
        file_objects = search.get_sobjects()
        for file_object in file_objects:
            base_dir = Environment.get_asset_dir()
            relative_dir = file_object.get("relative_dir")
            lib_dir = "%s/%s" % (base_dir, relative_dir)
            print "removing: ", lib_dir
            FileUndo.rmdir(lib_dir)
            file_object.delete()


        # finally delete the sobject
        print "deleting: ", sobject.get_search_key()
        if search_type == 'sthpw/snapshot':
            my.delete_snapshot(sobject)
        else:
            sobject.delete()
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:62,代码来源:delete_wdg.py

示例5: get_preallocated_dir

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
 def get_preallocated_dir(my):
     preallocated = my.snapshot.get_preallocated_path(file_type='maya', file_name='what.ma',ext='ma')
     preallocated_dir_name = os.path.dirname(preallocated)
     preallocated_dir_name = preallocated_dir_name.replace('%s/' %Environment.get_asset_dir(), '')
     # remove the base part
     preallocated_dir_names = preallocated_dir_name.split('/')
     
     preallocated_dir_name = '/'.join(preallocated_dir_names)
     return preallocated_dir_name
开发者ID:0-T-0,项目名称:TACTIC,代码行数:11,代码来源:naming_test.py

示例6: get_display

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def get_display(my):

        alias = my.kwargs.get("alias")

        my.rel_path = my.kwargs.get("rel_path")
        if not my.rel_path:
            from tactic_client_lib import TacticServerStub

            server = TacticServerStub.get(protocol="local")
            my.rel_path = server.get_doc_link(alias)

        if not my.rel_path or my.rel_path == "none_found":
            # raise TacticException("Help alias [%s] does not exist" % alias)
            layout = DivWdg()
            layout.add(HelpCreateWdg(alias=alias))
            layout.add(HelpDocFilterWdg(alias="main"))
            return layout

        # special condition for plugins path
        if my.rel_path.startswith("/plugins/"):
            plugin_dir = Environment.get_plugin_dir()
            rel_path = my.rel_path.replace("/plugins/", "")
            path = "%s/%s" % (plugin_dir, rel_path)
        elif my.rel_path.startswith("/builtin_plugins/"):
            plugin_dir = Environment.get_builtin_plugin_dir()
            rel_path = my.rel_path.replace("/builtin_plugins/", "")
            path = "%s/%s" % (plugin_dir, rel_path)
        elif my.rel_path.startswith("/assets/"):
            asset_dir = Environment.get_asset_dir()
            rel_path = my.rel_path.replace("/assets/", "")
            path = "%s/%s" % (asset_dir, rel_path)
        else:

            # see if there is an override
            doc_dir = os.environ.get("TACTIC_DOC_DIR")
            if not doc_dir:
                doc_dir = Config.get_value("install", "doc_dir")
            if not doc_dir:
                install_dir = Environment.get_install_dir()
                doc_dir = "%s/doc" % install_dir

            path = "%s/%s" % (doc_dir, my.rel_path)

        html = []
        try:
            f = open(path, "r")
            count = 0
            for line in f:
                line = my.filter_line(line, count)
                html.append(line)
                count += 1
            f.close()
        except Exception, e:
            print "Error processing: ", e
            html.append("Error processing document: %s<br/><br/>" % str(e))
开发者ID:hellios78,项目名称:TACTIC,代码行数:57,代码来源:help_wdg.py

示例7: do_delete

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def do_delete(self, sobject, related_types=None):

        search_type = sobject.get_base_search_type()

        # always delete notes and task and snapshot
        if not related_types:
            related_types = ['sthpw/note', 'sthpw/task', 'sthpw/snapshot']
        #related_types = self.schema.get_related_search_types(search_type)

        if related_types:
            for related_type in related_types:
                if not related_type or related_type == search_type:
                    continue

                # snapshots take care of sthpw/file in the proper manner, so
                # skip them here
                if related_type == 'sthpw/file':
                    continue

                related_sobjects = sobject.get_related_sobjects(related_type)
                for related_sobject in related_sobjects:
                    if related_type == 'sthpw/snapshot':
                        self.delete_snapshot(related_sobject)
                    else:
                        related_sobject.delete()
                        #self.do_delete(related_sobject)


        # implicitly remove "directory" files associated with the sobject
        search = Search("sthpw/file")
        search.add_op("begin")
        search.add_filter("file_name", "")
        search.add_null_filter("file_name")
        search.add_op("or")
        search.add_parent_filter(sobject)
        file_objects = search.get_sobjects()

        #if file_objects:
        #    print("Removing [%s] file objects" % len(file_objects))

        for file_object in file_objects:
            base_dir = Environment.get_asset_dir()
            relative_dir = file_object.get("relative_dir")
            lib_dir = "%s/%s" % (base_dir, relative_dir)
            FileUndo.rmdir(lib_dir)
            file_object.delete()


        # finally delete the sobject
        print("Deleting: ", sobject.get_search_key())
        if search_type == 'sthpw/snapshot':
            self.delete_snapshot(sobject)
        else:
            sobject.delete()
开发者ID:mincau,项目名称:TACTIC,代码行数:56,代码来源:delete_wdg.py

示例8: get_by_path

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def get_by_path(path):
        asset_dir = Environment.get_asset_dir()
        path = path.replace("%s/" % asset_dir, "")
        relative_dir = os.path.dirname(path)
        file_name = os.path.basename(path)

        # NOTE: this does not work with base_dir_alias

        search = Search("sthpw/file")
        search.add_filter("relative_dir", relative_dir)
        search.add_filter("file_name", file_name)
        sobject = search.get_sobject()
        return sobject
开发者ID:mincau,项目名称:TACTIC,代码行数:15,代码来源:file.py

示例9: get_display

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def get_display(my):

        paths = my.get_files()

        top = my.top
        top.add_style("padding: 10px")
        top.add_color("background", "background", -5)
        top.add_style("min-width: 500px")
        top.add_style("font-size: 12px")
        top.add_class("spt_sobject_dir_list_top")
        my.set_as_panel(top)

        inner = DivWdg()
        top.add(inner)


        show_title = my.kwargs.get("show_title")
        if show_title not in [False, 'false']:
            title_wdg = DivWdg()
            inner.add(title_wdg)
            title_wdg.add("File Browser [%s]" % my.sobject.get_code())
            title_wdg.add_gradient("background", "background3")
            title_wdg.add_style("padding: 5px")
            title_wdg.add_style("margin: -10px -10px 10px -10px")
            title_wdg.add_style("font-weight: bold")

        show_shelf = my.kwargs.get("show_shelf")
        if show_shelf not in [False, 'false']:
            shelf_wdg = DivWdg()
            inner.add(shelf_wdg)
            shelf_wdg.add(my.get_shelf_wdg())
            shelf_wdg.add_style("padding: 5px")
            shelf_wdg.add_style("margin: -5px -5px 15px -5px")
            shelf_wdg.add_style("font-weight: bold")




        base_dir = Environment.get_asset_dir()

        dir_list = SnapshotDirListWdg(base_dir=base_dir, location="server", show_base_dir=True,paths=paths, all_open=True, files=my.files, snapshots=my.snapshots)

        inner.add(dir_list)


        if my.kwargs.get("is_refresh"):
            return inner
        else:
            return top
开发者ID:blezek,项目名称:TACTIC,代码行数:51,代码来源:snapshot_files_wdg.py

示例10: download_transaction_files

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def download_transaction_files(self, transactions):
        '''This uses a simple httpd download mechanism to get the files.
        '''

        remote_host = sync_utils.get_remote_host()

        download_mode = 'http'

        # Try a mode where files are zipped
        if download_mode == 'zip':
            remote_server.download_zip(paths)



        # go through each transaction and look at the files
        for transaction in transactions:
            transaction_xml = transaction.get("transaction")
            cmd = TransactionFilesCmd(transaction_xml=transaction_xml, mode='relative')
            paths = cmd.execute()


            # download to the temp dir
            to_dir = Environment.get_tmp_dir()
            ticket = Environment.get_ticket()
            to_dir = "%s/%s" % (to_dir, ticket)

            # or we could download directly to that asset directory
            base_dir = Environment.get_asset_dir()

            # do the slow method
            for path in paths:
                url = "%s/assets/%s" % (remote_host, path)

                print("downloading: ", url)
                remote_server.download(url, to_dir)

                # FIXME: the problem with this is that it is not undoable
                #dirname = os.path.dirname(path)
                #to_dir = "%s/%s" % (base_dir, dirname)
                #print("to_dir: ", to_dir)


                remote_server.download(url, to_dir)
开发者ID:mincau,项目名称:TACTIC,代码行数:45,代码来源:run_transaction_cmd.py

示例11: execute

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def execute(self):

        mode = self.kwargs.get('mode')
        if not mode:
            mode = 'lib'


        transaction_xml = self.kwargs.get("transaction_xml")
        assert(transaction_xml)

        from pyasm.common import Xml, Environment

        if isinstance(transaction_xml, basestring):
            xml = Xml()
            xml.read_string(transaction_xml)
        else:
            xml = transaction_xml


        base_dir = Environment.get_asset_dir()
        paths = []


        # get all of the file nodes
        nodes = xml.get_nodes("transaction/file")
        for node in nodes:

            if xml.get_attribute(node, "type") == 'create':
                src = xml.get_attribute(node, "src")

                if mode == 'relative':
                    path = src
                else:
                    if src.startswith(base_dir):
                        path = src
                    else:
                        path = "%s/%s" % (base_dir, src)
                paths.append(path)

        return paths
开发者ID:mincau,项目名称:TACTIC,代码行数:42,代码来源:run_transaction_cmd.py

示例12: execute

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

        template_dir = Environment.get_template_dir()

        # find the 
        template_dir = my.kwargs.get("template_dir")
        if not template_dir:
            return


        path = None

        template_name = os.path.basename(template_dir)
        template_dir = os.path.dirname(template_dir)

        filenames = os.listdir(template_dir)
        for filename in filenames:
            if not filename.endswith(".zip"):
                continue

            if filename.startswith(template_name):
                path = "%s/%s" % (template_dir, filename)
                break

        if not path:
            return


        asset_dir = Environment.get_asset_dir()

        ticket = Environment.get_ticket()
        cache_dir = "%s/_cache/%s" % (asset_dir, ticket)

        if not os.path.exists(cache_dir):
            os.makedirs(cache_dir)

        shutil.copy(path, cache_dir)

        my.info["filename"] = filename
开发者ID:0-T-0,项目名称:TACTIC,代码行数:41,代码来源:project_template_wdg.py

示例13: get_display

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def get_display(my):

        top = my.top
        top.add_style("padding: 10px")
        top.add_color("background", "background", -5)
        top.add_style("min-width: 600px")

        paths = my.get_files()

       
        # assume that all the paths are part of the same repo
        repo = 'tactic'
        for file in my.files.values():
            repo = file.get_value("repo_type", no_exception=True)
            break

        if repo == 'perforce':
            search_key = my.kwargs.get("search_key")
            sobject = SearchKey.get_by_search_key(search_key)
     
            project = sobject.get_project()
            depot = project.get_value("location", no_exception=True)
            if not depot:
                depot = project.get_code()
            location = '//%s' % depot

            dir_list = SnapshotDirListWdg(base_dir=location, location="scm", show_base_dir=True,paths=paths, all_open=True, files=my.files, snapshots=my.snapshots) 
        else:
            # If not discovered thru base_dir_alias, use the default
            if not my.base_dir:
                my.base_dir = Environment.get_asset_dir()
            
            dir_list = SnapshotDirListWdg(base_dir=my.base_dir, location="server", show_base_dir=True,paths=paths, all_open=True, files=my.files, snapshots=my.snapshots)

        top.add(dir_list)


        return top
开发者ID:asmboom,项目名称:TACTIC,代码行数:40,代码来源:snapshot_files_wdg.py

示例14: get_files

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def get_files(my):

        paths = []

        # remember this here for now
        my.files = {}
        my.snapshots = {}


        search_key = my.kwargs.get("search_key")
        sobject = SearchKey.get_by_search_key(search_key)
        # if it is deleted, return
        if not sobject:
            return []
    
        if isinstance(sobject, Snapshot):
            snapshots = [sobject]
        else:
            snapshots = Snapshot.get_by_sobject(sobject, "publish")

        for snapshot in snapshots:
            snapshot_paths = snapshot.get_all_lib_paths()

            files = snapshot.get_all_file_objects()

            for path, file in zip(snapshot_paths, files):

                # if the path is a directory, get all of the files
                if os.path.isdir(path):
                    for root, dirnames, filenames in os.walk(path):

                        for filename in filenames:
                            item_path = "%s/%s" % (root, filename)
                            paths.append(item_path)
                            my.files[item_path] = file
                            my.snapshots[item_path] = snapshot

                        for dirname in dirnames:
                            item_path = "%s/%s/" % (root, dirname)
                            paths.append(item_path)
                            my.files[item_path] = file
                            my.snapshots[item_path] = snapshot


                    """
                    dirlist = os.listdir(path)
                    for item in dirlist:
                        item_path = "%s%s" % (path, item)
                        if os.path.isdir(path):
                            item_path = "%s/" % item_path
                        paths.append(item_path)
                        my.files[path] = file
                    """

                else:
                    paths.append(path)
                    my.files[path] = file
                    base_dir_alias =  file.get_value('base_dir_alias')
                    if not my.base_dir and base_dir_alias:
                        my.base_dir = Environment.get_asset_dir(alias=base_dir_alias)

        return paths
开发者ID:asmboom,项目名称:TACTIC,代码行数:64,代码来源:snapshot_files_wdg.py

示例15: add_top_behaviors

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_asset_dir [as 别名]
    def add_top_behaviors(my, top):

        # convert this to a repo directory
        asset_dir = Environment.get_asset_dir()

        # FIXME: not sure how general this
        #webdirname = "/assets/%s" % dirname.replace(asset_dir, "")

        web = WebContainer.get_web()
        browser = web.get_browser()


        if browser == 'Qt':
            top.add_relay_behavior( {
            'type': 'dblclick',
            'bvr_match_class': 'spt_dir_list_item',
            'cbjs_action': '''
            var path = bvr.src_el.getAttribute("spt_path");
            var asset_dir = '%s';
            var url = "/assets/" + path.replace(asset_dir, "");
            //window.open(url);

            var url_parts = url.split("/");
            var file = url_parts.pop();
            file = encodeURIComponent(file);
            url_parts.push(file);
            url = url_parts.join("/");

            var class_name = 'tactic.ui.widget.EmbedWdg';
            var kwargs = {
                src: url
            }

            var parts = path.split("/");
            var filename = parts[parts.length-1];
            spt.tab.set_main_body_tab()
            spt.tab.add_new(filename, filename, class_name, kwargs);
            ''' % asset_dir
            } )
        else:
            top.add_relay_behavior( {
            'type': 'dblclick',
            'bvr_match_class': 'spt_dir_list_item',
            'cbjs_action': '''
            var path = bvr.src_el.getAttribute("spt_path");
            
            if (path.indexOf('####') != -1) {
                spt.info('Cannot open the file sequence');
            } 
            else {
            var asset_dir = '%s';
            var url = "/assets/" + path.replace(asset_dir, "");

            var url_parts = url.split("/");
            var filename = url_parts.pop();
            filename = encodeURIComponent(filename);
            url_parts.push(filename);
            url = url_parts.join("/");

            window.open(url);
            }
            ''' % asset_dir
            } )

        # add a top menu
        menu = Menu(width=180)
        menu_item = MenuItem(type='title', label='Actions')
        menu.add(menu_item)

        menu_item = MenuItem(type='action', label='Download to Folder')
        menu.add(menu_item)
        menu_item.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
            var activator = spt.smenu.get_activator(bvr);
            var applet = spt.Applet.get();
            var select_dir = true;
            var dir = applet.open_file_browser('', select_dir);
            if (!dir) {
                dir = applet.get_current_dir();
            }
            if (!dir) {
                spt.alert("No folder selected to copy to");
                return;
            }
            
            var path = activator.getAttribute("spt_path");

            var asset_dir = '%s';
            var env = spt.Environment.get();
            var server_url = env.get_server_url();
            var url = server_url + "/assets/" + path.replace(asset_dir, "");
            var parts = path.split("/");
            var filename = parts[parts.length-1];
            spt.app_busy.show("Downloading file", filename);
            applet.download_file(url, dir + "/" + filename);
            spt.app_busy.hide();
            if (dir)
                spt.notify.show_message("Download to '" + dir + "' completed.")
            ''' % asset_dir
#.........这里部分代码省略.........
开发者ID:asmboom,项目名称:TACTIC,代码行数:103,代码来源:snapshot_files_wdg.py


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