Supybot & pisg

Perl is back ? :)
In a previous life, i used Perl for a while. So tonight when i found that <a href=http://pisg.sourceforge.net/>pisg</a> doesn’t support Supybot log file, i decided to give it a look. To adapt it, it’s only a matter of regex. Beside i’m not a regex guru, i managed to make it work without too much pain so :

– Enjoy perl ? not really regex yeah !

Securing courier-imap

I spent part of the day to install a virtual mail server, and i discover that there is a really simple way to secure courier-imap. By defaut when you use this kind of server the auth is made against the standard pam module. This is really simple, but what happend if someone is able to read your imap password. Yes he get the account password.

Courier imap can do the auth against a lot of stuff. Simply change the authmodulelist=authpam to authmodulelist=authuserdb. This will use the file /etc/courier/userdb.

userdb "username" set home=/home/username
                      mail=/home/username/Maildir
                      uid=UID gid=GID
userdbpw | userdb "username" set imappw
makeuserdb

So now you can use a different password for your account and your imap, and you can choose who can access to imap server.

Installing Debian on a Dell Latitude D400

Introduction

At my work, some people have bought some D400 laptop to use Linux.
During the installation, we run into various issues. This short
document try to explain, how we managed to have a working Debian
on this.

For various reasons, we want to use a debian and this doc is
about this, but take care that installing a Redhat or a Mandrake
is really easier than a debian of this kind of laptop. I hope
debian developpers will fix this soon.

Latitude D400

  • Celeron (centrino) 1.4 Ghz / 512 Mo of RAM / 30 Go
  • CDROM / Floppy drive: USB combo
  • network card: 1Gb Broadcom BCM5700
  • sound / video : Intel 82845G
  • Wifi: True Mobile

Base Installation

First we downloaded the latest debian iso (a woody). The main
problem is that despite the bios can boot the OS using the
USB cdrom, after the woody CD boot, you can’t access to
the cdrom content, because debian developper forget to put
the usb-storage in the initrd.img. (this works fine on
RH .. ). My first try was to rebuild the debian boot system
with the debian boot-floppies package. After a try i discover
that usb-storage doesn’t detect the usb cdrom when you
compile it in the kernel, so i need to use it as module
in initrd, but i decided to try another method.

I used a windows FAT filesystem:

  • boot windows XP (provided by dell)
  • create a new partition of 1Go ( you will use this as swap after the install)
  • copy the debian content on this
  • copy the BCM5700 driver on this too
  • reboot / press F12 to boot on the debian CD
  • after the boot : press ALT-F2 to open a empty console
  • mkdir /remote
  • mount the fat fs on this: mount /dev/hda3 /remote
  • go thought the installation process, when it ask
    for the default debian package, simply choose:
    ‘mounted partition’ ‘/remote’
  • and do a normal install
  • WARNING don’t install the PCMCIA modules, because it will lock the boot process (as on every Dell !! )

Finishing the install

As i want to have a recent OS, i choose to install
the testing, so simply install from the CD:

  • kernel-header for the current kernel (bf24)
  • install gcc / make / unzip
  • build the BCM5700 driver
  • and load it in the kernel.
  • simply configure the network w/ ifconfig / route
  • now you can use a ftp to continue the install in testing
  • apt-get update / dist-upgrade
  • install latest kernel (2.4.24 for me)
  • rebuild the BCM5700 for this kernel

X / Sound / PCMCIA / ACPI

Now we have a debian testing running, we can configure it.

XFree

  • download Intel 82845G driver
  • make / install / insmod it (agpgart / i830)
  • add them to /etc/modules
  • download the 855 patch
  • build this patch and run it ./855patch 32768
  • this will allocate 32Mo of memory for the video card
  • put this in your /etc/init.d/bootmisc.sh to have this at every boot
  • install the XFree 4.3 (from unstable since it’s not in testing right now) (it won’t work with 4.2)
  • XFree should now detect a i830 video card (it won’t do if you aren’t using intel’s agpgart )

Sound

  • load the i810_audio module (to use gnomeetting use Alsa one)
  • put it in /etc/modules to have it a boot

PCMCIA

  • One every Dell, default PCMCIA settings will block the system so:
  • apt-get install pcmcia-cs / modules
  • when it ask for starting it answer: NO !!
  • edit the /etc/pcmcia/config.opts
  • and change include port to: include port 0×100-0x4ff, port 0xc00-0xcff
  • now you can start it :)

ACPI

To enable the support for acpi in the default debian kernels you should
append the acpi=on at boot.

  • Add this “append=”acpi=on” to the lilo.conf
  • apt-get install acpid
  • now the power button should stop the laptop
  • the acpi sleep command doesn’t work right now, so you can’t do ‘suspend
    to ram’ or ‘to disk’, but this should be avalaible in kernel soon.

Slides in Py

Tomorrow, i will teach Python to my students (i work in a school as developper) so, sometimes someone ask me for a python introduction. I usually make my slides w/ OO or full html + custom CSS. Today while trying to build the slides i remember that i’ve already found
Pylize .

I do the same with a python build.py (split html into piece and add shortcup for next and previous), but this one really seems good. The only thing, that I don’t really like, is the lack of printing support, nice slides is not enough for today’s student, they want a pretty print too :)

Enjoy Mutt

I get it! I managed to use mutt w/ my imap folders, with hooks and everything fine. This is not really hard, but :

  • libsas-modules break the SSL certification (without any error message)
  • mutt really lack of header cache for imap (there is a patch for Maildir but no for imap)
### IMAP ########################################
set imap_user="jkx"
set spoolfile=imaps://mail.larsen-b.com/
set folder=imaps://mail.larsen-b.com/INBOX
set record=imaps://mail.larsen-b.com/INBOX.Sent
mailboxes  imaps://mail.larsen-b.com/

