<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UnixWars &#187; Python</title>
	<atom:link href="http://unixwars.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://unixwars.com</link>
	<description>Taher Shihadeh's ragbag</description>
	<lastBuildDate>Mon, 26 Dec 2011 23:38:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>dirsort: Directory sorter</title>
		<link>http://unixwars.com/2010/08/09/dirsort-epi_sort-reloaded/</link>
		<comments>http://unixwars.com/2010/08/09/dirsort-epi_sort-reloaded/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 12:33:49 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=678</guid>
		<description><![CDATA[This one is a grown up version of epi_sort.py, a simple script I wrote a while ago to help me sort a huge bunch of media files I had laying around. I recently suffered some major data loss on an external hard drive full of videos. After recovering most of the contents, the directory structure [...]]]></description>
			<content:encoded><![CDATA[<p>This one is a grown up version of <a href="../2010/07/03/filename-comparator/">epi_sort.py</a>,  a simple script I wrote a while ago to help me sort a huge bunch of  media files I had laying around. I recently suffered some major data  loss on an external hard drive full of videos. After recovering most of  the contents, the directory structure was completely lost. I&#8217;ve managed to organize things pretty decently thanks to the script.</p>
<p>I have named it <a href="/scripts/dirsort/">episort</a>. Not very original, but it has been a lifesaver so far.<br />
It is much faster and accurate than before, by the way.</p>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2010/08/09/dirsort-epi_sort-reloaded/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>epi_sort.py: Filename comparison</title>
		<link>http://unixwars.com/2010/07/03/filename-comparator/</link>
		<comments>http://unixwars.com/2010/07/03/filename-comparator/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 14:08:57 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=667</guid>
		<description><![CDATA[As every Joe Six-pack would do, I usually write a lot of scripts to automate my tasks as much as I can. Most of them aren&#8217;t even worth mentioning, but nevertheless I have been meaning to start posting some of those. I&#8217;ve stumbled upon lots of jewels on the net that seemed worthless to their [...]]]></description>
			<content:encoded><![CDATA[<p>As every Joe Six-pack would do, I usually write a lot of scripts to automate my tasks as much as I can. Most of them aren&#8217;t even worth mentioning, but nevertheless I have been meaning to start posting some of those. I&#8217;ve stumbled upon lots of jewels on the net that seemed worthless to their authors, so if any one gets to use one of mine I&#8217;ll be happy. You never know.</p>
<h4>The problem:</h4>
<p>I have a directory full of unclassified media files, some are duplicates, some aren&#8217;t, and each one follows a different naming convention.</p>
<p>I even try to classify them from time to time, so you can throw some directories into the pack. Sometimes, I even create two or three directories for the same group-series-category-whatever before I realize there is an existing one with a slightly different name. And frequently a lot of files remain unclassified, many of which could fit into one of the directories I mentioned.</p>
<p>Of course &#8230; whenever a new file arrives to my <a href="/tag/home-server/">home server</a>, it gets thrown into that very same directory, so Chaos keeps spreading, as it always does.</p>
<p>To clarify things, lets show an example:</p>
<pre>drwxrwxrwx 1 user user      4096 2010-07-03 11:50 01_Battlestar_Enterprise
drwxrwxrwx 1 user user      4096 2010-07-03 11:42 02_Startrek_Galactica
drwxrwxrwx 1 user user      4096 2010-07-03 11:50 03_battlestar.enterprise-season.1
-rwxrwxrwx 1 user user 220393472 2010-07-03 02:49 battlestar.enterprise.s1e01.avi
-rwxrwxrwx 1 user user 221227008 2010-07-03 02:50 Battlestar_Enterprise_1_22.mp4
-rwxrwxrwx 1 user user 195393472 2010-07-03 02:49 startrek.galactica.4x15.[ripper_22].mkv
</pre>
<p>As you can imagine, sorting things up can get really tedious, and there is no automatic way of doing it that I know of.</p>
<p>I had some time this morning and got fed up with it. Every little piece of help is more than welcome, and here is where Python comes to the rescue.</p>
<h4>The solution:</h4>
<p>There are dozens of ways to do this, but I ended up coding a quick hack to help me sort things out.<br />
It just compares the names of files and directories, and estimates the similarities. Anything above a 50% match is usually correctly estimated.</p>
<pre class="prettyprint">#!/usr/bin/env python
# -*- coding: utf-8 -*-

# (C) 2010, Taher Shihadeh
# Licensed: GPL v2

"""
The script works based only on names of files and directories in a
non-recursive manner.

It takes a path as parameter and tries to determine if the names of
the contents look alike.

It removes separator characters, numbers and file extensions prior to
the comparison.
"""

import os
import sys
import string
from operator import itemgetter

FAST = False # Change this to skip file-to-file comparisons
SEP  = '_-+~.·:;·()[]¡!¿?<>'

def main (path):
    lst1    = os.listdir (path)
    lst2    = lst1
    len_lst = len(lst1)
    count   = 0.0
    results = []

    for x in lst1:
        for y in lst2:
            if x==y:
                continue
            x_dir = os.path.isdir(x)
            y_dir = os.path.isdir(y)

            if FAST and not (x_dir or y_dir):
                continue

            result = {'A': (x, x_dir), 'B': (y, y_dir)}

            str1, str2 = x, y
            if not x_dir:
                str1,_ = os.path.splitext (x)
            if not y_dir:
                str2,_ = os.path.splitext (y)

            result['factor'] = compare (str1,str2)
            results.append(result)

        lst2.remove(x)
        count += 1
        print >> sys.stderr, '%.2f%% done' %((count / len_lst)*200)

    show(results)

def split (str1):
    trans = string.maketrans(SEP, ' '*len(SEP))
    return str1.translate(trans).split()

def clean (lst):
    assert type(lst) == list
    return filter(lambda x: not x.isdigit(), lst)

def compare (str1, str2):
    """Return similarity factor as percentage"""
    aux1 = clean (split (str1.lower()))
    aux2 = clean (split (str2.lower()))

    set_or  = set(aux1) | set(aux2)
    set_and = set(aux1) &amp; set(aux2)

    return (float(len(set_and)) / float(len(set_or)))*100

def show (results):
    """Show most similar last"""
    for x in sorted(results, key=itemgetter('factor')):
        a,b = x['A'],x['B']
        if not b[1] and a[1]:
            a,b = b,a
        print '%.2f \t %s \t --> %s' %(x['factor'], a[0], b[0])

if __name__=='__main__':
    try:
        path = sys.argv[1]
    except IndexError:
        path = os.getcwd()

    main (path)
</pre>
<p>I don&#8217;t think any one is going to use it, but what the hell. It&#8217;s a big Internet ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2010/07/03/filename-comparator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cherokee v0.98: Jailbreak</title>
		<link>http://unixwars.com/2009/01/25/cherokee-v098/</link>
		<comments>http://unixwars.com/2009/01/25/cherokee-v098/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 21:40:27 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=209</guid>
		<description><![CDATA[It has been a while since my last post. Some rough month this has been, oh boy. Anyway, I wanted to let you know that we have released the new and improved Cherokee a couple of days ago. Since the project has advanced so much over the last months, we have decided to boost the [...]]]></description>
			<content:encoded><![CDATA[<p>It has been a while since my last post. Some rough month this has been, oh boy. Anyway, I wanted to let you know that we have released the new and improved Cherokee a couple of days ago.</p>
<p>Since the project has advanced so much over the last months, we have decided to boost the release closer to the 1.0 milestone. Many things have been improved, in stability, features  and performance. The Windows build has received some attention, and though it still has a lot of issues, Stefan de Konik has built a <a title="Binary Windows build" href="http://kinkrsoftware.nl/contrib/cherokee/cherokee-win32-r2734.zip">beta Windows package</a> for people to try it out and help us sort out the rest of the problems. Great job as always, Stefan! The admin part is still not running under Windows, but you can always create the necessary config files on another environment and try out the Windows binaries.</p>
<p>In this release the caching mechanisms have been fixed, the web server can now be bound to multiple IPs and ports at the same time, a new balancing strategy has been added (so sticky sessions can now be implemented, for instance) &#8230;</p>
<p>To find out more about it, read the <a href="http://lists.octality.com/pipermail/cherokee/2009-January/009697.html">official release note for 0.98</a></p>
<p style="text-align: center"><a title="Cherokee Web Server" href="http://www.cherokee-project.com/"><img src="http://unixwars.com/wp-content/2008/03/cherokee.gif" alt="Cherokee Webserver" /></a></p>
<p>Try it out. Cherokee is the fastest web server there is right now.</p>
<p>Her you have some links:</p>
<ul>
<li>The <a href="http://cherokee-project.com/cgi-bin/mailman/listinfo/cherokee">mailing lists</a></li>
<li><a title="Donwload Cherokee 0.98" href="http://www.cherokee-project.com/download/0.98/0.98.0/cherokee-0.98.0.tar.gz">Download</a> link</li>
<li><a href="http://www.cherokee-project.com/doc/">Online documentation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2009/01/25/cherokee-v098/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cherokee on steroids: v0.11 now with reverse proxy</title>
		<link>http://unixwars.com/2008/11/27/cherokee-on-steroids-v011-now-with-reverse-proxy/</link>
		<comments>http://unixwars.com/2008/11/27/cherokee-on-steroids-v011-now-with-reverse-proxy/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 10:37:27 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Cherokee]]></category>
		<category><![CDATA[high performance]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=189</guid>
		<description><![CDATA[Yesterday we reached yet another milestone in Cherokee&#8217;s development towards World Domination. After almost a month of hard work, our newest creation hit the streets. The official anouncement hasn&#8217;t even been made yet, but Cherokee 0.11.1 is out in the wild. Besides our regular bug fixes and performance enhancements, it is shipped with some new [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday we reached yet another milestone in Cherokee&#8217;s development towards World Domination. After almost a month of hard work, our newest creation hit the streets. The official anouncement hasn&#8217;t even been made yet, but Cherokee 0.11.1 is out in the wild.</p>
<p>Besides our regular bug fixes and performance enhancements, it is shipped with some new features. SSI support was being requested every now and then, the SSL infrastructure has been reworked and the new <a href="http://en.wikipedia.org/wiki/Reverse_proxy">reverse proxy</a> is working flawlessly. The Windows build is not a reality yet, but great advances have been made towards that end. Cherokee is currently working under Windows, but the admin is not. And it has to be cross compiled, for now. Anyway, we&#8217;re one step closer to releasing a binary Windows build ;)</p>
<p style="text-align: center"><a title="Cherokee Web Server" href="http://www.cherokee-project.com/"><img src="http://unixwars.com/wp-content/2008/03/cherokee.gif" alt="Cherokee Webserver" /></a></p>
<p>We have a lot of fresh ideas, and as always feedback and feature requests are more than welcome at the <a href="http://cherokee-project.com/cgi-bin/mailman/listinfo/cherokee">mailing lists</a>. Here are links to <a title="Donwload Cherokee 0.11.1" href="http://www.cherokee-project.com/download/0.11/0.11.1/cherokee-0.11.1.tar.gz">download</a> and read the <a href="http://www.cherokee-project.com/doc/">online documentation</a> with tons of new information and recipes. Enjoy! ;)</p>
<p>UPDATE: Link to the <a href="http://lists.octality.com/pipermail/cherokee/2008-November/009398.html">official anouncement.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2008/11/27/cherokee-on-steroids-v011-now-with-reverse-proxy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python can do a lot of things</title>
		<link>http://unixwars.com/2008/11/20/python-can-do-a-lot-of-things/</link>
		<comments>http://unixwars.com/2008/11/20/python-can-do-a-lot-of-things/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 15:27:16 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=183</guid>
		<description><![CDATA[But it is not omnipotent. Leave that to Q. I stumbled upon this funny answer from back in 2005 and I had to share it. That guy is a genius! ;-) I&#8217;m curious how I can make Python print text in color. That depends strictly on your printer. With my hp LaserJet 1200, no way [...]]]></description>
			<content:encoded><![CDATA[<p>But it is not omnipotent. Leave that to Q. I stumbled upon this <a href="http://bytes.com/forum/thread22349.html">funny answer from back in 2005</a> and I had to share it. That guy is a genius! ;-)</p>
<blockquote><p><strong><em>I&#8217;m curious how I can make Python print text in color.</em></strong></p>
<p><em>That depends strictly on your printer.  With my hp LaserJet 1200, no way &#8212; not even Python&#8217;s power can overcome the hardware&#8217;s limitations in this regard&#8230; it&#8217;s a black-and-white printer and that&#8217;s all there is to it!  If I did have a color printer, then I would have Python produce the appropriate postscript code, or &#8220;escape-sequences&#8221; in whatever printer-specific language a given printer requires to have it output color text (or, depending on my operating system, printer driver, filters, etc, I might have to send appropriate &#8220;escape-sequences&#8221; or whatever to the DRIVER in order to convince it to drive the printer appropriately).</em></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2008/11/20/python-can-do-a-lot-of-things/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The family keeps growing</title>
		<link>http://unixwars.com/2008/11/14/the-family-keeps-growing/</link>
		<comments>http://unixwars.com/2008/11/14/the-family-keeps-growing/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 09:21:10 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=176</guid>
		<description><![CDATA[I posted a note about this at Cherokee&#8217;s main site, but I totally forgot to tell you over here. My bad. However, it&#8217;s never late to share good news. A couple of days ago Cherokee&#8217;s family incorporated a Polish Cherokee Community as new member! And they took a huge leap forward by creating Cherokee Polska, [...]]]></description>
			<content:encoded><![CDATA[<p>I posted a note about this at <a href="http://cherokee-project.com">Cherokee&#8217;s main site</a>, but I totally forgot to tell you over here. My bad.</p>
<p>However, it&#8217;s never late to share good news. A couple of days ago Cherokee&#8217;s family incorporated a <a href="http://lists.octality.com/pipermail/cherokee/2008-November/009303.html">Polish Cherokee Community</a> as new member!</p>
<p>And they took a huge leap forward by creating <a href="http://cherokee-project.pl">Cherokee Polska</a>, which isn&#8217;t just another site about Cherokee. So far they&#8217;ve translated everything, documentation included. And the effort has been worth it. They received thousands of unique visitors on their first day, and that is only the beginning.</p>
<p style="text-align: center;"><a href="http://unixwars.com/wp-content/2008/11/cherokee-polska-small.jpg"><img class="size-full wp-image-178 alignnone" title="cherokee-polska-small" src="http://unixwars.com/wp-content/2008/11/cherokee-polska-small.jpg" alt="" width="399" height="263" /></a></p>
<p style="text-align: left;">From here, I wish to extend my most sincere congratulations to these guys. Great work!</p>
<p style="text-align: left;">Since Cherokee has been steadily getting better and better, I expect more localization initiatives will keep popping up. We&#8217;ll see it in time. That&#8217;s a given.</p>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2008/11/14/the-family-keeps-growing/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New day, new release: Cherokee 0.10</title>
		<link>http://unixwars.com/2008/10/29/new-day-new-release-cherokee-010/</link>
		<comments>http://unixwars.com/2008/10/29/new-day-new-release-cherokee-010/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 12:49:13 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=171</guid>
		<description><![CDATA[We&#8217;ve been really busy lately. After my adventures in Venezuela at the Infociencias and the Open Source World Conference 2008 in Málaga -I know, I know&#8230; I still have to talk about that and post some photos, but the days are not long enough!-, we&#8217;ve finally made the time to polish some last details. Today, [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been really busy lately. After my adventures in Venezuela at the <a href="http://www.infociencias.org/">Infociencias</a> and the <a href="http://www.opensourceworldconference.com/">Open Source World Conference 2008</a> in Málaga -I know, I know&#8230; I still have to talk about that and post some photos, but the days are not long enough!-, we&#8217;ve finally made the time to polish some last details.</p>
<p>Today, <a href="http://lists.octality.com/pipermail/cherokee/2008-October/009123.html">Cherokee 0.10 has been born!</a> Even if you&#8217;re not into this FOSS World thingie, you should know that this is the <a href="http://www.cherokee-project.com/benchmarks.html">fastest web server</a> out there!</p>
<div class="entry">
<div id="awppost_140" class="awppost">
<div id="awppost_1_140" class="awppage">
<p style="text-align: center;"><a title="Cherokee Web Server" href="http://www.cherokee-project.com/"><img title="New Cherokee release hits the streets!" src="http://unixwars.com/wp-content/2008/03/cherokee.gif" alt="Cherokee Webserver" /></a></p>
<p>As always, stability and performance have improved, some bugs have been fixed and new features are available. Lately our <a href="http://www.alobbs.com/1344/MySQL_asynchronous_balancing_with_HTTP_JSON.html">MySQL load balancer</a> module has been attracting a lot of attention. Download <a href="http://www.cherokee-project.com">Cherokee</a> and follow the <a href="http://www.cherokee-project.com/doc/cookbook_dbslayer.html">cookbook</a> to give it a try.</p>
<p>As always, here yo have the list of relevant links:</p>
<ul>
<li>Alvaro’s <a href="http://lists.octality.com/pipermail/cherokee/2008-October/009123.html">official release note</a>.</li>
<li>Our <a href="http://cherokee-project.com/cgi-bin/mailman/listinfo/cherokee">mailing lists</a>.</li>
<li><a title="Download Cherokee 0.10.0" href="http://www.cherokee-project.com/download/0.10/0.10.0/cherokee-0.10.0.tar.gz">Download link</a>.</li>
<li><a href="http://www.cherokee-project.com/">Cherokee-Project’s</a> website.</li>
</ul>
<p>Handle with care: This baby is a heavy hitter by its own merits! ;)</p></div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2008/10/29/new-day-new-release-cherokee-010/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Cherokee 0.8.0 &#8220;Hard as a rock&#8221; released!</title>
		<link>http://unixwars.com/2008/08/14/cherokee-080-hards-as-a-rock-released/</link>
		<comments>http://unixwars.com/2008/08/14/cherokee-080-hards-as-a-rock-released/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 16:21:10 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Cherokee]]></category>
		<category><![CDATA[high performance]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=124</guid>
		<description><![CDATA[The day has finally arrived. After a lot of hard work, we are finally releasing 0.8. It has improved quite a lot in this time. It is faster, much more stable and has been thoroughly tested and documented, at last! Unfortunately not everything are good news. After putting in a lot of effort fixing the [...]]]></description>
			<content:encoded><![CDATA[<p>The day has finally arrived. After a lot of hard work, we are finally releasing 0.8. It has improved quite a lot in this time. It is faster, much more stable and has been thoroughly tested and documented, at last!</p>
<p>Unfortunately not everything are good news. After putting in a lot of effort fixing the Windows build, we finally decided to postpone this until <strike>0.8.1</strike> the next major release. It has been too long since the last release, and having so many improvements it doesn&#8217;t make much sense to hold the relase back just to offer it simultaneously to all platforms. This was the only thing holding us back beside some bugs that had to be fixed, so now this is our one big remaining task for the next release ;)</p>
<p style="text-align: center"><a title="Cherokee Web Server" href="http://www.cherokee-project.com/"><img src="http://unixwars.com/wp-content/2008/03/cherokee.gif" alt="Cherokee Webserver" /></a></p>
<p>This is our best release ever. By far. Improved performance, interface and documentation enhancements and lots of new features: much faster I/O cache, huge FastCGI performance improvement, updates (and binary upgrades) are now handled gracefully with no downtime, the load balancing is better and a lot more. Alvaro just sent the <a href="http://lists.octality.com/pipermail/cherokee/2008-August/008725.html">official release note</a> minutes ago.</p>
<p>We have a lot of fresh ideas, and as always feedback and feature requests are more than welcome at the <a href="http://cherokee-project.com/cgi-bin/mailman/listinfo/cherokee">mailing lists</a>. Here is the <a title="Donwload Cherokee 0.8.0" href="http://www.cherokee-project.com/download/0.8/0.8.0/cherokee-0.8.0.tar.gz">download link</a>. Enjoy it! ;)</p>
<p>UPDATE: I&#8217;ve just updated the <a href="http://www.cherokee-project.com/doc/">documentation</a> available at the site.</p>
<p>UPDATE: A quick update to fix some minor bugs has been released: <a href="http://lists.octality.com/pipermail/cherokee/2008-August/008749.html">Cherokee 0.8.1</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2008/08/14/cherokee-080-hards-as-a-rock-released/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Cherokee Quickstart</title>
		<link>http://unixwars.com/2008/08/07/cherokee-quickstart/</link>
		<comments>http://unixwars.com/2008/08/07/cherokee-quickstart/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 16:29:37 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Cherokee]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=120</guid>
		<description><![CDATA[Many users have told us that they would love to have some more documentation about Cherokee. One of the tasks before relasing 0.8 (which is almost ready by now) is documenting. Yesterday I wrote a small tutorial that will be part of the documentation. It is a simple walkthrough to set up a couple of [...]]]></description>
			<content:encoded><![CDATA[<p>Many users have told us that they would love to have some more documentation about Cherokee. One of the tasks before relasing 0.8 (which is almost ready by now) is documenting.</p>
<p>Yesterday I wrote a small tutorial that will be part of the documentation. It is a simple walkthrough to set up a couple of virtual servers, basic authentication (PAM and flat) and some redirections.</p>
<p>It will be available at the official site as soon as we make the release, at <a href="http://cherokee-project.com/doc">http://cherokee-project.com/doc</a></p>
<p><img class="aligncenter" src="http://unixwars.com/wp-content/2008/03/cherokee.gif" alt="" width="129" height="50" /></p>
<p>Here it is for now. No screenshots and not much styling in my blog, sorry. It&#8217;s just a  quick cut&amp;paste. There&#8217;s a lot of other stuff I should be documenting instead of blogging ;)</p>
<h2 id="_configuration_quickstart">Configuration Quickstart</h2>
<div class="sectionbody">
<div class="para">
<p>This section briefly describes the whole administration web interface provided by cherokee-admin. This is the only recommended way of configuring <em>Cherokee</em>. If you are looking for development information, you should refer to the appropriate section, especially cherokee.conf file specification.</div>
<div class="para">
<p>We will first show a quick overview of the available options, followed by a simple walkthrough. You can learn more about the options in their specific documentation entries.</p></div>
<h3 id="_overview"><span id="more-120"></span>Overview</h3>
<div class="ilist">
<ul>
<li>General:   There are a number of entries that specify the most significant   configuration options such as the port &#8211; or ports &#8211; that the server   will listen to, the default timeout, whether to support keep-alive   connections and so on.</li>
<li>Virtual servers:   If you want your web server to work with more than one domain you   will have to create Virtual   servers other than the <tt>default</tt> one. Each one will have a   completely independent configuration: paths, behavior, logging   facilities, etc.</li>
<li>Encoding:   The encoders allow to transform whatever information the server is   sending as a response of a request, no matter what handler is   generating it.</li>
<li>Icons:   Associate icon images with one or more file extensions. Used to   offer directory listings.</li>
<li>Mime Types:   Manage MIME types.</li>
<li>Advanced:   This is to configure the most complex parameters of the server and how   it interacts with the operating system. If you are unsure about any of   the options here, better not mingle with them. Default values should   work just fine.</li>
</ul>
</div>
<h3 id="_walkthrough">Walkthrough</h3>
<div class="para">
<p>There is very little set up you must do to have a perfectly functional web server out of the box. <em>Cherokee</em>&#8216;s default configuration can be used to serve any typical PHP-driven dynamic website.</div>
<div class="para">
<p>If you have a specific need, you should check out the recipes present in the <em>Cookbook</em> section of the documentation. Among other subjects, you can find information about <em>Cherokee</em> optimizations, setting up efficient Authentication mechanisms, or configuring several popular application frameworks.</div>
<div class="para">
<p>In this tutorial we will be setting up a system with a couple of virtual servers, PHP support, some redirection rules and a simple authentication mechanism.</p></div>
<div class="para">
<p>To follow this walkthrough you need to be running cherokee-admin. This is an administration tool, so you will need system administrator rights.</p></div>
<div class="listingblock">
<div class="content">
<pre><tt># cherokee-admin
Cherokee Web Server 0.8.0 (Aug  6 2008): Listening on port 9090, TLS disabled,
IPv6 disabled, using epoll, 1024 fds system limit, max. 507 connections,
single thread, 1016 fds
Server 0.8.0 running.. PID=19611</tt></pre>
</div>
</div>
<div class="para">
<p>Now you can access the administration interface simply by opening your web browser and visiting http://localhost:9090</p></div>
<div class="para">
<p>If your user doesn&#8217;t have enough privileges you will be notified. Also if no configuration file exists you will be prompted to create one with the default settings.</p></div>
<div class="para">
<p>That is a good starting point. Right now your web server will not be running yet. We will only be using two of the available tabs to adjust some more settings: General and Virtual Servers.</p></div>
<div class="para">
<p>Of course, once we&#8217;re done we will have to apply our changes and launch the server. The configuration changes must be submitted to the server, be it automatically if possible or by using the appropriate form submitting buttons. But no change is reflected in the configuration file until you <tt>Apply</tt> the changes. You can be sure of not damaging anything while playing around with <tt>cherokee-admin</tt>. At least not until you <tt>Apply</tt> the changes. Note that, if the <em>Cherokee</em> server is running, the applied modifications will also affect the instance being executed.</div>
<div class="para">
<p>We will only be modifying the <strong>Server Permissions</strong>. It usually is a poor choice to run services with super user privileges. Set both <strong>User</strong> and <strong>Group</strong> to <tt>www-data</tt>. Your system might already have another user account specifically for the purpose of running a webserver. Use that instead if so, or create the <tt>www-data</tt> user if you don&#8217;t already have one.</div>
<div class="para">
<p>Next is the Virtual Servers tab.</p></div>
<div class="para">
<p>When you start, you will only have one virtual server called <tt>default</tt>. You can begin by cloning it as <tt>example</tt>. While you are at it you should also append the following line to your <tt>/etc/hosts</tt> file (in Windows you will find this as <tt>%WINDIR%\system32\drivers\etc\hosts</tt>).</div>
<div class="listingblock">
<div class="content">
<pre><tt>127.0.0.1       example.net example.org</tt></pre>
</div>
</div>
<div class="para">
<p>This is to allow your system to resolve requests for <tt>example.net</tt> or <tt>example.org</tt> locally. Of course, once you are out in the Wild (you know, in the Internet), you will need proper DNS records.</div>
<div class="vlist">
<dl>
<dt> <strong><tt>default</tt></strong> </dt>
<dd>We will leave default untouched except for the document root path, which we will change. This is done through the <tt>Basics</tt> tab. You could create by hand <em>/var/www/default</em> for example and set it up in the appropriate field.</p>
<div class="para">
<p>If you access your machine by IP or a DNS resolution points in that direction for any particular domain, the contents of your document root directory will be exposed (<em>/var/www</em> by default unless you changed that during the build process). Whenever there is no match for a virtual server specifically defined in your list, the <tt>default</tt> virtual server will be the one responding.</div>
<div class="para">
<p>Right now any file with the <em>php</em> extension will be served after being processed by the PHP interpreter (you should have <tt>php-cgi</tt> installed in your system for this, though).</div>
<div class="para">
<p>Any requested file would be sent. If a directory is requested, a file called index.php or index.html will be served if it is present (the search will be performed in that order; you can configure this in the <tt>Basics</tt> tab). If not, a directory listing is offered instead. If you would want to prevent this behavior but would like to keep up serving whatever content is requested directly, simply change the <tt>List &amp; Send</tt> handler for the <tt>Static Content</tt> handler.</div>
</dd>
<dt> <strong><tt>example</tt></strong> </dt>
<dd>For now this virtual server is an exact copy of the untouched <tt>default</tt> virtual server. Create some new directories <em>/var/wwww/example</em> and <em>/var/wwww/example/auth</em>, and configure the first one as default document root path.</p>
<div class="para">
<p>Next, setup <tt>example.net</tt> and <tt>example.com</tt> in the <tt>Domain names</tt> tab. We&#8217;ll erase everything in the <strong>Targets</strong> list within the <tt>Behavior</tt> tab, except the <tt>default</tt> rule. With this we&#8217;ll only be able to serve static content.</div>
<div class="para">
<p>Accessing the URL http://example.org should now show a list of available files and directories under <em>/var/www/example/</em>.</div>
<div class="para">
<p>Now lets password protect the <tt>auth</tt> directory. Add a new <tt>Directory</tt> class rule pointing to <tt>/auth</tt>. Then, through the <tt>Security</tt> tab, add a <tt>Validation Mechanism</tt> under <tt>Authentication</tt>.</div>
<div class="para">
<p>The field <tt>Realm</tt> is mandatory. Lets set it as <tt>Secured Area</tt>. If you choose <tt>PAM</tt> and impose no more restrictions, only users with a local account in your system will be able to access the secured zone at http://example.net/auth Other mechanisms would work in a similar fashion but with their specific requirements. For example, had you chosen <tt>Plain text file</tt> instead of PAM you would have had to specify a <tt>Password File</tt>. For example, it could have been <tt>/var/www/passwords.txt</tt> with the following contents:</div>
<div class="listingblock">
<div class="content">
<pre><tt>testuser1:password1
testuser2:password2</tt></pre>
</div>
</div>
<div class="para">
<p>Note that the rule must not be flagged as <tt>Final</tt>, or else no other rules will be applied afterwards and no access will be given to any contents. This is because at this point we have not defined any handler for the <tt>/auth</tt> rule and nothing would be served.</div>
<div class="para">
<p>Refer to the Cookbook for detailed examples on the different options.</p></div>
<div class="para">
<p>Lastly, lets configure a redirection rule by choosing a &#8220;Regular Expression&#8221; as the new rule type. Type the following regex: <tt>^/rss.*$</tt> Then, within the <tt>Handler</tt> selection tab specify a target: <tt>/feed</tt></div>
<div class="imageblock">
<div class="content"><img title="Regex" src="file:///home/taher/src/cherokee/trunk/doc/media/images/admin_rule_regex.png" alt="Regex" /></div>
</div>
<div class="para">
<p>And voilà! A request of the form http://example.net/rss2 would be redirected to http://example.net/feed</p></div>
<div class="para">
<p>Note that the <tt>Type</tt> of the <strong>Redirection</strong> is <tt>External</tt>. This means the server will instruct the requesting web client to fetch the redirected URL, which means the client will allways know what the final URL is. This also means the redirection can be done to servers other than your own. If it were internal, the redirection would be invisible (no URL rewrite), but if it was done to an external server the <tt>Virtual Domain</tt> setting wouldn&#8217;t apply and your <tt>default</tt> virtual domain would have to handle the connection. Having the theoretical content hosted elsewhere, an error would occur.</div>
<div class="para">
<p>A much more general redirection could be one using these values:</p></div>
<div class="vlist">
<dl>
<dt> <strong>Regular Expression</strong> </dt>
<dd><tt>^/(.*)$</tt></p>
</dd>
<dt> <strong>Substitution</strong> </dt>
<dd>http://www.example.com/example.net/$1</p>
</dd>
</dl>
</div>
<div class="para">
<p>Note that this rule would have to be external since <tt>example.com</tt> is not among the domains managed by our configuration.</div>
<div class="para">
<p>This would redirect every petition to a site hosted under <tt>http://example.com/example.net</tt>. For instance, the request for <tt>http://example.net/image.jpg</tt> would return <tt>http://example.com/example.net/image.jpg</tt></div>
</dd>
</dl>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2008/08/07/cherokee-quickstart/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Cherokee on Windows: improving the building environment</title>
		<link>http://unixwars.com/2008/07/17/cherokee-on-windows-improving-the-building-environment/</link>
		<comments>http://unixwars.com/2008/07/17/cherokee-on-windows-improving-the-building-environment/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 11:19:49 +0000</pubDate>
		<dc:creator>Taher Shihadeh</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Cherokee]]></category>

		<guid isPermaLink="false">http://unixwars.com/?p=106</guid>
		<description><![CDATA[As it was anounced some time ago, Cherokee 0.8 will once again have a native Windows binary. We&#8217;ve been having a lot of requests because our Windows users haven&#8217;t had the chance to taste Cherokee-Admin since it was born. Beware that the Windows build has to be taken with a grain of salt under Windows. [...]]]></description>
			<content:encoded><![CDATA[<p>As it was anounced some time ago, Cherokee 0.8 will once again have a native Windows binary. We&#8217;ve been having a lot of requests because our Windows users haven&#8217;t had the chance to taste Cherokee-Admin since it was born.</p>
<p>Beware that the Windows build has to be taken with a grain of salt under Windows. A lot of work is still needed since some major changes -like a totally rewritten I/O cache, a lot more efficient and stable- will be coming by the time 0.8 is released.</p>
<p style="text-align: center"><a title="Cherokee Web Server" href="http://www.cherokee-project.com/"><img src="http://unixwars.com/wp-content/2008/03/cherokee.gif" alt="Cherokee Webserver" /></a></p>
<p>These are the necessary steps to setup a suitable building environment.</p>
<p>Like <a href="http://www.alobbs.com/1336/Cherokee_Windows_build.html">Alvaro said</a> in his blog, installing the whole bundle of needed tools is not trivial. In fact, there was a strange problem with the provided autotools (automake 1.8.2 and autoconf 2.59) of the previous environment that made us have to manually tweak things in order to successfuly finish the compilation of Cherokee. This has been tested on a Windows XP virtual machine.</p>
<p>This is what you need to install.</p>
<h3><span id="more-106"></span></h3>
<h3>MinGW: minimalist GNU for Windows (GCC &amp; binutils)</h3>
<ul>
<li> Download <a href="http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe?modtime=1209244789&amp;big_mirror=1">MinGW</a> release 5.1.4 at the time of this writing.<a href="http://downloads.sourceforge.net/mingw/MinGW-5.1.4.exe?modtime=1209244789&amp;big_mirror=1"><br />
</a></li>
<li> Run it and select &#8216;Candidate&#8217;. Check base tools &amp; g++</li>
<li> Install in a directory with no spaces (the default directory C:\MinGW is fine).</li>
</ul>
<h3>MSYS: Minimal SYStem</h3>
<ul>
<li> Download <a href="http://downloads.sourceforge.net/mingw/MSYS-1.0.10.exe?modtime=1079444447&amp;big_mirror=1">MSYS</a>, tests were made with release 1.0.10</li>
<li> Install it in the same directory as MinGW (remove &#8220;1.0&#8243; from the install path).</li>
<li> Answer y, y, c:/MinGW</li>
<li>You should add something like this to your ~/.profile to process your preferences:</li>
</ul>
<pre class="prettyprint">if [ -f ${HOME}/.bashrc ] then
  . ${HOME}/.bashrc
fi</pre>
<h3>MSYS DTK: Dev Toolkit</h3>
<ul>
<li> Get <a title="http://prdownloads.sourceforge.net/mingw/msysDTK-1.0.1.exe?download" rel="nofollow" href="http://prdownloads.sourceforge.net/mingw/msysDTK-1.0.1.exe?download">DTK</a></li>
<li> Install it in the same path as above</li>
</ul>
<h3>Update Autoconf &amp; Automake</h3>
<ul>
<li>Something strange happened as I said above, so I had to manually upgrade both to recent versions. I simply matched the ones I have in my Linux box and got it working. Afterwards I found packages with just that, so just install these <a href="http://downloads.sourceforge.net/mingw/autoconf-2.61-MSYS-1.0.11-1.tar.bz2?modtime=1206460029&amp;big_mirror=1">autoconf</a> and <a href="http://downloads.sourceforge.net/mingw/automake-1.10-MSYS-1.0.11-1.tar.bz2?modtime=1206460075&amp;big_mirror=1">automake</a> and you&#8217;re good to go.</li>
</ul>
<h3>Pthreads Win32: POSIX Threads</h3>
<ul>
<li>Cherokee will need these. Just download ftp://sourceware.org/pub/pthreads-win32/dll-latest/ and copy the appropriate files to /lib and /include</li>
</ul>
<h3>Python</h3>
<ul>
<li>You will need this, since both the build process and Cherokee-Admin use Python. Just download a <a href="http://python.org/ftp/python/2.5.2/python-2.5.2.msi">Python Windows installer</a>, remember to include the directory in your path environment variable, and you&#8217;re done</li>
<li>rxvt seems to be broken, which is most noticeable when you try to run Python interactively, so I just comment out its line in msys.bat.</li>
</ul>
<h3>Nice to have:</h3>
<p>If you want to do something more than just building the binaries, you should also consider installing the usual tools: SVN, Emacs, gdb&#8230; Remember including them in your path.</p>
<h3>Configuring and building:</h3>
<p>After setting your environment you&#8217;ll have to change slighlty the configure command because there is still a problem with readdir_r. Hopefully it will be solved shortly.</p>
<pre class="prettyprint">./autogen.sh --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
--enable-trace --enable-static-module=all --enable-static         \
--enable-shared=no --enable-beta --disable-readdir_r</pre>
<p>And that should be it.</p>
<p>If you still have some kind of problem you could always try out this <a title="MinGW bundle to compile Cherokee for Win32" href="http://cherokee-project.com/download/windows/Win32_Building_Environment.rar">working bundle</a> that I&#8217;ve just uploaded to cherokee-project.com and extract it in C:\, but I&#8217;m unsure if it would work before at least using the installers for MinGW and MSYS. I haven&#8217;t tried, but it wouldn&#8217;t surprise me if some DLLs were needed in specific places. After that, using my package should probably be OK. As I&#8217;ve said some times now, I don&#8217;t do Windows so I&#8217;m afraid I won&#8217;t be of much help here.</p>
<p>Have fun, and good luck. We&#8217;ll keep you informed.</p>
<p>UPDATE: If you&#8217;re still having trouble with this, Alvaro wrote <a href="http://www.alobbs.com/1342/Win32_compilation_environment.html">an update to this</a> that will hopefully be the last one we need.</p>
]]></content:encoded>
			<wfw:commentRss>http://unixwars.com/2008/07/17/cherokee-on-windows-improving-the-building-environment/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

