[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Testing out the theme

Rahul wrote:

Users who want to take a look at this new Echo theme would want a quick and easy way to install and check it out.

Currently all I see is a list of SVG files in a wiki page. Can we put up a tarball appropriately packaged or a RPM package that is updated frequently perhaps?

Hello again...

I mentioned this over lunch today and J5 (John Palmieri) wrote a python script to pull all the files from the wiki. (attached). Yeay! The following are some technical details that he included if someone would like to take this on and modify it. Like last time, I've got two .tar...one is just the PNGs [1] and the other is PNG+SVG (44.1M) [2]. The naming of the files are a bit different this time as it is pulled directly from the wiki. Leon, if you could do what you did last time, that would be great!


[1] http://people.redhat.com/dfong/icons/echo48_0.11.tar.bz2
[2] http://people.redhat.com/dfong/icons/echo_0.11.tar.bz2

J5 wrote:

Attached is the python script used to pull them all from the wiki.  I whipped it up pretty quickly and there are several areas where it can be improved if someone wants to work on it:

* It uses a base directory of echo_art/ this should be able to be
overridden by a command line switch
* If the directory exists it should confirm with the user and then
delete or move the old directory * Statistics could be added as well as a way to diff previous pulls to
see what has changed
* There is already a filter function that returns a new name and
directory based on the icons name.  Right now the script just checks for
'image-missing' and returns None indicating that icon should not be
downloaded.  This filter function can be expanded to filter icons into
specific directories for easier packaging provided you have a consistent
naming scheme on the wiki.
* Inputs need to be filtered to make sure someone doesn't add input on
the wiki that would cause the script to do bad thing on your machine.
Right now it is not an issue but if the filter function gets more
complex (such as using a part of a file name as the directory) you might
want to scan those directory strings to make sure characters like ~
or .. don't get in.
* Someone could add a specfile generator and auto packager so that new
sets of icons can be tested easily.

Hope this helps you guys out and I can't wait to see the new icons in

-- John (J5) Palmieri <johnp redhat com>

#!/bin/env python

## echo_pull - pulls echo icons off the fedora wiki 

## Copyright (C) 2006 Red Hat, Inc.
## Copyright (C) 2006 John (J5) Palmieri <johnp redhat com>

## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.

## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## GNU General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


import sys
import os
import urllib2
import HTMLParser 

import re


def _mkdir(newdir):
    """works the way a good mkdir should :)
        - already exists, silently complete
        - regular file in the way, raise an exception
        - parent directory(ies) does not exist, make them as well
    if os.path.isdir(newdir):
    elif os.path.isfile(newdir):
        raise OSError("a file with the same name as the desired " \
                      "dir, '%s', already exists." % newdir)
        head, tail = os.path.split(newdir)
        if head and not os.path.isdir(head):
        #print "_mkdir %s" % repr(newdir)
        if tail:

class ArtParser(HTMLParser.HTMLParser):

    def handle_starttag(self, tag, attr):
        if tag == 'a':
            for a in attr:
                if a[0] == 'href':
                    match = href_re.match(a[1])
                    if match:
                        self.filter_and_download (base_url, 
    def download(self, url, directory, filename):
        if not os.path.isdir(directory):
        file_path = os.path.join(directory, filename)
        file = os.popen ('wget "%s" -O %s'%(url, file_path))
        error = file.close()

        if error:
            sys.stderr.write ('Error downloading %s to %s\n'%(url, 
    def filter(self, file):
        if file.startswith('image-missing'):
            return (base_dir, file) 

    def filter_and_download (self, base_url, resource, file):
        art_url = "%s%s"%(base_url, 
        filter = self.filter(file)
        if filter:
            (filtered_dir, filtered_file) = filter
            self.download(art_url, filtered_dir, filtered_file)

def main():
    #get the main page
    url = '%s%s'%(base_url, echo_dir)
        data = urllib2.urlopen(url).read()
    except urllib2.HTTPError, e:
        print "HTTP error: %d" % e.code
    except urllib2.URLError, e:
        print "Network error: %s" % e

    #pull out <a > tags with a target graphics in the href
    p = ArtParser()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]