Re: unit testing class hierarchies

2012-10-02 Thread Fayaz Yusuf Khan
Peter Otten wrote:

> Ulrich Eckhardt wrote:
>> The problem here is that TestBase is not a complete test case (just 
as
>> class Base is not complete), but the unittest framework will still 
try
>> to run it on its own.
How exactly are you invoking the test runner? unittest? nose? You can 
tell the test discoverer which classes you want it to run and which 
ones you don't. For the unittest library, I use my own custom 
load_tests methods:
def load_tests(loader, tests, pattern):
testcases = [TestD1, TestD2]
return TestSuite([loader.loadTestsFromTestCase(testcase)
  for testcase in testcases])
http://docs.python.org/library/unittest.html#load-tests-protocol

>> One way around this is to not derive class
>> TestBase from unittest.
> 
> Another is to remove it from the global namespace with
> 
> del TestBase
Removing the class from namespace may or may not help. Consider a 
scenario where someone decided to be creative with the cls.__bases__ 
attribute.

-- 
Fayaz Yusuf Khan
Cloud architect, Dexetra SS, India
fayaz.yusuf.khan_AT_gmail_DOT_com, fayaz_AT_dexetra_DOT_com
+91-9746-830-823

-- 
http://mail.python.org/mailman/listinfo/python-list


Should I acquire lock for logging.Handler.flush()?

2012-02-20 Thread Fayaz Yusuf Khan
I'm writing a custom logging Handler that sends emails through AWS Simple 
Email Service using the boto library.
As there's a quota cap on how many (200) emails I can send within 24hrs, I 
think I need to buffer my log messages from the emit() calls (Or is that a bad 
idea?).
And I was reading the Handler documentation and was confused if I should call 
the acquire() and release() methods from within a flush() call.
-- 
Fayaz Yusuf Khan
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I acquire lock for logging.Handler.flush()?

2012-02-21 Thread Fayaz Yusuf Khan
On Tuesday 21 Feb 2012 12:52:14 PM Vinay Sajip wrote:
> If you are using SMTPHandler, calling flush() won't do anything.
> You'll probably need to subclass the handler to implement rate
> limiting.
Oh, no! I'm writing my own handler.
https://github.com/fayazkhan/ses_handler/blob/master/ses_handler.py
Now I understand from here 
http://docs.python.org/library/logging.html#handler-objects
that emit() calls are wrapped acquire() and release() in the handle() method.

Anyway, I read the source and found many interesting things that ought to be 
mentioned in the docs.
Such as flush() should be called from close() whenever it's implemented. 
(FileHandler.close() is doing it)
And how come close()/flush() isn't being called from inside a lock?
(Handler.close() calls the module level _acquireLock() and _releaseLock()s but 
nothing about the instance level acquire() or release())
Or is it being locked from somewhere else?
-- 
Fayaz Yusuf Khan
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I acquire lock for logging.Handler.flush()?

2012-02-23 Thread Fayaz Yusuf Khan
On Thursday 23 Feb 2012 8:23:42 AM Vinay Sajip wrote:
> If locking is required in a particular handler class for close or
> flush, that can be implemented by the developer of that handler class.
> AFAIK there is no such need for the handler classes in the stdlib - if
> you have reason to believe otherwise, please give some examples of
> potential problems and with example code if possible.
Well, I'm not currently facing any race-around conditions. As I said, I was 
mostly familiarizing myself with the API.
Well, as emit() is always being called from within a lock, I assumed that 
flush() should/would also be handled similarly. Afterall, they are handling the 
same underlying output stream or in case of the BufferingHandler share the same 
buffer. Shouldn't the access be synchronized?
-- 
Fayaz Yusuf Khan
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: asynchronous downloading

2012-02-23 Thread Fayaz Yusuf Khan
On Thursday 23 Feb 2012 5:10:25 PM Plumo wrote:
> I read through the python-dev archives and found the fundamental problem is
> no one maintains asnycore / asynchat. 
By all means, scratch your own itch. :)
-- 
Fayaz Yusuf Khan
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWart: Language missing maximum constant of numeric types!

2012-02-24 Thread Fayaz Yusuf Khan
On Saturday 25 Feb 2012 12:37:58 AM MRAB wrote:
> We already have arbitrarily long ints, so there could be a special
> infinite int singleton (actually, 2 of them, one positive, the other
> negative).
Seconded. Although would a wish request to bugs.python.org saying "Allow 
storage of the integer infinity" make any sense to the developers? :P
-- 
Fayaz Yusuf Khan
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get a package pip installable?

2012-04-15 Thread Fayaz Yusuf Khan
nbvf...@gmail.com wrote:

> (test)chris@amnesia:~$ pip install django-easydump
> Downloading/unpacking django-easydump
> Could not find any downloads that satisfy the requirement django-easydump
> No distributions at all found for django-easydump
> Storing complete log in /Users/chris/.pip/pip.log
Works fine here. Although fails with other build errors.
Downloading/unpacking django-easydump
  Downloading django-easydump-0.2.3.tar.gz
  Running setup.py egg_info for package django-easydump
Traceback (most recent call last):
  File "", line 14, in 
  File "/home/fayaz/Programming/build/django-easydump/setup.py", line 6, 
