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


Python common.Environment类代码示例

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


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

示例1: get_display

    def get_display(my):

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()
        js_url = "%s/javascript" % context_url
        spt_js_url = "%s/spt_js" % context_url    # adding new core "spt" javascript library folder

        version = Environment.get_release_version()

        # add some third party libraries
        third_party = js_includes.third_party
        security = Environment.get_security()

        # FIXME: this logic should not be located here.
        # no reason to have the edit_area_full.js
        if not security.check_access("builtin", "view_script_editor", "allow") and security.check_access("builtin", "view_site_admin", "allow"):
            if "edit_area/edit_area_full.js" in third_party:
                third_party.remove("edit_area/edit_area_full.js")


        for include in js_includes.third_party:
            Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

        all_js_path = js_includes.get_compact_js_filepath()

        if os.path.exists( all_js_path ):
            Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix()))
        else:
            for include in js_includes.legacy_core:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))

            for include in js_includes.spt_js:
                Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

            for include in js_includes.legacy_app:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))


        #Container.append_seq("Page:js", "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject.js")
        #Container.append_seq("Page:js", "/context/spt_js/UnityObject.js")


        #widget = DivWdg()
        #widget.set_id("javascript")
        #my.set_as_panel(widget)
        widget = Widget()

        js_files = Container.get("Page:js")
        for js_file in js_files:
            widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) )


        return widget
开发者ID:blezek,项目名称:TACTIC,代码行数:53,代码来源:top_wdg.py

示例2: get_display

    def get_display(my):

        web = WebContainer.get_web()
        context_url = web.get_context_url().to_string()
        js_url = "%s/javascript" % context_url
        spt_js_url = "%s/spt_js" % context_url    # adding new core "spt" javascript library folder

        version = Environment.get_release_version()

        # add some third party libraries
        third_party = js_includes.third_party
        security = Environment.get_security()


        for include in js_includes.third_party:
            Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

        all_js_path = js_includes.get_compact_js_filepath()

        if os.path.exists( all_js_path ):
            Container.append_seq("Page:js", "%s/%s" % (context_url, js_includes.get_compact_js_context_path_suffix()))
        else:
            for include in js_includes.legacy_core:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))

            for include in js_includes.spt_js:
                Container.append_seq("Page:js", "%s/%s" % (spt_js_url,include))

            for include in js_includes.legacy_app:
                Container.append_seq("Page:js", "%s/%s" % (js_url,include))




        # custom js files to include
        includes = Config.get_value("install", "include_js")
        includes = includes.split(",")
        for include in includes:
            include = include.strip()
            if include:
                print "include: ", include
                Container.append_seq("Page:js", include)



        widget = Widget()

        js_files = Container.get("Page:js")
        for js_file in js_files:
            widget.add('<script src="%s?ver=%s" ></script>\n' % (js_file,version) )


        return widget
开发者ID:2gDigitalPost,项目名称:tactic_src,代码行数:53,代码来源:top_wdg.py

示例3: _do_execute

    def _do_execute(my):
        # restablish the site
        if my.site:
            Site.set_site(my.site)

        Environment.set_security(my.security)
        my.execute()
开发者ID:asmboom,项目名称:TACTIC,代码行数:7,代码来源:scheduler.py

示例4: _process_video

    def _process_video(my, file_name):
        if not HAS_FFMPEG:
            return

        thumb_web_size = my.get_web_file_size()
        thumb_icon_size = (120, 100)

        exts = File.get_extensions(file_name)

        base, ext = os.path.splitext(file_name)
        icon_file_name = "%s_icon.png" % base
        web_file_name = "%s_web.jpg" % base

        tmp_icon_path = "%s/%s" % (my.tmp_dir, icon_file_name)
        tmp_web_path = "%s/%s" % (my.tmp_dir, web_file_name)

        #cmd = '''"%s" -i "%s" -r 1 -ss 00:00:01 -t 1 -s %sx%s -vframes 1 "%s"''' % (ffmpeg, my.file_path, thumb_web_size[0], thumb_web_size[1], tmp_web_path)
        #os.system(cmd)

        import subprocess
        try:
            subprocess.call([ffmpeg_exe, '-i', my.file_path, "-y", "-ss", "00:00:00","-t","1",\
                    "-s","%sx%s"%(thumb_web_size[0], thumb_web_size[1]),"-vframes","1","-f","image2", tmp_web_path])
            
           
            if os.path.exists(tmp_web_path):
                my.web_path = tmp_web_path
            else:
                my.web_path = None

        except Exception, e:

            Environment.add_warning("Could not process file", \
                    "%s - %s" % (my.file_path, e.__str__()))
            pass
