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


Python Environment.add_warning方法代码示例

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


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

示例1: get_columns

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    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,代码行数:36,代码来源:sobject_default_config.py

示例2: get_display

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    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,代码行数:34,代码来源:filter_wdg.py

示例3: _process_video

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    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,代码行数:37,代码来源:file.py

示例4: get_by_code

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    def get_by_code(cls, code, allow_default=False):
        '''it is fatal not to have a pipeline, so put a default'''
        if not code:
            return None

        # first look at project specific pipeline
        pipeline = Search.get_by_code("config/pipeline", code)

        if not pipeline:
            pipeline = super(Pipeline,cls).get_by_code(code)

        if not pipeline and code == 'task':
            # Create a default task pipeline
            pipeline = SearchType.create("sthpw/pipeline")
            pipeline.set_value("code", "task")
            from pyasm.biz import Task
            xml = Task.get_default_task_xml()
            pipeline.set_value("pipeline", xml)
            pipeline.set_pipeline(xml)
            pipeline.set_value("search_type", "sthpw/task")
            #pipeline.commit()


        if not pipeline and allow_default:
            search = Search(cls)
            search.add_filter('code', 'default')
            pipeline = search.get_sobject()
            if not pipeline:
                
                pipeline = cls.create('default',  \
                    'default pipeline', '')

                xml = pipeline.get_xml_value("pipeline")

                # create a default process for the table
                root = xml.get_root_node()
                element = xml.create_element("process")
                Xml.set_attribute(element,"name", "default_process")
                Xml.append_child(root, element)

                pipeline.set_value('pipeline', xml.get_xml())
                pipeline.commit()
                
                # set the pipeline
                pipeline.set_pipeline(pipeline.get_value('pipeline'))
                Environment.add_warning("pipeline autogenerated", \
                    "[default] pipeline has just been created.")
        # Sometimes, a pipeline is instantiated without calling set_pipeline()
        # to be looked into
        if pipeline and not pipeline.get_processes():
            pipeline.set_pipeline(pipeline.get_value('pipeline'))
        return pipeline
开发者ID:funic,项目名称:TACTIC,代码行数:54,代码来源:pipeline.py

示例5: get_file_info

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    def get_file_info(xml, file_objects, sobject, snapshot, show_versionless=False, is_list=False, protocol='http'):
        info = {}
        #TODO: {'file_type': [file_type]: [path], 'base_type': [base_type]: [file|directory|sequence]}

        if is_list:
            info = []
        else:
            repo_info = {}
            info['_repo'] = repo_info

        nodes = xml.get_nodes("snapshot/file")
        for node in nodes:
            type = Xml.get_attribute(node, "type")

            file_code = Xml.get_attribute(node, "file_code")

            file_object = file_objects.get(file_code)
            if not file_object:
                if isinstance(info, dict):
                    info[type] = ThumbWdg.get_no_image()
                else:
                    info.append((type, ThumbWdg.get_no_image()))
                Environment.add_warning("No file object", "No file object found for file code '%s'" % file_code)
                continue

            file_name = file_object.get_full_file_name()
            web_dir = sobject.get_web_dir(snapshot, file_object=file_object)

            # handle a range if it exists
            file_range = file_object.get_value("file_range")
            if file_range:
                from pyasm.biz import FileGroup, FileRange
                file_range = FileRange.get(file_range)
                file_names = FileGroup.expand_paths(file_name, file_range)
                # just check the first frame
                if file_names:
                    file_name = file_names[0]
            path = "%s/%s" % (web_dir, file_name)

            if protocol != "file":
                path = urllib.pathname2url(path)

            if isinstance(info, dict):
                info[type] = path
                lib_dir = sobject.get_lib_dir(snapshot, file_object=file_object)
                repo_info[type] = "%s/%s" % (lib_dir, file_name)
            else:
                info.append((type, path))

        return info
开发者ID:asmboom,项目名称:TACTIC,代码行数:52,代码来源:file_wdg.py

示例6: get_to

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    def get_to(my):
        # add the assigned user to the list of users sent.
        recipients = super(TaskAssignEmailHandler, my).get_to()

        task = my.sobject
        assigned = task.get_value("assigned")

        login = Login.get_by_login(assigned)
        if not login:
            Environment.add_warning("Non existent user", "User %s does not exist" % assigned)
            return recipients

        recipients.add(login)

        return recipients
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:17,代码来源:email_handler.py