in 
version=open('VERSION').read(),
IOError: [Errno 2] No such file or directory: 'VERSION'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

  File "", line 14, in 

  File "/home/fayaz/Programming/build/django-easydump/setup.py", line 6, in 


version=open('VERSION').read(),

IOError: [Errno 2] No such file or directory: 'VERSION'


Command python setup.py egg_info failed with error code 1
Storing complete log in /home/fayaz/.pip/pip.log
 
-- 
Cloud developer and architect
Dexetra SS, Bangalore, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823


-- 
http://mail.python.org/mailman/listinfo/python-list


What is the use of python.cache_ubuntu?

2012-05-03 Thread Fayaz Yusuf Khan
My Ubuntu 11.04 server ran out of inodes due to too many files in 
'/tmp/python.cache_ubuntu'. Does anyone know what it does?
--
Cloud architect and hacker, Dexetra, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823

-- 
http://mail.python.org/mailman/listinfo/python-list


Wish: Allow all log Handlers to accept the level argument

2012-05-18 Thread Fayaz Yusuf Khan
***TRIVIAL ISSUE***, but this has been irking me for a while now.
The main logging.Handler class' __init__ accepts a level argument while none 
of its children do. The poor minions seem to be stuck with the setLevel 
method which considerably lengthens the code.

In short:
Let's do this:
root.addHandler(FileHandler('debug.log', level=DEBUG)
Instead of this:
debug_file_handler = FileHandler('debug.log')
debug_file_handler.setLevel(DEBUG)
root.addHandler(debug_file_handler)

Python 2.7
--
Cloud architect, Dexetra SS, Kochi, India
fayaz.yusuf.khan_AT_gmail_DOT_com, fayaz_AT_dexetra_DOT_com
+91-9746-830-823


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wish: Allow all log Handlers to accept the level argument

2012-05-23 Thread Fayaz Yusuf Khan
Jean-Michel Pichavant wrote:
> Meanwhile you can shorten the code this way:
> 
> root.addHandler(FileHandler('debug.log'))
> root.handlers[-1].setLevel(DEBUG)
> 
Eh? Readability was the aim.
-- 
Fayaz Yusuf Khan
Cloud architect, Dexetra SS, India
fayaz.yusuf.khan_AT_gmail_DOT_com, fayaz_AT_dexetra_DOT_com
+91-9746-830-823


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for open-source Python projects to help out with

2011-09-07 Thread Fayaz Yusuf Khan
On Wednesday, September 07, 2011 01:09:51 PM Alec Taylor wrote:
> Hi Tyler,
> 
> I'm currently working on building a new kind of social-network for
> Users-Groups, Game-Clans & Student-Groups.
> 
> Building it using DJango with Pinax.
> 
> Detailed Feature-Set (planned):
> • Event management
> • Conference management (including ticketing with payment-gateway
> integration) • Video+Audio Conferencing of event, with online interaction
> possibilitiy (great for webinars)
> • Join/create/delete/list groups
> • Sitewide calendar
> • Sitewide feed from non-private groups
> • SSO integration (facebook, twitter & linkedin)
> • Wall (+feed) for each group
> • Listing of who's in which group
> • PM group members
> 
> I will probably be releasing it under the New BSD license, although
> I'm happy to consider others given a good argument.
> 
> Interested?
The project page and mailing list?

-- 
Fayaz Yusuf Khan
Cloud developer and designer
Dexetra SS, Kochi, India
fayaz.yusuf.khan_AT_gmail_DOT_com
fayaz_AT_dexetra_DOT_com
+91-9746-830-823


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Generate 16+MAX_WBITS decompressable data

2013-02-12 Thread Fayaz Yusuf Khan
I'm trying write unit-tests for some of my old code and have run into this 
piece of code.

dcomp = zlib.decompressobj(16+zlib.MAX_WBITS)
chunk = ''.join(f.chunks())
received_data =  dcomp.decompress(chunk)

How do I generate the chunk here? From what I've been trying I'm getting 
this exception:
>>> import zlib
>>> zlib.compress('hello')
'x\x9c\xcbH\xcd\xc9\xc9\x07\x00\x06,\x02\x15'
>>> zlib.decompress(_, 16+zlib.MAX_WBITS)
Traceback (most recent call last):
  File "", line 1, in 
zlib.error: Error -3 while decompressing data: incorrect header check

zlib.decompress without the second argument works, but I can't really go 
ahead into my project file and remove it.
-- 
Fayaz Yusuf Khan
Cloud architect, Dexetra SS, India
fayaz.yusuf.khan_AT_gmail_DOT_com, fayaz_AT_dexetra_DOT_com
+91-9746-830-823

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generate 16+MAX_WBITS decompressable data

2013-02-12 Thread Fayaz Yusuf Khan
Marc Christiansen wrote:

> Try using a compressobj with 24 <= wbits < 32. It should work, but I
> didn't try.
> 
Er, the problem is that compressobj doesn't accept a WBIT argument.
-- 
Fayaz Yusuf Khan
Cloud architect, Dexetra SS, India
fayaz.yusuf.khan_AT_gmail_DOT_com, fayaz_AT_dexetra_DOT_com
+91-9746-830-823

-- 
http://mail.python.org/mailman/listinfo/python-list