Re: Testing out the theme

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

 



Rahul wrote:
Hi

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!

Thanks,
Diana

[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
action.

-- John (J5) Palmieri <johnp@xxxxxxxxxx>


#!/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@xxxxxxxxxx>

## 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
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## 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.

base_url='http://fedoraproject.org/'
echo_dir='wiki/Artwork/EchoDevelopment'
base_dir='echo_art'

import sys
import os
import urllib2
import HTMLParser 

import re

href_re=re.compile('\/(.*)\?.*target=(.*[(\.svg)(\.png)])')

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):
        pass
    elif os.path.isfile(newdir):
        raise OSError("a file with the same name as the desired " \
                      "dir, '%s', already exists." % newdir)
    else:
        head, tail = os.path.split(newdir)
        if head and not os.path.isdir(head):
            _mkdir(head)
        #print "_mkdir %s" % repr(newdir)
        if tail:
            os.mkdir(newdir)

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, 
                                                  a[1], 
                                                  match.group(2))
    def download(self, url, directory, filename):
        if not os.path.isdir(directory):
            _mkdir(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, 
                                                              file_path)) 
 
    def filter(self, file):
        if file.startswith('image-missing'):
            return
        else:
            return (base_dir, file) 

    def filter_and_download (self, base_url, resource, file):
        art_url = "%s%s"%(base_url, 
                          resource)
 
        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)
    try:
        data = urllib2.urlopen(url).read()
    except urllib2.HTTPError, e:
        print "HTTP error: %d" % e.code
        exit(1)
    except urllib2.URLError, e:
        print "Network error: %s" % e
        exit(2)

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

    p.close()

main()
_______________________________________________

@xxxxxxxxxx
http://www.redhat.com/mailman/listinfo/

[Index of Archives]     [Fedora Music]     [Fedora Development]     [Linux Kernel]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Directory]     [PAM]     [Big List of Linux Books]     [Gimp]     [Yosemite News]

  Powered by Linux