Re: [Twisted-Python] Installing twisted on Snow Leopard with custom 32-bit Python from python.org

2009-09-04 Thread Ronald Oussoren
 
On Friday, 04 September, 2009, at 08:22AM, "Nathan"  
wrote:
>I've installed the 32-bit Python on Snow Leopard (for various reasons
>unrelated to twisted) and would like to get twisted working with it.
>I've tried downloading twisted and running the standard "sudo python
>setup.py install" -- but that seems to simply install it in the system
>Python installation.  How can I get twisted installed where the Python
>installation that I got from python.org can use it?

Your probably using /usr/bin/python rather than the one you downloaded from 
Python.org. 

What's the output of 'which python'?  The python.org installer places binaries 
into /usr/local/bin, and also has a script in /Application/Python 2.6/ that 
will patch the startup profile of your shell to ensure that the python.org 
binaries are earlier on $PATH than the system install.

Ronald


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] FTPClient - aborting transfers

2009-09-04 Thread exarkun
On 1 Sep, 10:51 pm, m...@bennett.name wrote:
>Hello all,
>
>I've got an FTPClient implementation very similar to the one at [1],
>and I've added the ability to retrieve a file from the server with the
>following snippet:
>
>class FileReceiver(Protocol):
>"""
>Protocol subclass that writes received data to a local file.
>"""
>def __init__(self, filename):
>self.file = open(filename, 'wb')
>
>def dataReceived(self, data):
>self.file.write(data)
>
>receiver = FileReceiver(local_path)
>d = ftpClient.retrieveFile(remote_path,receiver)
>
>I want to be able to abort the transfers if they've not completed
>after a specific period of time. When the timeout is triggered, I call
>ftpClient.transport.loseConnection() which seems to stop the dL on
>line 109 of [1] from firing, but the data transfer continues until
>completion. This is true for both storing and retrieving files.
>
>In the storing case, I thought that
>twisted.protocols.basic.FileSender's stopProducing method might help,
>but all it seems to do is trigger the errback for anyone waiting for a
>response - the actual data transfer continues.
>
>How do I abort the transfer and clear the wire when the timeout fires?

The DTP connection is set as the (undocumented) dtpInstance attribute on 
the FTP instance it's associated with.  You can call loseConnection on 
that object's transport and the download should stop.  It might be 
worthwhile for someone to clean this up a bit.  Does it ever make sense 
for the transfer to continue when the control channel is gone?  Even if 
so, it'd be nice to have a supported (or at least documented) way to do 
this cleanup.

Jean-Paul

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Conch/SSH & Cisco IOS

2009-09-04 Thread Phil Mayers
James Y Knight wrote:
> On Sep 3, 2009, at 5:38 AM, Phil Mayers wrote:
> 
>> All,
>>
>> I've been having some problems using Conch/SSH to talk to the SSH  
>> server
>> on Cisco IOS (specifically the netconf subsystem)
>>
>> It seems that the IOS SSH server reacts badly to the following:
>>
>> c: syn
>> s: syn,ack
>> c: ack
>> c: PSH , 
>> s: PSH 
>> 
>>
>> i.e. IOS doesn't like being bombarded with either the version string  
>> or
>> KEX before it's sent its own banner.
> 
> I'm surprised to hear that, given that other users have posted  
> programs using conch that run commands against multiple Cisco routers  
> -- and apparently those programs worked. Do you have a particularly  
> old IOS? (Or maybe particularly new?)

As per my other email, it seems to be limited to the 12.2(33) train on 
the 6500 platform. Later and earlier trains on other platforms don't 
display the issue.

> 
> But if that's the case, it is clearly a bug in their ssh implementation.
> 
>  From http://www.ietf.org/rfc/rfc4253.txt:
>>Since the new client MAY immediately send additional data after its
>>identification string (before receiving the server's identification
>>string), the old protocol may already be corrupt when the client
>>learns that the server is old.  When this happens, the client  
>> SHOULD
>>close the connection to the server, and reconnect using the old
>>protocol.
> 
> 
> But anyhow, a patch to add a "broken-server-bug-workaround" option  
> seems reasonable. Once you've reported the bug to Cisco, so they'll  
> fix it at some point, that is.