示例7: execute

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

        # check file name
        file_name = os.path.basename(self.file_path)

        ext = File.get_extension(file_name)
        type = string.lower(ext)


        if type == "pdf":
            self._process_pdf( file_name )
        elif type != "psd" and type in File.NORMAL_EXT:
            # skip icon generation for normal or video files
            pass
        elif type in File.VIDEO_EXT:
            try:
                self._process_video( file_name )
            except IOError, e:
                '''This is an unknown file type.  Do nothing and except as a
                file'''
                print("WARNING: ", e.__str__())
                Environment.add_warning("Unknown file type", e.__str__())
开发者ID:mincau,项目名称:TACTIC,代码行数:24,代码来源:file.py

示例8: get_display

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

        try:
            import qb
        except ImportError:
            Environment.add_warning("Qube not installed", "Qube not installed")
            return "---"
            
        dispatcher_id = sobject.get_value("dispatcher_id")

        all_jobinfo = qb.jobinfo(filters={'id': dispatcher_id})
        if not all_jobinfo:
            return "---"

        job_info = all_jobinfo[0]

        status = job_info.get('status')

        timestart = job_info.get('timestart')
        timecomplete = job_info.get('timecomplete')
        timeelapsed = int(timecomplete) - int(timestart)
        return "%s (%ss)" % (status, timeelapsed)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:25,代码来源:qube_render_submit.py

示例9: create

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    def create(src_sobject, dst_sobject, context="reference", direction="both"):

        project_code = Project.get_project_code()

        if not context:
            context = "reference"

        # ensure that the connection doesn't already exist
        search = Search("sthpw/connection")
        search.add_sobject_filter(src_sobject, prefix="src_")
        search.add_sobject_filter(dst_sobject, prefix="dst_")
        if search.get_count():
            Environment.add_warning("Already connected", "%s is already connected to %s" % (src_sobject.get_code(), dst_sobject.get_code() ) )
            return


        connection = SearchType.create("sthpw/connection")
        connection.set_value("src_search_type", src_sobject.get_search_type() )
        connection.set_value("dst_search_type", dst_sobject.get_search_type() )
        connection.set_value("src_search_id", src_sobject.get_id() )
        connection.set_value("dst_search_id", dst_sobject.get_id() )
        connection.set_value("context", context)
        connection.set_value("project_code", project_code)
        connection.commit()

        if direction == "both":
            connection = SearchType.create("sthpw/connection")
            connection.set_value("src_search_type", dst_sobject.get_search_type() )
            connection.set_value("dst_search_type", src_sobject.get_search_type() )
            connection.set_value("src_search_id", dst_sobject.get_id() )
            connection.set_value("dst_search_id", src_sobject.get_id() )
            connection.set_value("context", context)
            connection.set_value("project_code", project_code)
            connection.commit()


        return connection
开发者ID:blezek,项目名称:TACTIC,代码行数:39,代码来源:sobject_connection.py

示例10: get_source_link

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    def get_source_link(my, node):
        search_type = Xml.get_attribute(node, "search_type")
        search_id = Xml.get_attribute(node, "search_id")
        context = Xml.get_attribute(node, "context")
        version = Xml.get_attribute(node, "version")

        source_snapshot = Snapshot.get_by_version(search_type, search_id, \
            context, version )
        if not source_snapshot:
            Environment.add_warning("Snapshot not found",  "Reference snapshot for [%s|%s] does not exist" \
              % (search_type, search_id) )
            return ''
            #raise WidgetException( "Reference snapshot in '%s' does not exist" \
            #   % snapshot.get_id() )

        source = source_snapshot.get_sobject()

        # get the file link
        file_name = source_snapshot.get_name_by_type("main")
        path = "%s/%s" % (source_snapshot.get_web_dir(), file_name)

        
        return HtmlElement.href("Source: %s" %source.get_value("code"), \
            ref=path ) 
开发者ID:0-T-0,项目名称:TACTIC,代码行数:26,代码来源:texture_wdg.py