开发者ID:0-T-0,项目名称:TACTIC,代码行数:35,代码来源:file.py

示例5: get_side_bar_cache

    def get_side_bar_cache(my, left_nav_wdg):
        project = Project.get()
        project_code = project.get_code()

        # do it with sobject
        #key = "%s_side_bar" % project.get_code()
        #cache = Search.get("sthpw/widget_cache")
        #cache.add_filter("key", key)
        #sobject = cache.get_sobject()
        #value = sobject.get_value("cache")

        login = Environment.get_user_name()
        tmp_dir = "%s/cache/side_bar" % Environment.get_tmp_dir()

        filename = "%s__%s.html" % (project_code, login)
        path = "%s/%s" % (tmp_dir, filename)

        # use files
        import os
        if os.path.exists(path):
            f = open(path, "r")
            html = f.read()
            f.close()
        else:            
            dirname = os.path.dirname(path)
            if not os.path.exists(dirname):
                os.makedirs(dirname)
            f = open(path, "w")
            html = left_nav_wdg.get_buffer_display()
            f.write(html)
            f.close()

        return html
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:33,代码来源:page_nav_container_wdg.py

示例6: get_display

    def get_display(my):

        widget = Widget()

        if not my.select:
            return widget

        if not my.schema:
            Environment.add_warning("No schema defined")
            widget.add("No schema defined")
            return widget


        if not my.search_type:
            Environment.add_warning("HierarchicalFilterWdg: Cannot find current search_type")
            widget.add("Cannot find current search_type")
            return widget

        span = SpanWdg(css="med")
        parent_type = my.get_parent_type()
        if parent_type:
            parent_type_obj = SearchType.get(parent_type)
            span.add("%s: " % parent_type_obj.get_value("title"))

        # assume that there is a code in the parent
        my.select.add_empty_option("-- Select --")
        my.select.set_option("query", "%s|code|code" % my.parent_type)
        span.add(my.select)

        widget.add(span)

        return widget
开发者ID:0-T-0,项目名称:TACTIC,代码行数:32,代码来源:filter_wdg.py

示例7: execute

    def execute(my):

        from pyasm.common import ZipUtil
        ziputil = ZipUtil()

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

        upload_dir = Environment.get_upload_dir()
        template_dir = Environment.get_template_dir()

        for path in paths:
            path = path.replace("\\", "/")
            basename = os.path.basename(path)
            upload_path = "%s/%s" % (upload_dir, basename)

            if not upload_path.endswith(".zip"):
                continue

            print "upload: ", upload_path
            if not os.path.exists(upload_path):
                continue


            print "template_dir: ", template_dir
            shutil.move(upload_path, template_dir)
            to_path = "%s/%s" % (template_dir, basename)

            # unzip the file
            ziputil.extract(to_path)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:29,代码来源:project_template_wdg.py

示例8: get_render_dir

    def get_render_dir(my):
        ticket = Environment.get_security().get_ticket_key()
        tmpdir = Environment.get_tmp_dir()
        render_dir = "%s/temp/%s" % (tmpdir, ticket)
        System().makedirs(render_dir)

        return render_dir
开发者ID:0-T-0,项目名称:TACTIC,代码行数:7,代码来源:qube_render_submit.py

示例9: execute

    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,代码行数:26,代码来源:create_project_cmd.py

示例10: get_columns

    def get_columns(my, required_only=False):
        if my.search_type == 'sthpw/virtual':
            return []

        search_type_obj = SearchType.get(my.search_type)
        table = search_type_obj.get_table()

        from pyasm.biz import Project
        db_resource = Project.get_db_resource_by_search_type(my.search_type)
        database_name = db_resource.get_database()
        db = DbContainer.get(db_resource)

        # table may not exist
        try:
            all_columns = db.get_columns(table)
            columns = []
            if required_only:
                nullables = db.get_column_nullables(table)
                for column in all_columns:
                    null_ok = nullables.get(column)
                    if not null_ok:
                        columns.append(column)

                # if there are no required columns
                if not columns:
                    columns = all_columns 
                
            else:
                columns = all_columns 
        except SqlException:
            Environment.add_warning('missing table', 'Table [%s] does not exist in database [%s]' %(table, database_name))
            return  []

        return columns
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:34,代码来源:sobject_default_config.py