FWIW I've opened a TAC case with Cisco; we'll see what they say.

I note that OpenSSH seems to wait for the server banner before sending 
the client banner & kex.

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] Is there an equivalent of tap2deb?

2009-09-04 Thread Peter Westlake
Now that .tap files are obsolete, is there a supported way of making
Debian packages like tap2dep?

Thanks,

Peter.

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Is there an equivalent of tap2deb?

2009-09-04 Thread Tim Allen
On Fri, Sep 04, 2009 at 02:53:37PM +0100, Peter Westlake wrote:
> Now that .tap files are obsolete, is there a supported way of making
> Debian packages like tap2dep?

.tap files (Pickle-based config files) may be obsolete, but I don't
believe the other variants (.tac for Python-based config files, and
I think there's an XML serialisation too) are obsolete.

I've never used tap2deb, but twistd and tap2rpm both seem to be quite
happy with .tac files in our production systems here.

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Installing twisted on Snow Leopard with custom 32-bit Python from python.org

2009-09-04 Thread Nathan
On Fri, Sep 4, 2009 at 4:21 AM, Ronald Oussoren wrote:
>
> On Friday, 04 September, 2009, at 08:22AM, "Nathan"  
> wrote:
>>I've installed the 32-bit Python on Snow Leopard (for various reasons
>>unrelated to twisted) and would like to get twisted working with it.
>>I've tried downloading twisted and running the standard "sudo python
>>setup.py install" -- but that seems to simply install it in the system
>>Python installation.  How can I get twisted installed where the Python
>>installation that I got from python.org can use it?
>
> Your probably using /usr/bin/python rather than the one you downloaded from 
> Python.org.
>
> What's the output of 'which python'?  The python.org installer places 
> binaries into /usr/local/bin, and also has a script in /Application/Python 
> 2.6/ that will patch the startup profile of your shell to ensure that the 
> python.org binaries are earlier on $PATH than the system install.

Nope, I was calling
"/Library/Frameworks/Python.framework/Versions/2.6/bin/python"
explicitly, which is the location that the binary 32-bit installer
indicated it was installing into.  I disabled most (maybe all) of the
"helpful" python.org installer features like altering my path for me,
installing into /usr/local/bin, and installing the GUI apps.

But since you are mentioning it, perhaps twisted will install into the
custom python if it is earlier in the path than the system python?
Tryingnope.  Well, something's different--perhaps there's more
paths I need to add?  Here's what I tried:

export PATH="/Library/Frameworks/Python.framework/Versions/2.6/bin/:$PATH"

$ sudo python setup.py install
running install
running build
running build_py
running build_ext
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3
-I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-c conftest.c -o conftest.o
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3
-I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-c conftest.c -o conftest.o
conftest.c:1:23: error: sys/epoll.h: No such file or directory
conftest.c:1:23: error: sys/epoll.h: No such file or directory
lipo: can't figure out the architecture type of: /var/tmp//ccIcwAI5.out
building 'twisted.runner.portmap' extension
creating build/temp.macosx-10.3-fat-2.6
creating build/temp.macosx-10.3-fat-2.6/twisted
creating build/temp.macosx-10.3-fat-2.6/twisted/runner
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3
-I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
-c twisted/runner/portmap.c -o
build/temp.macosx-10.3-fat-2.6/twisted/runner/portmap.o
In file included from
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
 from
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
 from twisted/runner/portmap.c:10:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error:
stdarg.h: No such file or directory
In file included from
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
 from
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
 from twisted/runner/portmap.c:10:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error:
stdarg.h: No such file or directory
lipo: can't figure out the architecture type of: /var/tmp//ccnV11Ya.out
error: command 'gcc' failed with exit status 1


~ Nathan

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Is there an equivalent of tap2deb?

