Re: IOError: [Errno 4] Interrupted system call

2007-02-15 Thread chadrik
i'm getting the same error when trying to read results from popen2
within a pyQt window.  is this a threading issue? is my pyQt window
responsible for interrupting the read?  i'm fairly new to python so
i'm struggling to figure this out. can you recommend any possible
methods of preventing this? for instance, could acquiring a thread
lock before calling popen solve the problem?

thanks,
chad

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


Re: IOError: [Errno 4] Interrupted system call

2007-02-16 Thread chadrik
i don't have any signal handlers in my code, but i have no idea what
is going on in the internals of the pyQt framework that i'm using for
the GUI.

as far as simply ignoring the exception, that does not seem to work.
for instance, here's some code i've tried:


p = subprocess.Popen('mycommand', shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, close_fds=True)
output = ''
tries = 0
while tries < 12:
try:
tries = tries+1
print "retrieving results"
output = p.stdout.readlines()

except IOError:
print "IOError! try %s" % tries
print "output:", output
#time.sleep(1)
else:
print "Great Success"
print "output:", output
break


--printout: successful run--
retrieving results
Great Success
output: []

--printout: IOError run--
retrieving results
IOError! try 1
output:
retrieving results
Great Success
output: []

if the first try raises an error output does not get set and then the
second try succeeds but returns an empty list when it should return
results. moving the Popen inside the loop isn't an option either,
because, in addition to returning results, the command performs an
action which should only run once.

sorry if i'm missing something obvious here, i'm a python newb.

-chad




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


setuptools setup.py and "extras"

2009-04-22 Thread Chadrik

in addition to resolving install dependencies, setuptools supports
"extras" with their own dependencies.   these can be installed using
easy_install, like so:

$ easy_install mypackage[extraFeature]

what is the best way to cause an extra's dependencies to be installed
when using the `python setup.py` form?


i discovered that you can use easy_install via setup.py and point it
at the current directory:

$ python setup.py easy_install .  #<--- the period points easy_install
at our current dir


however, this does not install the extra features.  trying the next
logical step doesn't work:

$ python setup.py easy_install .[extraFeature]


so far the best that i've found is :

$ cd /path/to/mypackage
$ cd ..
$ python mypackage/setup.py easy_install mypackage[extraFeature]

is there a simpler way?

-chad


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


function factories and argument names

2008-06-20 Thread Chadrik

i know how to programmatically create python functions:


module = __import__( '__main__')
def factory( val ):
def f( arg=val ): print arg, val
f.__name__ = 'function%s' % x
return f

for x in [1,2,3,4]:
func = factory( x )
setattr( module, func.__name__, func)


but i'd like to add a little more customization: i'd like to vary the
name of the argument to the function, which is now fixed as 'arg':

help( function2 )

# Help on function function2 in module __main__:
#
# function2(arg=2)

ideally i'd like to create each function in the example with the given
format:

function1(arg1=1)
function2(arg2=2)
function3(arg3=3)
function4(arg4=4)

i know that the function will behave the same regardless of the arg
name, but i would like to help convey to the user what the meaning of
the argumetns are.  plus, i would also like to vary the number are
keyword args.

thanks in advance,
chad





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