示例11: preprocess

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    def preprocess(self):
        
        # protect against the case where there is a single sobject that
        # is an insert (often seen in "insert")
        if self.is_preprocessed == True:
            return

        skip = False
        if len(self.sobjects) == 1:
            if not self.sobjects[0].has_value("search_type"):
                skip = True

        if not skip:
            search_types = SObject.get_values(self.sobjects, 'search_type', unique=True)

            try:
                search_codes = SObject.get_values(self.sobjects, 'search_code', unique=True)
                search_ids = None
            except Exception as e:
                print "WARNING: ", e
                search_ids = SObject.get_values(self.sobjects, 'search_id', unique=True)
                search_codes = None
        else:
            search_types = []
            search_codes = []


        # if there is more than one search_type, then go get each parent
        # individually
        # NOTE: this is very slow!!!!
        ref_sobjs = []
        if len(search_types) > 1:
            ref_sobjs = []
            for tmp_sobj in self.sobjects:
                try:
                    ref_sobj = tmp_sobj.get_parent()
                    if ref_sobj:
                        ref_sobjs.append(ref_sobj)
                    else:
                        warning = "Dangling reference: %s" % tmp_sobj.get_search_key()
                        Environment.add_warning(warning, warning)
                except SearchException as e:
                    # skips unknown search_type/project
                    print e.__str__()
                    continue

        elif len(search_types) == 1:
            search_type =  self.sobjects[0].get_value("search_type")
            try:
                if search_codes != None:
                    ref_sobjs = Search.get_by_code(search_type, search_codes)
                else:
                    ref_sobjs = Search.get_by_id(search_type, search_ids)
            except SearchException as e:
                # skips unknown search_type/project
                print e.__str__()
                pass

        # TODO: None defaults to search_key, should be empty
        self.ref_sobj_dict = SObject.get_dict(ref_sobjs, None)

        # when drawn as part of a TbodyWdg, we want to disable the calculation
        # of most things so that it will not try to display a prev row
        if self.get_option('disable') == 'true':
            self.ref_sobj_dict = None
            self.empty = True
  
        self.is_preprocessed = True
开发者ID:mincau,项目名称:TACTIC,代码行数:70,代码来源:group_element_wdg.py

示例12: get_schema_wdg

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    def get_schema_wdg(my, schema):
        web = WebContainer.get_web()

        div = DivWdg()
        div.add_style("margin: 10 0 10 0")

        if not schema:
            Environment.add_warning("No schema", "No schema found")
            return div
        schema_xml = schema.get_xml_value("schema")
        code = schema.get_code()


        schema_search_types = schema_xml.get_values("schema/search_type/@name")
        if not schema_search_types:
            return


        title = DivWdg()
        view_margin_top = '4px'
        title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
        if not web.is_IE():
            title.add_styles( "margin-left: -10px; margin-right: -10px;" )
        title.add_looks( "navmenu_header" )

        title_label = SpanWdg()
        title_label.add_styles( "margin-left: 6px; padding-bottom: 2px;" )
        title_label.add_looks( "fnt_title_5 fnt_bold" )
        title_label.add("%s Schema" % code.capitalize())
        title.add(title_label)
        #title.add_style("margin-top: 7px")
        #title.add_style("font-weight: bold")
        #title.add_style("font-size: 1.1em")
        #title.add_style("color: black")
        #underline = HtmlElement.hr()
        #underline.add_style("color: black")
        #underline.add_style("size: 1px")
        #underline.add_style("margin-top: -3px")
        #title.add(underline)
        div.add( title )



        for schema_search_type in schema_search_types:
            try:
                search_type_obj = SearchType.get(schema_search_type)
            except SearchException:
                title = "<span style='color: #F44'>? %s</span>" % schema_search_type
            else:
                title = search_type_obj.get_title()


            span = DivWdg()
            span.add_style("padding: 1px")

            options = {
                'search_type': schema_search_type,
                'view': 'table',
                'schema_default_view': 'true',
            }
            link = my.get_link_wdg("schema", "main_body", title, options)


            # walk up the tree
            current_type = schema_search_type
            has_parent = False
            while 1:
                parent_type = schema.get_parent_type(current_type)
                if parent_type and parent_type != '*':
                    span.add("&nbsp;&nbsp;&nbsp;")
                    has_parent = True
                else:
                    if has_parent:
                        span.add("+&nbsp;")
                    break
                current_type = parent_type

            span.add(link)
            div.add(span)

        return div
