Category: Open Source

Using Mantis with a reduced mail() function

Mantis is a free web-based bug tracker. As most web trackers, it uses e-mail to notify testers and developers about the evolutions of issues they have reported or they just follow. For that purpose, Mantis uses Codeworx PHP Mailer class that gives you the opportunity to use the PHP mail() function, sendmail or a SMTP server to send those e-mails.

The use of the PHP mail() function is the default option. Unfortunately, some web hosting companies limits the PHP mail() function by forbidding the use of the 4th and 5th (optional) parameters. The result is that you can’t use the e-mail functionality of PHP mailer / Mantis because they use the 4th parameter.

The solution is to edit the file class.phpmailer.php in the directory mantis-dir/core/phpmailer/. Inside the file, look for the two lines containing the string “@mail” and replace the 4th argument by the e-mail address where the e-mail will be sent from. Example:

   $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
         "From: \"mybugs - Mantis bug tracker\" <me@domaine.tld>");
}
else
   $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
         "From: \"mybugs - Mantis bug tracker\" <me@domaine.tld>");

Now you have a fully functional bug tracker 🙂

Short script to add a timestamp on pictures

Here is a short script (1.6kb) to add a timestamp on all PNG pictures in a directory. It requires Python and the Python Image Library (PIL). In order to use it, modify some parameters in the beginning to suit your needs (images directory, font file and size, etc.) and launch ./timestampFiles.py. Here is a before/after example (size of pictures is reduced to fit in this blog):

Before/after example of adding a timestamp to a picture

Note 1: the font is not included in the script. Here, I used FreeSans which is a true free font (GNU GPL with font exception). It is available here (local copy, just the FreeSans font, 753kb).

Note 2: I chose to convert PNG images to JPG ones for 2 reasons. First, my capture script gives me PNG images (see previous posts). Second, I want to be able to copy all JPG pictures in a MJPEG movie. It shouldn’t be difficult to change the different file formats to suit your needs (ask me if you can’t do that).

Note 3: I guess this would also have been possible using a bash script and imagemagick, Perl or any other programming language 😉

Taking automated screenshots from a live video camera

Following my previous post, I attached a video camera to the composite input of my tv tuner. One good thing I didn’t noticed yesterday is that mplayer can be told to directly use pvr:// as a source instead of the generic tv:// (with many options). So you just have to enter mplayer pvr:// -tv device=/dev/video1:input=0 in order to watch tv.