示例11: test_all

    def test_all(self):
        batch = Batch()
        Environment.get_security().set_admin(True)

        from pyasm.unittest import UnittestEnvironment, Sample3dEnvironment
        test_env = UnittestEnvironment()
        test_env.create()

        sample3d_env = Sample3dEnvironment(project_code='sample3d')
        sample3d_env.create()

        Project.set_project("unittest")
        try:
            self.access_manager = Environment.get_security().get_access_manager()   
            self._test_all()

        finally:
            # Reset access manager for tear down 
            Environment.get_security()._access_manager =  self.access_manager
            Environment.get_security().reset_access_manager() 
            self._tear_down()
            Environment.get_security().set_admin(True)
            test_env.delete()
            Environment.get_security().set_admin(True)
            sample3d_env.delete()
            Site.pop_site()
开发者ID:mincau,项目名称:TACTIC,代码行数:26,代码来源:security_test.py

示例12: filter_xml

    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,代码行数:33,代码来源:help_wdg.py

示例13: __init__

    def __init__(self, login_name, password=None):
        super(XmlRpcLogin,self).__init__()

        self.set_app_server("xmlrpc")

        # If the tag <force_lowercase_login> is set to "true"
        # in the TACTIC config file,
        # then force the login string argument to be lowercase.
        # This tag is false by default.        
        self.login_name = login_name
        if Config.get_value("security","force_lowercase_login") == "true":
            self.login_name = self.login_name.lower()
        
        self.password = password

        # clear the main container
        #Container.clear()

        Environment.set_env_object( self )

        # set up the security object
        security = Security()
        Environment.set_security(security)

        self._do_login()
开发者ID:mincau,项目名称:TACTIC,代码行数:25,代码来源:batch.py

示例14: execute

    def execute(self):
        web = self.get_web()
        keys = web.get_form_keys()
        file_name = self.kwargs.get("file_name")

        # process and get the uploaded files
        dir = Environment.get_upload_dir()
        license_file = "%s/%s" % (dir, file_name)
        if not os.path.exists(license_file):
            raise TacticException("Error retrieving the license file in [%s]"%license_file)

        std_name = 'tactic-license.xml'

        head, file_name = os.path.split(license_file)
        # no restrictions for license file
        #if file_name != std_name:
        #    raise TacticException("License file name should be named tactic-license.xml. The file given is [%s]" %file_name)

        license_dir = Environment.get_license_dir()
        current_license = "%s/%s" %(license_dir, std_name)
        if os.path.exists(current_license):
            FileUndo.remove(current_license)
        FileUndo.move(license_file, current_license)

        self.add_description('Renewed license file')
        security = Environment.get_security()
        security.reread_license()
开发者ID:mincau,项目名称:TACTIC,代码行数:27,代码来源:license_manager_wdg.py

示例15: set_project

    def set_project(cls, project_code):
        '''This is kept here because everybody is used to using this'''

        security = Environment.get_security()
        # FIXME:
        # Because it is possible to call this before one is 
        # logged in.  This is required to see the login screen.
        from pyasm.security import get_security_version
        security_version = get_security_version()
        if security_version != 1 and not project_code == 'admin':
            key = { 'code': project_code }
            key2 = { 'code': "*" }
            keys = [key, key2]
            if not security.check_access("project", keys, access="allow", default="deny"):
                user = Environment.get_login()
                if user:
                    user = user.get_value("login")
                    raise SecurityException("User [%s] is not permitted to view project [%s]" % (user, project_code))
                else:
                    raise SecurityException("User is not permitted to view project [%s]" % (project_code))

        from pyasm.security import Site
        site = Site.get_site()
        PROJECT_KEY = "Project:global:%s:" % site
        Container.put(PROJECT_KEY, project_code)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:25,代码来源:project.py


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