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


Python Environment.get_dist_dir方法代码示例

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


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

示例1: setup_sites

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

        context_path = "%s/src/context" % my.install_dir
        doc_dir = "%s/doc" % my.install_dir
        plugin_dir = Environment.get_plugin_dir()
        builtin_plugin_dir = Environment.get_builtin_plugin_dir()
        dist_dir = Environment.get_dist_dir()

        log_dir = "%s/log" % Environment.get_tmp_dir()



        def CORS():
            #cherrypy.response.headers["Access-Control-Allow-Origin"] = "http://192.168.0.15:8100"
            cherrypy.response.headers["Access-Control-Allow-Origin"] = "*"
            cherrypy.response.headers["Access-Control-Allow-Headers"] = "Origin, X-Requested-With, Content-Type, Accept"
        cherrypy.tools.CORS = cherrypy.Tool('before_handler', CORS)


        config = {
            
            'global': {
                'server.socket_host': '127.0.0.1',
                'server.socket_port': 80,
                'log.screen': False,
                'request.show_tracebacks': True,
                'tools.log_headers.on': True,
                'server.log_file': "%s/tactic_log" % log_dir,
                'server.max_request_body_size': 0,
                #'server.socket_timeout': 60,
                'response.timeout': 3600,

                'tools.encode.on': True,
                'tools.encode.encoding': 'utf-8',
                'tools.decode.on': True,
                'tools.decode.encoding': 'utf-8',
                #'encoding_filter.on': True,
                #'decoding_filter.on': True
                'tools.CORS.on': True

                },
            '/context': {'tools.staticdir.on': True,
                         'tools.staticdir.dir': context_path,
                         # Need to do this because on windows servers, jar files
                         # are served as text/html
                         'tools.staticdir.content_types': {
                             'jar': 'application/java-archive'
                         }
                        },
            '/assets':  {'tools.staticdir.on': True,
                         'tools.staticdir.dir': Environment.get_asset_dir()
                        },
            '/doc':     {'tools.staticdir.on': True,
                         'tools.staticdir.dir': doc_dir,
                         'tools.staticdir.index': "index.html"
                        },
            # NOTE: expose the entire plugins directory
            '/tactic/plugins': {
                         'tools.staticdir.on': True,
                         'tools.staticdir.dir': plugin_dir,
                        },
            '/tactic/builtin_plugins': {
                         'tools.staticdir.on': True,
                         'tools.staticdir.dir': builtin_plugin_dir,
                        },
            '/tactic/dist': {
                        'tools.staticdir.on': True,
                        'tools.staticdir.dir': dist_dir,
                        },
             '/plugins': {
                         'tools.staticdir.on': True,
                         'tools.staticdir.dir': plugin_dir,
                        },
            '/builtin_plugins': {
                         'tools.staticdir.on': True,
                         'tools.staticdir.dir': builtin_plugin_dir,
                        },
            '/dist': {
                        'tools.staticdir.on': True,
                        'tools.staticdir.dir': dist_dir,
                        },
 

 

        }


        # set up the root directory
        cherrypy.root = Root()
        cherrypy.tree.mount( cherrypy.root, config=config)



        from pyasm.search import Search
        search = Search("sthpw/project")
        search.add_filter("type", "resource", op="!=")
        projects = search.get_sobjects()


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

