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


Python Environment.get_install_dir方法代码示例

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


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

示例1: generate

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_install_dir [as 别名]
    def generate(my, texts, font_sizes=15):
        if isinstance(texts, basestring):
            texts = [texts]

        if type(font_sizes) == types.IntType:
            font_sizes = [font_sizes]

        font_size = font_sizes[0]
            

        length = len(texts[0])
        width = int(font_size * 0.6 * length + 50)

        im = Image.new("RGBA", (width, 100))
        draw = ImageDraw.Draw(im)

        install_dir = Environment.get_install_dir()
        #/home/apache/tactic/src/pyasm/security/arial.ttf
        font_path = "%s/src/pyasm/security/arial.ttf" % install_dir
        for i, text in enumerate(texts):
            font = ImageFont.truetype(font_path, font_sizes[i])
            interval = int(font_size)
            offset = int(font_size/2)
            draw.text((20, i*interval), text, font=font, fill='#000')
            draw.text((20+offset, i*interval+offset), text, font=font, fill='#FFF')

                

        return im
开发者ID:blezek,项目名称:TACTIC,代码行数:31,代码来源:watermark.py

示例2: init

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

        self.search_type = self.kwargs.get('search_type')
        self.page_title = self.kwargs.get('page_title')
        self.use_short_search_type_label = (self.kwargs.get('use_short_search_type_label') in ['true','True','TRUE',True])

        self.html_template_dir = "%s/src/context/html_templates" % Environment.get_install_dir()
开发者ID:mincau,项目名称:TACTIC,代码行数:9,代码来源:print_layout_wdg.py

示例3: _get_template_config

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

        base_dir = Environment.get_install_dir()
        file_path="%s/src/config2/search_type/search/DEFAULT-conf.xml" % base_dir
        if os.path.exists(file_path):
            widget_config = WidgetConfig.get(file_path=file_path, view='template')
        return widget_config
开发者ID:mincau,项目名称:TACTIC,代码行数:9,代码来源:search_type_manager_wdg.py

示例4: filter_xml

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_install_dir [as 别名]
    def filter_xml(my, xml):
        dirname = os.path.dirname(my.rel_path)


        # filter images
        img_nodes = xml.get_nodes("//img")
        install_dir = Environment.get_install_dir()
        for node in img_nodes:
            src = xml.get_attribute(node, "src")

            if src.startswith("/tactic/plugins/"):
                plugin_dir = Environment.get_plugin_dir()
                path = "%s/%s" % (plugin_dir, src.replace("/tactic/plugins/", "") )
            elif src.startswith("/tactic/builtin_plugins/"):
                plugin_dir = Environment.get_builtin_plugin_dir()
                path = "%s/%s" % (plugin_dir, src.replace("/tactic/builtin_plugins/", "") )



            elif src.startswith("/"):
                path = "%s/src%s" % (install_dir, src)
            else:
                path = "%s/doc/%s/%s" % (install_dir, dirname, src)

            size = (0,0)
            try:
                from PIL import Image 
                im = Image.open(path)
                size = im.size
            except IOError, e:
                print "Error importing Image: ", e
                
            except:
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:35,代码来源:help_wdg.py

示例5: compact_javascript_files

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

    print " "
    print "Processing javascript files to compact into single '_compact_spt_all.js' file ..."
    print " "

    context_path = "%s/src/context" % Environment.get_install_dir()
    all_js_path = js_includes.get_compact_js_filepath()

    out_fp = open( all_js_path, "w" )

    for (dir, includes_list) in js_includes.all_lists:
        for include in includes_list:
            js_path = "%s/%s/%s" % (context_path, dir, include)
            print "    >> processing '%s' ..." % js_path
            out_fp.write( "// %s\n\n" % js_path )
            in_fp = open( js_path, "r" )
            done = False
            comment_flag = False
            while not done:
                line = in_fp.readline()
                if not line:
                    done = True
                    continue
                line = line.strip()
                if line.startswith("//"):
                    continue
                start_comment_idx = line.find( "/*" )
                if start_comment_idx != -1:
                    comment_flag = True
                    tmp_line = line[ : start_comment_idx ].strip()
                    if tmp_line:
                        out_fp.write( "%s\n" % tmp_line )
                if line.find( "*/" ) != -1:
                    comment_flag = False
                    tmp_line = line[ line.find("*/") + 2 : ].strip()
                    if tmp_line:
                        out_fp.write( "%s\n" % tmp_line )
                    continue

                if comment_flag:
                    continue

                line = line.strip()
                if line:
                    out_fp.write( "%s\n" % line )

            in_fp.close()
            out_fp.write( "\n\n" )

    out_fp.close()

    print " "
    print "Generated compact '%s' file." % all_js_path

    print " "
    print "DONE compacting javascript files into single file."
    print " "