### Hooks #######################################
folder-hook INBOX.Sent 'set index_format="%4C %Z %{%b %d} %-20.20t (%41) %s"'
folder-hook INBOX.JOB my_hdr From: XXXXX <XXXX@job.fr>

P2P filesystem

Yesterday i dreamed about a P2P filesystem. I found AVFS, a virtual file system, that enable the use of normal file like .tar.gz as normal file system. You can cd in and edit files like they are on the fs. And now i’ wondering how it will be to use bitorent and a Fuse python binding (fuse is a part of AVFS), to do something like this. At Finix (french Lug), there is a some community and sharing file between us is a bit paintfull. We need to put it somewhere and send a email over the list, as files are usually big (mainly photos collections), we can’t put it on ADSL. (making a host unreachable to since the 30 members download the file is not a good way. And doing something like cd /mnt/finix/ to access the shared space will be really great. Of course this won’t work for M$ users but we are a Lug so we don’t use M$ :)

Of course we can to this w/ python-LUFS to, but i find fuse more stable and easy to use .. so anybody want to give it a try ? Is there some cheap bounties (i don’t have a lot of bulks, but i can pay a little for the fuse python binding..)

Cheap python hosting

So now, it get to much hits to keep this website on my ADSL line. I don’t want to block users while i’m downloading files (have you try the last Unreal Tournament ?) with bitorent. As i’m searching for something cheap, and enable to host some python (and w/ ssh acces will be wonderfull) i run into trouble. There is a lot hoster in the place, but having python is another thing. And look for webware is really a pitty. So i decided to rent a dedicated server, but this isn’t really cheap. After looking on other weblogs i discover that some of you use ‘a virtula server’. This things is just a User Mode Linux that run on a remote host, so can have root access do want you want without to much pain (no install fee, not so expensive..). So let’s go .. I have a lot os things to put on the new server, but it has a good bandwith and cost only 15Euro / months for a 128Mo ram / 4 Go disk space. Alinea is not ready for the migration, but i guess i will do that quikly ..

ZPT metal:use-macro: the un-natural way

As i’m looking for a way to build page by ‘piece’ in Zope Page Templates, macros come to my mind. But macros are usually used with the ‘slot’ behaviour. This is really a nice design, but it’s too hard to maintain for a small app like, i wan to write.
Let’s take a example:

<html metal:use-macro="here/main_template/macros/main">
 <body>
   <span metal:fill-slot="content">
   This is the content ..
   </span>
</body>
</html>

This will call the main_template page template for the general look and feel, and simply insert the ‘slot’ content in, at the rendering call.

So if you have all pages w/ the same layout this can be really a simple way to do this.

But if you want to have a lot a different layout in the website, this can give you some headhache, because you will need to write a lot of template and fill slot in.

Another way to do this is to call a PT in another one:

<span tal:replace="here/templates/menu"> menu go here</span>

This is really more easily to build pages with different layout, but we need to understand how it works. It will __call__ the rendering on all parts of the template, so you can heat a lot of cpu with that. In a previous review, i discover that Nuxeo CPS use this kind of integration, and the results are really bad: calling 15 times pt.render() in a single page give me 5 seconds to render it.

After a little talk with other project developpers i went to the third way, the un-natural one, but the one that is simple and give me good performance too.
The main idea is to use the macros to build to parts of the page and to include them at the rendering call. (think as a include() in php).
I put all the parts in a file slots_template.pt

<!-- Banner -->
<div metal:define-macro="banner" id="banner">
 <div class="site_name">
  <a href=# tal:attributes="href config/site_url" tal:content="config/site_name">Site Name</a>
 </div>
</div>
<!-- side -->  ....

And not to include it in a page: i simply call

<div metal:use-macro="here/slots/macros/banner" />

So now i can build page w/ only a couple of macros call, and too much pain. There is a drawback of course, you can’t call in slots methods that the current page don’t know. so writing thrue slot can be included in a page without knowing the page context (like in method 2) but this isn’t a big deal, and you can simply use a aq_parent to do that. ( or play w/ getattr )

Importante note: I use this stuff in Webware, but in Zope you can do the same things.. the major difference is that Zope have aq_parent and can cache (without any code) the pt.render() so second way can be use without too much drawback.

SupyBot

http://supybot.sourceforge.net (SupyBot) is the coolest ircbot written in python, that i’ ever used. After 3 years of good work with eggdrop, it’s time to use something more userfriendly and python based.

This is a short introduction to use it:

  • download and install it (python setup.py install) as usual
  • run the supybot-wizard to build your own bot script
  • call supy-adduser script to add you as a user of the bot, don’t forget to add the ‘owner’ capabiliy.
  • run the bot.

Some usefull commands:

  • @ / msg : to send a command to the bot, simply post @dummy_command or send it to bot directly (/msg)
  • to load a plugin: @load plugin_name
  • to identify yourself (users are in conf/users.conf) /msg bot identify login password
  • @list : list (w/o argument) will return the plugin list
  • @list Plugin; will give you function of the plugin
  • @help plugin ../ @apropos: give help about commands.
  • @services getops: ask the op for the bot at chanserv

How auto-op works:

The main purpose of an ircbot is to give op right at the user join. To do this you need to:

  • @enforcer config auto-op true : ask the ircbot to do auto-op
  • add the capabily ‘auto-op’ to the user: @addcapabilty login auto-op
  • Now when the user identity himself, he will be oped by the bot
  • the next step is to play w/ hostmasks to avoid the need of identify
    call @hostmasks login to see the hostmasks for a user / and add/delhostmasks to set masks need to do this. for exemple: addhostmask jkx ‘soif!~soif@*.abo.wanadoo.fr