def update_liststore_image(liststore, tree_iters, col, pcs_files, dir_name,<EOL>icon_size=<NUM_LIT>):
def update_image(filepath, tree_iter):<EOL><INDENT>try:<EOL><INDENT>pix = GdkPixbuf.Pixbuf.new_from_file_at_size(filepath, icon_size,<EOL>icon_size)<EOL>tree_path = liststore.get_path(tree_iter)<EOL>if tree_path is None:<EOL><INDENT>return<EOL><DEDENT>liststore[tree_path][col] = pix<EOL><DEDENT>except GLib.GError:<EOL><INDENT>logger.error(traceback.format_exc())<EOL><DEDENT><DEDENT>def dump_image(url, filepath):<EOL><INDENT>req = net.urlopen(url)<EOL>if not req or not req.data:<EOL><INDENT>logger.warn('<STR_LIT>' % url)<EOL>return False<EOL><DEDENT>with open(filepath, '<STR_LIT:wb>') as fh:<EOL><INDENT>fh.write(req.data)<EOL><DEDENT>return True<EOL><DEDENT>for tree_iter, pcs_file in zip(tree_iters, pcs_files):<EOL><INDENT>if '<STR_LIT>' not in pcs_file:<EOL><INDENT>continue<EOL><DEDENT>if '<STR_LIT>' in pcs_file['<STR_LIT>']:<EOL><INDENT>key = '<STR_LIT>'<EOL><DEDENT>elif '<STR_LIT>' in pcs_file['<STR_LIT>']:<EOL><INDENT>key = '<STR_LIT>'<EOL><DEDENT>elif '<STR_LIT>' in pcs_file['<STR_LIT>']:<EOL><INDENT>key = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>continue<EOL><DEDENT>fs_id = pcs_file['<STR_LIT>']<EOL>url = pcs_file['<STR_LIT>'][key]<EOL>filepath = os.path.join(dir_name, '<STR_LIT>'.format(fs_id))<EOL>if os.path.exists(filepath) and os.path.getsize(filepath):<EOL><INDENT>GLib.idle_add(update_image, filepath, tree_iter)<EOL><DEDENT>elif not url or len(url) < <NUM_LIT:10>:<EOL><INDENT>logger.warn('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>status = dump_image(url, filepath)<EOL>if status:<EOL><INDENT>GLib.idle_add(update_image, filepath, tree_iter)<EOL><DEDENT><DEDENT><DEDENT>
下载文件缩略图, 并将它显示到liststore里.

    pcs_files - 里面包含了几个必要的字段.
    dir_name  - 缓存目录, 下载到的图片会保存这个目录里.
    size      - 指定图片的缩放大小, 默认是96px.