开发者ID:0-T-0,项目名称:TACTIC,代码行数:60,代码来源:js_compactor.py

示例6: get_file_contents

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_install_dir [as 别名]
def get_file_contents(version_filename):
    env = Environment()
    install_dir = env.get_install_dir()
    path = '/src/client/tactic_client_lib'
    fullPath = install_dir + path + '/' + version_filename
    f = open(fullPath, 'r')
    version_string = f.read()
    f.close()
    return version_string
开发者ID:0-T-0,项目名称:TACTIC,代码行数:11,代码来源:set_version.py

示例7: execute

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

        # make sure tmp config is unset.
        Config.unset_tmp_config()
        Config.reload_config()

        web = WebContainer.get_web()

        # read the current config file.


        # copy config to the path
        config_path = Config.get_config_path()
        if not os.path.exists(config_path):
            print "Installing default config file"

            dirname = os.path.dirname(config_path)
            if not os.path.exists(dirname):
                os.makedirs(dirname)

            if os.name == 'nt':
                osname = 'win32'
            else:
                osname = 'linux'

            install_dir = Environment.get_install_dir()
            install_config_path = "%s/src/install/start/config/tactic_%s-conf.xml" % ( install_dir, osname)

            shutil.copy(install_config_path, dirname)

        try:
            self.configure_db()
            self.configure_install()
            self.configure_mail_services()
            self.configure_gen_services()
            self.configure_asset_dir()
            self.configure_palette()
            self.configure_security()
        except Exception as e:
            raise TacticException('Error in [%s]: %s'%(self.section, e.__str__()))
        # FIXME: if this all fails, then revert back
        
        self.save_config()

        # after saving the config, test the database
        self.load_bootstrap()

        # remove the first run file
        data_dir = Environment.get_data_dir()
        path = "%s/first_run" % data_dir
        if os.path.exists(path):
            os.unlink(path)


        self.restart_program()
开发者ID:mincau,项目名称:TACTIC,代码行数:58,代码来源:db_config_wdg.py

示例8: color_exists

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_install_dir [as 别名]
    def color_exists(color):
        # find the base path
        tactic_base = Environment.get_install_dir()
        basedir = "%s/src/context/ui_proto/roundcorners/rc_%s" % (tactic_base, color.replace("#", ""))
        # print "test for corner: ", color

        if os.path.exists(basedir):
            return True
        else:
            return False
开发者ID:hellios78,项目名称:TACTIC,代码行数:12,代码来源:corner_generator.py

示例9: get_display

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

示例10: print_file_location_msg

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_install_dir [as 别名]
def print_file_location_msg():
    env = Environment()
    install_dir = env.get_install_dir()
    print '  The version files are located here:'
    print '    %s/VERSION' % install_dir
    print '    %s/src/context/VERSION' % install_dir
    print '    %s/src/client/tactic_client_lib/VERSION' % install_dir
    print '    %s/src/pyasm/application/common/interpreter/tactic_client_lib/VERSION' % install_dir
    print ''
    print '  The client tactic.zip is located here:'
    print '    %s/src/client/tactic_client_lib/tactic.zip' % install_dir
开发者ID:0-T-0,项目名称:TACTIC,代码行数:13,代码来源:set_version.py