2009-09-04 Thread Peter Westlake
On Sat, 05 Sep 2009 00:29 +1000, "Tim Allen" 
wrote:
> On Fri, Sep 04, 2009 at 02:53:37PM +0100, Peter Westlake wrote:
> > Now that .tap files are obsolete, is there a supported way of making
> > Debian packages like tap2dep?
> 
> .tap files (Pickle-based config files) may be obsolete, but I don't
> believe the other variants (.tac for Python-based config files, and
> I think there's an XML serialisation too) are obsolete.
> 
> I've never used tap2deb, but twistd and tap2rpm both seem to be quite
> happy with .tac files in our production systems here.

I'll try that, thanks!

Peter.

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] network server on multiprocessor hardware

2009-09-04 Thread Bokhan Artem
Hello.

Is there right (standard) way to write twisted network server
(tcp/web/mail/etc) which could use several cpu cores? For example,
master+workers model, where every worker doing the same job.
If so, may somebody help to wrap the sample code below?
May be some well-known twisted based software can do that?


from twisted.application import service,internet
from twisted.web import server,resource

class Simple(resource.Resource):
isLeaf = True
def render_GET(self, request):
return "Hello world."

application = service.Application("http")
ServerFactory = server.Site(Simple())
ServerService = internet.TCPServer(8081, ServerFactory)
ServerService.setServiceParent(application)



___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] network server on multiprocessor hardware

2009-09-04 Thread Glyph Lefkowitz
On Fri, Sep 4, 2009 at 4:59 PM, Bokhan Artem  wrote:

> Hello.
>
> Is there right (standard) way to write twisted network server
> (tcp/web/mail/etc) which could use several cpu cores? For example,
> master+workers model, where every worker doing the same job.
> If so, may somebody help to wrap the sample code below?
> May be some well-known twisted based software can do that?
>

The sample code you've provided doesn't do anything; no CPU consumption of
its own (it's all in the framework) and no network I/O of its own.  So it's
hard to come up with a realistic example.  There's no way to tell Twisted
itself to spread itself out over multiple CPU cores, but then, Twisted
itself is rarely the chief CPU consumer in an application.

If you want to take advantage of multiple CPU cures though, have a look at
Ampoule: .
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] os x installer, multiple source locations

2009-09-04 Thread Matt Bennett
Hello all,

I used the Twisted 8.2.0 for OS X 10.5 installer from [1] to install
twisted on my mac. I don't understand why, but I seem to have two
copies of the source on the disk, one at
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted
and another at /Library/Python/2.5/site-packages/twisted. Both
locations are on sys.path, the former taking precedence.

More curiously, the two versions appear to be different. The following
snippet fails with the version that python finds by default:

from twisted.python import usage

class Options(usage.Options):
optParameters = [["shiny_integer", "s", 1, None, int]]
optParameters = [["dummy_float", "d", 3.14159, None, float]]

o = Options()

Resulting in:

Traceback (most recent call last):
  File "options.py", line 7, in 
o = Options()
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted/python/usage.py",
line 120, in __init__
(longOpt, shortOpt, docs, settings, synonyms, dispatch) = c()
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted/python/usage.py",
line 287, in _gather_parameters
long, short, default, doc = util.padTo(4, parameter)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted/python/util.py",
line 227, in padTo
raise ValueError, "%d elements is more than %d." % (len(seq), n)
ValueError: 5 elements is more than 4.

The same snippet works with the version in the other location. Is this a bug?

Thanks,
Matt.

[1] 
http://tmrc.mit.edu/mirror/twisted/Twisted/8.2/Twisted-8.2.0_py2.5_osx10.5.dmg

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] Looping in a deffered

2009-09-04 Thread John Joske
I'm trying to make a simple deferred that will continue get a message of
a message queue, process it and then wait for another message.

 

While I can get the first message easily I am unable to work out how I
can get a second message without creating a new deferred in the printMsg
function, which eventually gives me a maximum recursion depth exceeded.

 

Basic code is a follows: 

 

from twisted.internet import reactor,defer

 

def printMsg(msg):

print "Message is:"

print msg



deferred=getMsg()

deferred.addCallback(printMsg)

 

 

def getMsg() :

d=defer.Deferred()

#replaced with code that actually goes to a queue to get the message

msg="This is a message"

d.callback(msg)

return d

 

deferred=getMsg()

deferred.addCallback(printMsg)

reactor.run()



Can any one point me on the right path to solve this?

 

Thanks

 

John

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python