Learning to use decorators with classes

2009-06-30 Thread Mr SZ
Hi, I'm writing an LDAP plugin for my TG2 application. In this I wrote a small class based decorator with args to set up a connection and call the necessary functionality but I'm having problems with it. Here's my code: class getConnection(object): def __init__(self, settings, credentials)

Find the name of a setup tools plugin when its class is known.

2009-06-29 Thread Mr SZ
Hi, Using pkg_resources, I can iterate through the plugins in an entrypoint and note down the plugin classes and all using "pkg_resources.iter_entry_points(ENTRYPOINT)" Now, when the plugin is loaded, I want to know it's entrypoint name as I have to load a bunch of settings identified by the

getattr on a function

2009-04-27 Thread Mr SZ
Hi all, Is it possible to call functions using getattr. I have written a simple script with functions that call either SSL, TLS or plain functionality. something like: def func(): ... def funcSSL(): ... def funcTLS(): ... Now, based on my args I would like to call either one of them. I

imaplib thread method anomaly

2009-02-03 Thread Mr SZ
Hi, I was looking at the thread functionality of IMAP4rev1 servers with the threading extension. Here is my output with debug=8 : 02:23.02 > GDJB3 UID THREAD references UTF-8 (SEEN) 02:23.02 < * THREAD (3)(2)(4)(1) 02:23.02 matched r'\* (?P[A-Z-]+)( (?P.*))?' => ('THREAD', ' (3)(2)

regex doubts

2008-07-19 Thread Mr SZ
Hi, I am taking a string as an input from the user and it should only contain the chars:L , M or R I tried the folllowing in kodos but they are still not perfect: [^A-K,^N-Q,^S-Z,^0-9] [L][M][R] [LRM]?L?[LRM]? etc but they do not exactly meet what I need. For eg: LRLRLRLRLM is ok but LRLRLRNL

Help with decorators

2008-07-18 Thread Mr SZ
Hi, I'm using decos for the first time.I want to check the input and then call a function in a class. I'm pasting the code:     def check_input_sanity(self,rover_input):         '''Check the input from client'''         def _check(fn):             def _inner(rover_input):                 if ro

Handling events using pycairo

2008-07-17 Thread Mr SZ
Hi, I'm trying to create a rectangle when the user presses or releases the mouse over a cairo object.I'm using the eventBox to capture the mouse events. Now the problem is the shapes is beng drawn when I call it from the expose_event event handler and nothing happens when I call the same from t

Simple Image Cropper

2008-07-14 Thread Mr SZ
Hi, I am designing a simple image cropper which simply takes an image and use PIL to do the cropping.Now in order to do the cropping I simply draw a rectangle on the image by dragging the mouse over the image.I then use button press and button release events to find the mouse postition and send

Adding a Cairo object into a vbox using pygtk

2008-07-11 Thread Mr SZ
Hi , I am trying to attach a cairo object into a vbox.I can pack a textbox with the following code:     entry = gtk.Entry()     entry.set_max_length(50)     entry.connect("activate", self.enter_callback, entry)     entry.set_text("hello")     entry.insert_text(" world", len(entry.get_text()))   

Filechooser issues

2008-07-11 Thread Mr SZ
Hi, I am using a gtk.filechooser dialog to open and save files.How do I add a filter so that only images are filtered ?I did something like this:     def get_save_filename(self):         filename = None     chooser = gtk.FileChooserDialog("Save File...", self.window,

UnboundLocalError problems

2008-06-29 Thread Mr SZ
Hi, I am writing a small script that changes my pidgin status to away when I lock my screen.I'm using the DBUS API for pidgin and gnome-screensaver.Here's the code: #!/usr/bin/env python import dbus, gobject from dbus.mainloop.glib import DBusGMainLoop dbus.mainloop.glib.DBusGMainLoop(set_as_

Working with dictionary like strings

2007-06-11 Thread Mr SZ
hello all, I'm using the urllib module to fetch pages from the web.The returned response is in the structure of a dictionary .For eg: {"":"","label": [ ] ,"torrents": [ ["F0666BDCCBFD01A52535759C044485E2E1CCE3C3",136,"AAA",1250164864,651,646185088,606208,0,0,0,-1,"",0,0,0,0,33564,7,342884352], [

running python scripts via crontab

2007-06-09 Thread Mr SZ
Hello all, I wrote a simple python script to send mail via smtp to my gmail acc.I can run it as python /home/phil/Desktop/smtp.py but when I add the same to my crontab as * * * * * /usr/bin/python2.5 /home/phil/Desktop/smtp.py ,it doesn't run.I checked the process by using top comman

Dealing with dictionary like strings

2007-06-08 Thread Mr SZ
Hello all, I'm using the urllib module to fetch pages from the web.The returned response is in the structure of a dictionary .For eg: {"":"","label": [ ] ,"torrents": [ ["F0666BDCCBFD01A52535759C044485E2E1CCE3C3",136,"AAA",1250164864,651,646185088,606208,0,0,0,-1,"",0,0,0,0,33564,7,342884352], [

How to use TLS lite

2007-06-08 Thread Mr SZ
I'm using tls lite to send mail using gmail's smtp.This is what I've done: from tlslite.api import * import tlslite.integration.SMTP_TLS connection= tlslite.integration.SMTP_TLS.SMTP_TLS('smtp.gmail.com',587) connection.set_debuglevel(1) msg = "Subject:Testing \n Hello" connection.starttls('[EMAIL