示例11: upgrade

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_install_dir [as 别名]
def upgrade():
    print "Running upgrade on 'sthpw' database"

    install_dir = Environment.get_install_dir()
    python = Config.get_value("services", "python")
    if not python:
        python = "python"

    cmd = "%s \"%s/src/bin/upgrade_db.py\" -f -y -p sthpw" % (python, install_dir)
    print cmd

    os.system(cmd)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:14,代码来源:bootstrap_load.py

示例12: generate

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_install_dir [as 别名]
    def generate(color):
        # find the base path
        tactic_base = Environment.get_install_dir()
        basedir = "%s/src/context/ui_proto/roundcorners/rc_%s" % (tactic_base, color.replace("#", ""))

        basename = "rc_%s_10x10" % color
        cmd = CornerGenerator(color=color, basedir=basedir, basename=basename)
        cmd.execute()

        basename = "rc_%s_5x5" % color
        cmd = CornerGenerator(color=color, basedir=basedir, basename=basename, size=5)
        cmd.execute()
开发者ID:hellios78,项目名称:TACTIC,代码行数:14,代码来源:corner_generator.py

示例13: init

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

        install_dir = Environment.get_install_dir()

        # initialize
        js = '''
        <!-- TACTIC -->
        // Fixes
        var spt = {};
        spt.browser = {};
        spt.browser.is_IE = function() { return false; }
        spt.error = function(error) {
            throw(error);
        }
        '''
        my.ctx.eval(js)
       
        sources = [
                "environment.js",
                "client_api.js"
        ]
        for source in sources: 
            #path = "tactic/%s" % source
            path = "%s/src/context/spt_js/%s" % (install_dir, source)
            js = open(path).read()
            my.ctx.eval(js)

        js = '''
spt._delegate = function(func_name, args, kwargs) {

    // convert everything to json
    var args2 = [];
    for (var i in args) {
        args2.push(args[i]);
    }

    if (typeof(kwargs) == "undefined") {
        kwargs = {};
    }

    args2 = JSON.stringify(args2);
    kwargs = JSON.stringify(kwargs);

    var ret_val = spt_delegator.execute(func_name, args2, kwargs);
    ret_val = JSON.parse(ret_val);
    return ret_val;

}

var server = TacticServerStub.get();
        '''
        my.ctx.eval(js)
开发者ID:nuxping,项目名称:TACTIC,代码行数:54,代码来源:js_wrapper.py

示例14: execute

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


        # make sure tmp config is unset.
        Config.unset_tmp_config()
        Config.reload_config()

        web = WebContainer.get_web()

        # read the current config file.


        # copy config to the path
        config_path = Config.get_config_path()
        if not os.path.exists(config_path):
            print "Installing default config file"

            dirname = os.path.dirname(config_path)
            if not os.path.exists(dirname):
                os.makedirs(dirname)

            if os.name == 'nt':
                osname = 'win32'
            else:
                osname = 'linux'

            install_dir = Environment.get_install_dir()
            install_config_path = "%s/src/install/start/config/tactic_%s-conf.xml" % ( install_dir, osname)

            shutil.copy(install_config_path, dirname)

        my.configure_db()
        my.configure_install()
        my.configure_services()
        my.configure_asset_dir()
        my.configure_palette()
        # FIXME: if this all fails, then revert back
        my.save_config()

        # after saving the config, test the database
        my.load_bootstrap()

        # remove the first run file
        data_dir = Environment.get_data_dir()
        path = "%s/first_run" % data_dir
        if os.path.exists(path):
            os.unlink(path)


        my.restart_program()
开发者ID:blezek,项目名称:TACTIC,代码行数:52,代码来源:db_config_wdg.py

示例15: upgrade

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import get_install_dir [as 别名]
def upgrade():
    print "Running upgrade on 'sthpw' database"

    install_dir = Environment.get_install_dir()
    from pyasm.common import Config

    python = Config.get_value("services", "python")
    if not python:
        python = "python"

    cmd = '%s "%s/src/bin/upgrade_db.py" -f -y -p sthpw' % (python, install_dir)
    print cmd

    os.system(cmd)
开发者ID:pombredanne,项目名称:TACTIC,代码行数:16,代码来源:bootstrap_load.py


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