开发者ID:blezek,项目名称:TACTIC,代码行数:83,代码来源:schema_section_wdg.py

示例13: _process_image

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

        base, ext = os.path.splitext(file_name)

        # get all of the extensions
        exts = File.get_extensions(file_name)
        frame = 0
        if len(exts) == 2:
            try:
                frame = int(exts[0])
                base = base.replace(".%s" % exts[0], '' )
            except ValueError:
                frame = 0

        if frame:
            icon_file_name = "%s_icon.%s.png" % (base, exts[0])
            web_file_name = "%s_web.%s.jpg" % (base, exts[0])
        else:
            icon_file_name = "%s_icon.png" % base
            web_file_name = "%s_web.jpg" % base

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

        # create the web image
        try:
            if self.texture_mode:
                self._resize_texture(self.file_path, tmp_web_path, 0.5)
                self.web_path = tmp_web_path

                # create the icon
                thumb_size = (120,100)
                try:
                    self._resize_image(tmp_web_path, tmp_icon_path, thumb_size)
                except TacticException:
                    self.icon_path = None
                else:
                    self.icon_path = tmp_icon_path
            elif self.icon_mode: # just icon, no web
                # create the icon only
                thumb_size = (120,100)
                try:
                    self._resize_image(self.file_path, tmp_icon_path, thumb_size)
                except TacticException:
                    self.icon_path = None
                else:
                    self.icon_path = tmp_icon_path


            else:
                
                thumb_size = self.get_web_file_size()
                
                try:
                    self._resize_image(self.file_path, tmp_web_path, thumb_size)
                except TacticException:
                    self.web_path = None
                else:
                    self.web_path = tmp_web_path

                # create the icon
                thumb_size = (120,100)
                try:
                    self._resize_image(tmp_web_path, tmp_icon_path, thumb_size)
                except TacticException:
                    self.icon_path = None
                else:
                    self.icon_path = tmp_icon_path

            # check icon file size, reset to none if it is empty
            # TODO: use finally in Python 2.5
            if self.web_path:
                web_path_size = os.stat(self.web_path)[stat.ST_SIZE]
                if not web_path_size:
                    self.web_path = None
            if self.icon_path:
                icon_path_size = os.stat(self.icon_path)[stat.ST_SIZE]
                if not icon_path_size:
                    self.icon_path = None
        except IOError, e:
            Environment.add_warning("Could not process file", \
                "%s - %s" % (self.file_path, e.__str__()))
            self.web_path = None
            self.icon_path = None
开发者ID:mincau,项目名称:TACTIC,代码行数:86,代码来源:file.py

示例14: _process_video