示例2: execute

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

        force = my.kwargs.get("force")
        clean = my.kwargs.get("clean")
        if clean in [False, 'false']:
            clean = False

        # ensure that plugin dir is empty
        if os.path.exists(my.plugin_dir):
            if clean:
                if force in ['true', True]:
                    shutil.rmtree(my.plugin_dir)
                else:
                    raise Exception("Plugin is already located at [%s]" % my.plugin_dir)
       
        
        if not os.path.exists(my.plugin_dir):
            os.makedirs(my.plugin_dir)


        # build the information from the manifest

        code = my.kwargs.get("code")
        if not code:
            code = my.xml.get_value("manifest/@code")

        version = my.kwargs.get("version")
        if not version:
            version = my.xml.get_value("manifest/@version")

        nodes = my.xml.get_nodes("manifest/*")


        # clean out all of the files
        my.delete_files(nodes)


        has_info = False
        sobjects = []

        # handle all of the nodes in the manifest
        for i, node in enumerate(nodes):
            name = my.xml.get_node_name(node)
            if name == 'sobject':
                dumped_sobjects = my.handle_sobject(node)
                if not dumped_sobjects:
                    dumped_sobjects = []
                sobjects.extend(dumped_sobjects)
            elif name == 'search_type':
                my.handle_search_type(node)
            elif name == 'include':
                my.handle_include(node)
            elif name == 'python':
                my.handle_python(node)


        # make sure there is a data node and handle it
        data_node = my.xml.get_node("manifest/data")
        if data_node is None:
            root_node = my.xml.get_root_node()
            data_node = my.xml.create_element("data")
            child = my.xml.get_first_child(root_node)
            if child is None:
                my.xml.append_child(root_node, data_node)
            else:
                my.xml.insert_before(data_node, child)

        my.handle_data(data_node)
            
 



        manifest_path = "%s/manifest.xml" % (my.plugin_dir)
        file = codecs.getwriter('utf8')(open(manifest_path, 'wb'))
        file.write(my.xml.to_string())
        file.close()

        # FIXME: leaving this out for now
        #my.handle_snapshots()

        dist_dir = my.kwargs.get("dist_dir")
        if not dist_dir:
            dist_dir = Environment.get_dist_dir()

        # get the basename of the code
        basecode = os.path.basename(my.code)

        # zip up the contents
        import zipfile
        if version:
            zip_path = "%s/%s-%s.zip" % (dist_dir, basecode, version)
        else:
            zip_path = "%s/%s.zip" % (dist_dir, basecode)

        print "Zipping up plugin file [%s]" % zip_path
        print "    from [%s]" % my.plugin_dir
        from pyasm.common import ZipUtil
        ignore_dirs = ['.svn']

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

示例3:

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_dist_dir [as 别名]


        # check that the main directories exists
        install_dir = os.getenv("TACTIC_INSTALL_DIR")
        data_dir = os.getenv("TACTIC_DATA_DIR")
        if not os.path.exists(install_dir):
            print "Environment variable TACTIC_INSTALL_DIR '%s' does not exist" % install_dir
            return
        if not os.path.exists(data_dir):
            print "Environment variable TACTIC_DATA_DIR '%s' does not exist" % data_dir
            return


        # create the dist folder
        dist_dir = Environment.get_dist_dir()
        if not os.path.exists(dist_dir):
            os.makedirs(dist_dir)




        self.create_temp_directory()

        self.change_directory_ownership()

        self.install_win32_service()


        if install_db == False:
            print "TACTIC setup successful.  Next, the TACTIC database needs to be configured."
开发者ID:mincau,项目名称:TACTIC,代码行数:32,代码来源:install.py

示例4: __init__

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_dist_dir [as 别名]
    def __init__(my, **kwargs):
        super(PluginBase,my).__init__(**kwargs)

        # plugin sobject (Not really used anymore?)
        my.search_key = my.kwargs.get("search_key")

        zip_path = my.kwargs.get("zip_path")
        upload_file_name = my.kwargs.get("upload_file_name")

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

        my.plugin_dir = my.kwargs.get("plugin_dir")
        my.manifest = my.kwargs.get("manifest")
        my.code = my.kwargs.get("code")
        my.version = my.kwargs.get("version")

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

        my.verbose = my.kwargs.get("verbose") not in [False, 'false']
        # at the end of this, the following variables are needed in order to
        # define the plugin
        #
        #   version: the version of the plugin
        #   plugin_dir: the directory where the plugin definition is located
        #   manifest: the description of what is in the plugin

        if zip_path:

            # assume the zip path is the same as the basename
            basename = os.path.basename(zip_path)
            basename, ext = os.path.splitext(basename)
            assert ext == '.zip'

            tmp_dir = Environment.get_tmp_dir()

            unzip_dir = "%s/%s" % (tmp_dir, basename)
            if os.path.exists(unzip_dir):
               shutil.rmtree(unzip_dir)


            # unzip the file in to the tmp_dir or plugin_dir (for install)
            zip_util = ZipUtil()
            zip_util.extract(zip_path, base_dir=tmp_dir)


            # assume zip path
            my.plugin_dir, ext = os.path.splitext(zip_path)

            # mv from temp
            if my.plugin_dir != unzip_dir:
                if os.path.exists(my.plugin_dir):
                    shutil.rmtree(my.plugin_dir)
                shutil.move(unzip_dir, my.plugin_dir)

            manifest_path = "%s/manifest.xml" % my.plugin_dir
            f = open(manifest_path, 'r')
            my.manifest = f.read()
            f.close()


        elif upload_file_name:
            # The path is moved to the plugin dir, if this process is taking
            # "local" file (such as one uploaded)
            upload_dir = Environment.get_upload_dir()
            upload_path = "%s/%s" % (upload_dir, upload_file_name)
            plugin_base_dir = Environment.get_plugin_dir()
            dist_dir = Environment.get_dist_dir()
            if not os.path.exists(dist_dir):
                os.makedirs(dist_dir)

            basename = os.path.basename(upload_path)
            #if os.path.exists("%s/%s" % (plugin_base_dir, basename)):
            #    os.unlink("%s/%s" % (plugin_base_dir, basename) )
            #shutil.move(upload_path, plugin_base_dir)


            # copy to dist folder
            if os.path.exists("%s/%s" % (dist_dir, basename)):
                os.unlink("%s/%s" % (dist_dir, basename) )
            shutil.move(upload_path, dist_dir)

            zip_path = "%s/%s" % (dist_dir, upload_file_name)

            zip_util = ZipUtil()
            zip_util.extract(zip_path, base_dir=plugin_base_dir)

            my.plugin_dir = "%s/%s" % (plugin_base_dir, basename)
            my.plugin_dir = my.plugin_dir[:-4]
            manifest_path = "%s/manifest.xml" % (my.plugin_dir)

            if os.path.exists(manifest_path):
                f = open(manifest_path, 'r')
                my.manifest = f.read()
                f.close()
            else:
                # when uploading, this will likely not be needed
                my.manifest = "<manifest/>"
                return


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