Noticed the input=0 above? This tells the tuner to take the video signal from the tv (read the mplayer man page to see how to change the channel). Now, since I connected my video camera to the composite video in, I need to tell mplayer to use it with input=1. One last thing: taking a screenshot in mplayer is done by pressing the ‘s’ key (with option -vf screenshot. In summary, the image below was taken with mplayer pvr:// -tv device=/dev/video1:input=1:noaudio -vo x11 -vf screenshot
(camera facing the screen).

blurry capture of computer screen taken by camera connected to tv tuner

Now I want to take one screenshot every 5 seconds, even when I’m not there to press the ‘s’ key! For this purpose, we need to use a fifo file and mplayer in slave mode. Mplayer in slave mode will listen to commands we automatically send into the fifo file (by a different process, see below). This is how we do this:

mkfifo myfifofile.tmp
mplayer -slave -input file=myfifofile.tmp pvr:// -tv device=/dev/video1:input=1:noaudio -vo x11 -vf screenshot

And from another console, we can type echo "screenshot 0" >> myfifofile.tmp to take the screenshot. To automate all this, the following simple bash code is sufficient:

#!/bin/bash
# will send mplayer screenshot command every 5 seconds to fifo file
# stop this with Ctrl + C
LIMIT=0
while [ $LIMIT -lt 1 ]; do
echo "screenshot 0" >> myfifofile.tmp
sleep 5
done

In the end, stop the bash script with Ctrl + C and quit mplayer with echo "quit" >> myfifofile.tmp.

A first step toward TV on my Linux laptop

I recently got a Hauppauge WinTV-PVR-USB2 (a TV tuner, video recorder and FM receiver) because I read it was well supported on GNU/Linux. The following post explains how I installed it on a Fedora Core 9. If you want to install it with another Linux distribution, some information may vary but most of the following steps will be exactly the same.

First connect the USB device, the list of USB devices shows my system has recognised it:

[root@localhost ~]# lsusb
Bus 002 Device 003: ID 2040:2900 Hauppauge
...
[root@localhost ~]# dmesg
usbcore: registered new interface driver pvrusb2
pvrusb2: Hauppauge WinTV-PVR-USB2 MPEG2 Encoder/Tuner : V4L in-tree version
pvrusb2: Debug mask is 31 (0x1f)
firmware: requesting v4l-pvrusb2-29xxx-01.fw
pvrusb2: ***WARNING*** Device fx2 controller firmware seems to be missing.
pvrusb2: Did you install the pvrusb2 firmware files in their proper location?
pvrusb2: request_firmware unable to locate fx2 controller file v4l-pvrusb2-29xxx-01.fw
pvrusb2: Failure uploading firmware1
pvrusb2: Device initialization was not successful.
pvrusb2: Giving up since device microcontroller firmware appears to be missing.

Although my tuner is fully recognised, the system needs a firmware in order to make it work. Where is the firmware? A quick search on a well-known search engine redirects us to Mike Isely’s website where he explains how to get the driver (Mike actually also wrote the driver for this TV tuner). Although I got the CD with drivers for Windows, I prefer to use the latest driver that can be found on the Hauppage support website. Mike also writes you can get the driver from the ivtv project.

So I uncompress the driver in the “win_driver” directory and launch Mike Isely’s fwextract.pl script:

[jepoirrier@localhost hauppauge]$ mkdir win_driver
[jepoirrier@localhost hauppauge]$ unzip hauppauge_cd_3.4d1.zip -d win_driver/
[jepoirrier@localhost hauppauge]$ ./fwextract.pl

The script extracted 4 drivers (2 decoders and 2 encoders) and dmesg already told me the two I need: v4l-pvrusb2-29xxx-01.fw and v4l-cx2341x-enc.fw (as encoder). To know where to put these files, check a little bit on the web (this depends on your GNU/Linux distribution). On the Fedora Core 9, it’s in /lib/firmware, so:

[root@localhost hauppauge]# cp v4l-cx2341x-enc.fw /lib/firmware
[root@localhost hauppauge]# cp v4l-pvrusb2-29xxx-01.fw /lib/firmware

Unplug your USB cable, re-plug it and a dmesg should give you a long list of what your system detected, the most interesting part being the last line where it request the firmware and doesn’t stop: firmware: requesting v4l-cx2341x-enc.fw 🙂 Now check your video devices and you should have an additional /dev/videox:

[root@localhost hauppauge]# ls /dev/vid*
/dev/video /dev/video0 /dev/video1

In my case, /dev/video1 is the one I need …

Now, how to watch TV? TVTIME seems to be good but, unfortunately, my video card driver doesn’t support hardware YUY2 overlay (I have an ATI Radeon Mobility HD 2600 with the open source radeon driver). No problem: mplayer /dev/video1 shows a very beautiful snow. Now I need an antenna or a cable to connect to my tuner …

mplayer -vo x11 /dev/video1 -vf and then s

Watch your webcam with mplayer

A small post just to keep this command at hand:
mplayer -fps 30 -tv driver=v4l:width=640:height=480:device=/dev/video1 tv://
This allows you to watch what your webcam “sees” (provided it uses a video4linux webcam). Btw, Cheese is funny to use too!

I was also trying to find a decent Python library for video4linux but I only found outdated ones (libfg, 2003, and pyv4l, 2002). I guess I’ll have to use some C library for a small project I’ll tell you about later 😉

The "problem with TinyURL" is (partially) solved

Thanks to the free software project lilURL and one of its implementation at ur1, the problem with TinyURL is solved. Thanks Alexandre for the info. 🙂

So now http://www.poirrier.be/~jean-etienne/ can be short (http://ur1.ca/04d) and free at the same time: free to use, and free to look at source code.

Since I’m never fully satisfied (hmm, never say never), the next step would be an implementation of some “intelligence” in these short URLs (see Udi’s post). And since I never have time (or less and less), I’m a bit sad not to have that time to code a solution (which should be quite easy).

The problem with TinyURL …

The problem with TinyURL.com is that its source code is not free. And I can’t find any other open services/projects that offers the same features (1).

I realized this when trying to add a long link in a Twitter update (2, 3). A maximum of 140 characters doesn’t allow you to add much text around. And it seems that a lot of Twitter users are using the TinyURL.com service which allows you to translate a small URL it gives you to the full, “regular” URL. For example, http://www.poirrier.be/~jean-etienne/ (37 characters) becomes http://tinyurl.com/6kq84z (25 characters).

But … TinyURL is trademarked and its terms of services explicitely tell us they may report your activity to some “agencies” … In addition to the reasons why Udi hates TinyURLs, I wonder how is stored your URLs. Well, it’s not exactly “how?” but “with which additional information?”. I guess they store your IP address, ISP and location (to be able to report your activity to your ISP and U.S. agencies) along with your submition, date & time, … Nothing is said about privacy in their page. Nothing is said either about the time they will keep your URL (what if you try to use your TinyURL in 5 months or 5 years?). And obviously, no source code available. On the other hand, if you don’t want to use the service, you are also free not to use it.

The only problem is that I can’t find proper, free/open alternatives. There are dead/unborn projects like this one at Mozdev or url(x) (no, GiganticURL is not a solution 😉 ). And there is even a PEAR service to TinyURL. Decent URL is not a solution since it’s only a variation on TinyURL (still not open/free and nothing about privacy). BURL is often cited but the only link I have is broken.

It could be nice to have a TinyURL-like service with open source/free source code and a clear overview of privacy settings (why not à-la-carte settings defined when the user submit his/her long URL?). (Note that Udi also has interesting additional ideas in his previously cited post, mainly about knowing what kind of media you’ll get with the short URL)

(1) The first sentence of this post is a kind of “executive summary”. I hope I’m not getting too old to indulge myself in this kind of thing 😉
(2) Yes, I now have a Twitter account. I don’t know the real purpose of having this kind of thing along with my own blog. Let’s see …
(3) I know, Twitter doesn’t have an open/free source code too. But open source microblogging site may become Twitter fallback.

AEL-NG?

A few days ago, I was sad to see that the Association Electronique Libre (AEL) website was down and only replaced by two measly <html> tags. For those who didn’t know it:

The Association Electronique Libre is a belgian association protecting the fundamental rights in the information society.

The Association Electronique Libre supports the freedoms of speech, press, and association on the Internet and any electronical mediums, the right to use encryption software for private communication, the right to write software unimpeded by private monopolies, the right to access and preserve public domain and free digital information.
(from an old copy of the AEL website)

Although it was based in Belgium, the information it contained as well as the actions that were supported exceeded the small Belgian borders. The wiki was a very useful and valuable source of documents, links and comments about freedom in the electronic media. “Fortunately” we still have a 2007 version of the website on archive.org and some messages from the mailing-list were kepts on the mail-archive and open subscriber (and I will preciously keep my archives!).

Following a small exchange of e-mails with one of the main guy behind AEL, the machine hosting the AEL is simply dead (the fact the machine was dying was announced a long time ago, no one apparently reacted). I guess (or rather hope) that the data is still available on the hard disk(s).

Now what? Beside the fact we are all getting “older” with other priorities in life, how come we don’t feel more concerned about our freedom in the cyberspace? Internet liberties are still in danger [1], the Electronic Frontier Foundation website has more and more issues, a paper-media publishing house is printing comics to “educate teenage youth about an array of issues ranging from privacy, free software, security and the impact of politics on personal freedom as it relates to the use of technology”, … Are we too lazy to try to understand what’s behind Facebook, LinkedIn, Orkut, Ning and other “social networking websites“? Maybe the technological gap between these polished websites and what indivuals can do “in their garage” radically increased since the advent of so-called Web2.0, inhibiting our will to actively participate in it [2], to make it ours? Did most of us “surrender” in front of the razzle-dazzle aspects of new communication media?

The idea behind this post title (AEL – New Generation?) is simply that something should be done to bring back to life a central, hopefully community-driven website to gather information about our freedom in cyberspace …

[1] Ironically, in this post, this reference is written by the main person behind the AEL
[2] About the “creativity” of people in Web2.0 applications, we could read with interest this article from C. Jonckheere and F. Schreuer (unfortunately in French only)