# 需要导入模块: from pyasm.common import Environment [as 别名]
# 或者: from pyasm.common.Environment import add_warning [as 别名]
    def _process_video(self, file_name):
        if not HAS_FFMPEG:
            return

        thumb_web_size = self.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" % (self.tmp_dir, icon_file_name)
        tmp_web_path = "%s/%s" % (self.tmp_dir, web_file_name)

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

        import subprocess
                
        try:
            # Attempt to resize only if necessary. Requires ffprobe call.
            # (More recent version of ffmpeg support the argument
            # -vf scale="'if(gt(iw, 640), 640, iw)':'if(gt(ih, 6400), 6400, -1)'"
            # allowing for scaling which preserves aspect ratio and only scales
            # when necessary. For now, it is necessary to query video size.)
            free_aspect_ratio = thumb_web_size[1] == -1 
            try:
                command = ["ffprobe", "-print_format", "json", "-select_streams", "v:0", "-show_entries", "stream=height,width",  self.file_path]
                p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                out, err = p.communicate()
                data = jsonloads(out)
                streams = data.get("streams") or []
                sample_stream = streams[0]
                width = int(sample_stream.get("width"))
                height = int(sample_stream.get("height"))
            
                max_width = thumb_web_size[0]
                max_height = max_width*10 if free_aspect_ratio else thumb_web_size[1]
               
                if width < max_width and height < max_height:
                    # Resizing is not necessary
                    size_option = ""
                    size = ""
                elif not free_aspect_ratio and (width > max_width or height > max_height):
                    size_option = "-s"
                    size =  "%sx%s" % (thumb_web_size[0], thumb_web_size[1])
                else: 
                    if width > height:
                        size_option = "-vf"
                        size = "scale=%s:-1" % thumb_web_size[0]
                        
                    elif height > width:
                        aspect_ratio = float(float(height)/(width))
                        if aspect_ratio >= 10:
                            size_option = "-vf"
                            size = "scale=-1:%s" % max_height
                        else:
                            new_height = max_height
                            new_width = float(new_height)/height
                            if new_width > max_width:
                                new_width = max_width
                                new_height = height*float(new_width)/width
                                size_option = "-vf"
                                size = "scale=%s:-1" % max_width
                            else:
                                size_option = "-vf"
                                size = "scale=-1:%s" % max_height

            except Exception as e:
                if free_aspect_ratio: 
                    size_option = "-vf"
                    size = "scale=%s:-1" % thumb_web_size[0]
                else:
                    size_option = "-s"
                    size =  "%sx%s" % (thumb_web_size[0], thumb_web_size[1])

            command = [ffmpeg_exe, '-i', self.file_path, "-y", "-ss", "00:00:00","-t","1"]
            if size_option and size:
                command.extend([size_option, size])
            command.extend(["-vframes","1","-f","image2", tmp_web_path])
            subprocess.call(command)

            if os.path.exists(tmp_web_path):
                self.web_path = tmp_web_path
            else:
                self.web_path = None

        except Exception as e:

            Environment.add_warning("Could not process file", \
                    "%s - %s" % (self.file_path, e.__str__()))
            pass
          
        try:
            subprocess.call([ffmpeg_exe, '-i', self.file_path, "-y", "-ss", "00:00:00","-t","1",\
                    "-s","%sx%s"%(thumb_icon_size[0], thumb_icon_size[1]),"-vframes","1","-f","image2", tmp_icon_path])
            
            if os.path.exists(tmp_icon_path):
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:file.py

示例15: _process_image

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

        base, ext = os.path.splitext(file_name)

        # get all of the extensions
        exts = File.get_extensions(file_name)
        frame = 0
        if len(exts) == 2:
            try:
                frame = int(exts[0])
                base = base.replace(".%s" % exts[0], '' )
            except ValueError:
                frame = 0

        if frame:
            icon_file_name = "%s_icon.%s.png" % (base, exts[0])
            web_file_name = "%s_web.%s.jpg" % (base, exts[0])
        else:
            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)

        # create the web image
        try:
            if my.texture_mode:
                my._resize_texture(my.file_path, tmp_web_path, 0.5)
                my.web_path = tmp_web_path

                # create the icon
                thumb_size = (120,100)
                my._resize_image(tmp_web_path, tmp_icon_path, thumb_size)

                my.icon_path = tmp_icon_path
            elif my.icon_mode: # just icon, no web
                # create the icon only
                thumb_size = (120,100)
                my._resize_image(my.file_path, tmp_icon_path, thumb_size)
                my.icon_path = tmp_icon_path


            else:
                from pyasm.prod.biz import ProdSetting
                web_file_size = ProdSetting.get_value_by_key('web_file_size')
                thumb_size = (640, 480)
                if web_file_size:
                    parts = re.split('[\Wx]+', web_file_size)
                    
                    thumb_size = (640, 480)
                    if len(parts) == 2:
                        try:
                            thumb_size = (int(parts[0]), int(parts[1]))
                        except ValueError:
                            thumb_size = (640, 480)
                
                my._resize_image(my.file_path, tmp_web_path, thumb_size)

                my.web_path = tmp_web_path

                # create the icon
                thumb_size = (120,100)
                my._resize_image(tmp_web_path, tmp_icon_path, thumb_size)

                my.icon_path = tmp_icon_path

            # check icon file size, reset to none if it is empty
            # TODO: use finally in Python 2.5
            if my.web_path:
                web_path_size = os.stat(my.web_path)[stat.ST_SIZE]
                if not web_path_size:
                    my.web_path = None
            if my.icon_path:
                icon_path_size = os.stat(my.icon_path)[stat.ST_SIZE]
                if not icon_path_size:
                    my.icon_path = None
        except IOError, e:
            Environment.add_warning("Could not process file", \
                "%s - %s" % (my.file_path, e.__str__()))
            my.web_path = None
            my.icon_path = None
开发者ID:blezek,项目名称:TACTIC,代码行数:84,代码来源:file.py


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