Archive for python

pytemplate 1.5


pytemplate 1.5 is arrived, with 2 new features: daemon capabilities and signal handling. Go straight forward to  pytemplate project page to get it!

I’m also pleased to announce that it should be available on netBSD, thanks to imil.

Have fun.

Posted in python | 2 Comments

News about pytemplate: version 1.4.0 available!


pytemplate, the python template framework, is now in version 1.4.0. What’s new for this version? it uses optparse to create options, meaning that options can now be created easely from your program and that does not need to be modified anymore. It also means that this version is really able to be a pythondistributed module.

For more information, to download it,  go to the pytemplate project page.
deb and rpm package to install as a python distributed module are available at this page.
Have fun.


Posted in python | Leave a comment

pytemplate 1.3.1

You are welcome on my new small wiki to download the pytemplate-1.3.1!
If you want to participate to this project, do not hesitate to live a comment.
In the todo list, I have mainly the portability task on windows.
I’ve been using this framework for a few script, and be sure it really helps to go quick and not too durty.


Posted in python | Leave a comment

pytemplate: a main script template


If you want to start a python script and if the developper white page fears you, you are very welcome on this page. I have updated an old project of script template written in python.  You have only to think about what you want to do, the script will handle other stuffs, like parameters, logging function. If you want to dowload the script, you can go on the project page, or download it directly.

Also available a debian building environment, where you will have to replace all the pytemplate references by the name fo your package. Be carefull, using this building environment, I advise you the new debian maintainer’s guide if you are not familiar the debian policies.

Comments are very welcome.


Posted in python | 2 Comments

A python script template for main


Today, I propose a template for your python scripts. You can use it as you want when you need to create a script. If you want to modify it, go ahead, but let me know…

By default, with this script, you can manage -h for help, -c for config file, -v for verbosity, you can also enter parameters. It will by default use the system stdin and stdout, and will log on error.log the stderr.

If you have trouble to use this script, do not hesitate to contact me through this blog.

To download the, go to the project page.

Regards and have fun.


Posted in python | Leave a comment

My patch pour keyboardinterrupt

--- backuo/       2007-10-19 13:54:25.000000000 +0200
+++      2007-10-19 14:19:54.000000000 +0200
@@ -130,6 +130,13 @@
                             line = raw_input(self.prompt)
                         except EOFError:
                             line = 'EOF'
+                        except KeyboardInterrupt:
+                            self.stdout.write('nare you sure you want to exit?
 y/n ')
+                            answer =''
+                            while (answer != 'y') & (answer != 'n'):
+                                answer = raw_input()
+                                if answer == 'y':
+                                    exit(0)    

Posted in python | Leave a comment

How to create a patch, how to apply it?


After having proposed a modification to on the lib in order to manage correctly, I have been asked for sending the associated patch… Of course, I will!.. But before, I need to learn how to make a patch. Here is the way to do it:

Let’s imagine I have my file that has a bug, and the that is the with the bug correction. to generate the patch, do:

diff -ruN >mypatch

-r is to do it recursively. In how case, not really useful, but you can create patch on directories.

-u will output 3 lines of unified context. Default is 3. -U4 will put 4 lines...

-N will be used to treat absent files as empty files. Same, in our case not useful, but usefull for patches on directories.

Now, how to apply a patch:

patch < mypatch for a file.
patch -pNUM < mypatch #where NUM is the recursive depth for directories

Here it is…

Let me know, if this helped!

That’s it, you have made a patch.

How to use it

Posted in python | Leave a comment

schemgen V2


Do you remember, my small python ldap generator? If you used it, probably, you got some troubles… Not really easy to use and a few bugs! I propose that you use this new version V2.0.

Go on the projects page

Have fun.


Posted in ldap, python | Leave a comment

python lib management of KeyboardInterrupt

Hello all,

You are a python user and you are used to import to generate a simple CLI, but disappointed with ctrl-C management that generates a KeyboardInterrupt error, well, I have submitted a proposal. You will be able to read it on .

Have fun

Posted in python | Leave a comment

python multhreading…


Python multithreating module is very easy to use. I have created this almost unuseful script to generate with an asterisk equipment calls to every 10 seconds.

For this you have to know that to generate calls with asterisk, you can send files ( in the /var/spool/asterisk/outgoing directory .

Here is a sample of file:

Channel: SIP/me

MaxRetries: 1

RetryTime: 60

WaitTime: 30

Context: me

Extension: you

Priority: 1

where me and you are declared channel in sip.conf

I have created the following script that sends every 10 sec the files into the good directory (first process) and notify the second process that a call has been generated.

#!/usr/bin/env python

import thread
import time
from threading import *
import subprocess

class call_gen(Thread):

def __init__(self,condition,sleeptime=10):

def run(self):

    while 1 :
        cond.acquire() #acquire the lock
        b = subprocess.Popen(['./'])

class Notifier(Thread):

    def __init__(self,condition,sleeptime=2):


    def run(self):

    while 1:
        print 'call has been generated'

if __name__=="__main__":

    while 1: pass

For information is a script that copy the and send it into the directory /var/spool…

Thanks to made by Krishna G Pai that really helped!

Have fun.

Posted in asterisk, python | Leave a comment

Swedish Greys - a WordPress theme from Nordic Themepark.