示例5: setup_sites

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

        context_path = "%s/src/context" % my.install_dir
        doc_dir = "%s/doc" % my.install_dir
        plugin_dir = Environment.get_plugin_dir()
        builtin_plugin_dir = Environment.get_builtin_plugin_dir()
        dist_dir = Environment.get_dist_dir()

        log_dir = "%s/log" % Environment.get_tmp_dir()

        config = {
            
            'global': {
                'server.socket_host': '127.0.0.1',
                'server.socket_port': 80,
                'log.screen': False,
                'request.show_tracebacks': True,
                'tools.log_headers.on': True,
                'server.log_file': "%s/tactic_log" % log_dir,
                'server.max_request_body_size': 0,
                #'server.socket_timeout': 60,
                'response.timeout': 3600,

                'tools.encode.on': True,
                'tools.encode.encoding': 'utf-8',
                'tools.decode.on': True,
                'tools.decode.encoding': 'utf-8',
                #'encoding_filter.on': True,
                #'decoding_filter.on': True
            }
            ,
            '/context': {'tools.staticdir.on': True,
                         'tools.staticdir.dir': context_path,
                         # Need to do this because on windows servers, jar files
                         # are served as text/html
                         'tools.staticdir.content_types': {
                             'jar': 'application/java-archive'
                         }
                        },
            '/assets':  {'tools.staticdir.on': True,
                         'tools.staticdir.dir': Environment.get_asset_dir()
                        },
            '/doc':     {'tools.staticdir.on': True,
                         'tools.staticdir.dir': doc_dir,
                         'tools.staticdir.index': "index.html"
                        },
            # NOTE: expose the entire plugins directory
            '/tactic/plugins': {
                         'tools.staticdir.on': True,
                         'tools.staticdir.dir': plugin_dir,
                        },
            '/tactic/builtin_plugins': {
                         'tools.staticdir.on': True,
                         'tools.staticdir.dir': builtin_plugin_dir,
                        },
            '/tactic/dist': {
                        'tools.staticdir.on': True,
                        'tools.staticdir.dir': dist_dir,
                        }
 

        }

      

        # set up the root directory
        cherrypy.root = Root()
        cherrypy.tree.mount( cherrypy.root, config=config)



        from pyasm.search import Search
        search = Search("sthpw/project")
        search.add_filter("type", "resource", op="!=")
        projects = search.get_sobjects()


        # find out if one of the projects is the root
        root_initialized = False
        """
        for project in projects:
            project_code = project.get_code()
            if False:
                from tactic.ui.app import SitePage
                cherrypy.root.tactic = SitePage(project_code)
                cherrypy.root.projects = SitePage(project_code)
                root_initialized = True
                break
        """

        if not root_initialized:
            project_code = Project.get_default_project()
            if project_code and project_code !='default':
                from tactic.ui.app import SitePage
                cherrypy.root.tactic = SitePage(project_code)
                cherrypy.root.projects = SitePage(project_code)
                root_initialized = True


        if not root_initialized:
#.........这里部分代码省略.........
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:103,代码来源:cherrypy30_startup.py


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