[Twisted-Python] Reply:Re: run python application with twistd -y ifinger.tac, error occurs. please help to check

2013-09-17 Thread 吴志高






Jean-Paul
您好!

Thanks for your help. 
Because i am a fresh man to twisted. 
I will roll back to version 2.x and try the application again.

谢谢!!

姓名 : 吴志高/Charles
电话 : (+086)13410859946

邮箱 : wuzhiga...@163.com





At 2013-09-17 20:14:08,exar...@twistedmatrix.com wrote:
>On 09:06 am, _...@lvh.io wrote:
>>Hi Charles,
>>
>>
>>Yes, twistd doesn't appear to work on py3k. Not being able to import
>>_preamble is normal (once Twisted has been installed), but _preamble 
>>does
>>assume sys.exc_clear exists, which isn't true on 3.x.
>>
>>I couldn't find any ticket on this. Perhaps you should file it (and 
>>maybe
>>fix it!) :)
>
>I think there are still many unported dependencies of `twistd` to port 
>first.
>>It's my understanding that the new except clause semantics are expected 
>>to
>>take care of this problem.
>>
>>Can someone comment as to why this was put there in the first place, 
>>and,
>>specifically, why it can't just be "pass"? Is there some logging system
>>that looks at the current exception or something when twistd (or some 
>>other
>>script) starts?
>
>Both `log.err()´ and `Failure()´ look at the current exception.  If we 
>don't `sys.clear_exc()´ here then the first piece of code that tries to 
>use either of those may get a surprising result.  The current exception 
>state can last a long time so this surprise can hide for a remarkably 
>long time before showing up.
>
>The exception state also holds references to lots of extra things on the 
>stack which is undesirable even if there are no other side-effects.
>
>Jean-Paul
>
>___
>Twisted-Python mailing list
>Twisted-Python@twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] infrastructure hosting confusion / cleanup

2013-09-17 Thread Glyph
Pages like this one:



information about the source code being built in the form of a git revision.

As long as we're still using Subversion for our upstream VCS, it would be 
desirable to also have a Subversion revision number.

I wanted to request this, but even I have lost track, at this point, of where 
to file bugs for things like this.

It looks like we're hosting our infrastructure projects on Github right now, 
which means  
would be the place to go.  But there is no 'issues' link there.  Nor any link 
to any place where bugs might be filed.

I guess  is still 
what is being used for that thing? But then that project provides a 
non-up-to-date view of the source code.

Richard Wall's draft for a new "new ticket" page directs people to file issues 
against twisted-infra but that appears to be wrong in this particular case, 
since the buildbot configuration doesn't have a bugtracker there.  
  Plus, 
that suggestion links to a list of like a zillion infrastructure projects, half 
of which don't even have a description that explains what they are, let alone 
where to file bugs.

Can someone please volunteer to update all of the READMEs on all of these 
projects, and all of the various locations where they've ever lived, to point 
at the actual, canonical place where infrastructure is developed?  It would be 
good if users who want to report that the website is down or ask for an 
enhancement to the website, or Trac or Buildbot instances did not have to 
select between a dozen different projects that they might file an issue against.

(Perhaps they should all link to 
 or some page beneath it, 
which can _remain_ the canonical location for everything and be updated once, 
since based on our history it seems likely that half of our infrastructure will 
randomly move to Bitbucket, or perhaps to Sourceforge, at some point in the 
future...)

If someone who has not previously participated in infrastructure development 
would like to take point on creating such a resource, I will be happy to get 
you the appropriate access to any systems you need to.

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


Re: [Twisted-Python] logging

2013-09-17 Thread Wilfredo Sánchez Vega

  For your Trac'ing pleasure:

  https://twistedmatrix.com/trac/ticket/6750

-wsv


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


Re: [Twisted-Python] Twisted at PyConUK 2013

2013-09-17 Thread Glyph
On Sep 17, 2013, at 10:43 AM, Phil Mayers  wrote:

> On 17/09/13 17:05, exar...@twistedmatrix.com wrote:
> 
>>> p.s. the "How to review" docs on Trac are AWFUL if you've never done
>>> one before. It assumes a *hell* of a lot of prior knowledge. There
>>> needs to be a single page checklist for first-time reviewers.
>> 
>> This is in progress.
> 
> Awesome; would it be useful for me to write up what I did, or do you have 
> enough source material?

Let's have a discussion here on the list first :-).  So... yes, write it up in 
a reply.

The review docs are always in progress.  Feedback like "this is bad" is 
basically useless; we know it's bad, but everyone has its own idea of what 
"bad" means.  What would be really useful in such a write-up was specific 
feedback about what you needed to know, what resources you discovered, and what 
they were missing.  Like:

"I didn't know if I should _ or _ because I was looking at this url _ and it 
didn't say and didn't link to anything that told me what to do.  So, based on 
this previous review _ I decided to _ and that worked out okay, that should be 
documented on the first URL I found".

So please feel free to offer more feedback but let's please keep it as specific 
as possible.

> FWIW I found virtualenv & the github mirror to be incredibly useful for the 
> task; in particular it meant getting latest & greatest 
> pyflakes/twistedchecker and dependencies, and being able to install the 
> branch.

Separately, "how to get set up to review" would be a useful document too.

-glyph

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


Re: [Twisted-Python] Twisted Names EDNS(0) support [Was Twisted at PyConUK 2013]

2013-09-17 Thread exarkun

On 04:18 pm, m-li...@the-moon.net wrote:

[snip]

Meanwhile, I'll see if I can help exarkun with the code review 
checklist.


No, not me. :)  Ashwini is working on this.  Please give her a hand. :)

Jean-Paul

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


Re: [Twisted-Python] Twisted Names EDNS(0) support [Was Twisted at PyConUK 2013]

2013-09-17 Thread Phil Mayers

On 17/09/13 17:18, Richard Wall wrote:

On 17 September 2013 16:34, Phil Mayers  wrote:

On 17/09/13 15:29, Richard Wall wrote:


PS. I'd love to merge https://tm.tl/5675 before the conference, so if
you're familiar with the DNS RFCs, I'd really appreciate a code
review. I'm rwall on #twisted-dev and #twisted if you want to discuss
it



Deep breath... I'll give this a go.


Thanks Phil,

I'd seen your previous work in this area and was hoping you'd reply. :)

You might be interested to read the reviews of
https://twistedmatrix.com/trac/ticket/5675 where we introduced support
for parsing of  OPT pseudo records.


Good idea, that was helpful.

I've given it a go; if anyone has a review of my review... ;o)



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


Re: [Twisted-Python] Twisted at PyConUK 2013

2013-09-17 Thread Phil Mayers

On 17/09/13 17:05, exar...@twistedmatrix.com wrote:


p.s. the "How to review" docs on Trac are AWFUL if you've never done
one before. It assumes a *hell* of a lot of prior knowledge. There
needs to be a single page checklist for first-time reviewers.


This is in progress.


Awesome; would it be useful for me to write up what I did, or do you 
have enough source material?


FWIW I found virtualenv & the github mirror to be incredibly useful for 
the task; in particular it meant getting latest & greatest 
pyflakes/twistedchecker and dependencies, and being able to install the 
branch.


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


Re: [Twisted-Python] run python application with twistd -y ifinger.tac, error occurs. please help to check

2013-09-17 Thread exarkun

On 04:10 pm, _...@lvh.io wrote:

On Tue, Sep 17, 2013 at 2:14 PM,  wrote:

I think there are still many unported dependencies of `twistd` to port
first.


Sure, but every little bit helps, right? :)


It doesn't make a lot of sense to me to port things that depend on 
unported things.  The little bit that would help would be porting one of 
the unported dependencies.


 Can someone comment as to why this was put there in the first place, 
and,
specifically, why it can't just be "pass"? Is there some logging 
system

that looks at the current exception or something when twistd (or some
other
script) starts?


Both `log.err()´ and `Failure()´ look at the current exception.  If we
don't `sys.clear_exc()´ here then the first piece of code that tries 
to use
either of those may get a surprising result.  The current exception 
state
can last a long time so this surprise can hide for a remarkably long 
time

before showing up.


Okay, cool. From what I understand:

1. _preamble is just a hack to get bin/whatever to work right without
installing (i.e. from a checkout)
2. (not too sure about this) in py3k, except statements do the clearing 
bit

already: www.python.org/dev/peps/pep-3110/#semantic-changes

So, does that mean we can do a try: ... ; except AttributeError and be 
done

with it?


Sounds like probably yea.  The way to know would be to make the change 
and run the test suite (perhaps first double checking to get an idea of 
how well covered this is).  Revision history suggests the change was 
made to get a test to pass but it doesn't mention which one.


This is why porting the dependencies first makes sense though - you 
won't be able to run the tests as long as the dependencies are unported.


Jean-Paul

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


Re: [Twisted-Python] Twisted at PyConUK 2013

2013-09-17 Thread Phil Mayers

On 17/09/13 15:29, Richard Wall wrote:


PS. I'd love to merge https://tm.tl/5675 before the conference, so if
you're familiar with the DNS RFCs, I'd really appreciate a code
review. I'm rwall on #twisted-dev and #twisted if you want to discuss
it


Deep breath... I'll give this a go.

p.s. the "How to review" docs on Trac are AWFUL if you've never done one 
before. It assumes a *hell* of a lot of prior knowledge. There needs to 
be a single page checklist for first-time reviewers.


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


[Twisted-Python] Twisted Names EDNS(0) support [Was Twisted at PyConUK 2013]

2013-09-17 Thread Richard Wall
On 17 September 2013 16:34, Phil Mayers  wrote:
> On 17/09/13 15:29, Richard Wall wrote:
>
>> PS. I'd love to merge https://tm.tl/5675 before the conference, so if
>> you're familiar with the DNS RFCs, I'd really appreciate a code
>> review. I'm rwall on #twisted-dev and #twisted if you want to discuss
>> it
>
>
> Deep breath... I'll give this a go.

Thanks Phil,

I'd seen your previous work in this area and was hoping you'd reply. :)

You might be interested to read the reviews of
https://twistedmatrix.com/trac/ticket/5675 where we introduced support
for parsing of  OPT pseudo records.

Meanwhile, I'll see if I can help exarkun with the code review checklist.

Thanks again and I look forward to your feedback.

-RichardW.

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


Re: [Twisted-Python] Twisted Names EDNS(0) support [Was Twisted at PyConUK 2013]

2013-09-17 Thread Richard Wall
On 17 September 2013 17:18, Richard Wall  wrote:
> You might be interested to read the reviews of
> https://twistedmatrix.com/trac/ticket/5675 where we introduced support
> for parsing of  OPT pseudo records.

Sorry, wrong link.

This is the OPT record ticket - https://twistedmatrix.com/trac/ticket/5668

And this is the EDNS plan:
 * https://twistedmatrix.com/trac/wiki/EDNS0

-RichardW.

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


Re: [Twisted-Python] Twisted at PyConUK 2013

2013-09-17 Thread exarkun

On 03:34 pm, p.may...@imperial.ac.uk wrote:

On 17/09/13 15:29, Richard Wall wrote:

PS. I'd love to merge https://tm.tl/5675 before the conference, so if
you're familiar with the DNS RFCs, I'd really appreciate a code
review. I'm rwall on #twisted-dev and #twisted if you want to discuss
it


Deep breath... I'll give this a go.

p.s. the "How to review" docs on Trac are AWFUL if you've never done 
one before. It assumes a *hell* of a lot of prior knowledge. There 
needs to be a single page checklist for first-time reviewers.


This is in progress.

Jean-Paul

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


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


Re: [Twisted-Python] run python application with twistd -y ifinger.tac, error occurs. please help to check

2013-09-17 Thread Laurens Van Houtven
On Tue, Sep 17, 2013 at 2:14 PM,  wrote:

> I think there are still many unported dependencies of `twistd` to port
> first.
>

Sure, but every little bit helps, right? :)


>  Can someone comment as to why this was put there in the first place, and,
>> specifically, why it can't just be "pass"? Is there some logging system
>> that looks at the current exception or something when twistd (or some
>> other
>> script) starts?
>>
>
> Both `log.err()´ and `Failure()´ look at the current exception.  If we
> don't `sys.clear_exc()´ here then the first piece of code that tries to use
> either of those may get a surprising result.  The current exception state
> can last a long time so this surprise can hide for a remarkably long time
> before showing up.
>

Okay, cool. From what I understand:

1. _preamble is just a hack to get bin/whatever to work right without
installing (i.e. from a checkout)
2. (not too sure about this) in py3k, except statements do the clearing bit
already: www.python.org/dev/peps/pep-3110/#semantic-changes

So, does that mean we can do a try: ... ; except AttributeError and be done
with it?

The exception state also holds references to lots of extra things on the
> stack which is undesirable even if there are no other side-effects.
>
> Jean-Paul
>

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


[Twisted-Python] [ANN] structlog – bring context & structure to your logs without boilerplate

2013-09-17 Thread Hynek Schlawack
Hi folks,

today, I’ve release the 0.2.0 of my structlog project whose ambition is no less 
than changing the way we log in Python. :)

And since it sports dedicated support for Twisted 
 (but is not limited to it, it 
wraps *any* logger), I’d like to introduce you to it.

Basically, its premise is that events happen in a context and you want to log 
out both effortlessly.  Nowadays logs are usually consumed by parsers anyway, 
so regular, easily parsable logs are a good thing™.

This is a nice example of a Twisted application showing off a bit what 
structlog is capable of:

import sys
import uuid

import structlog
import twisted

from twisted.internet import protocol, reactor

logger = structlog.getLogger()


class Counter(object):
i = 0

def inc(self):
self.i += 1

def __repr__(self):
return str(self.i)


class Echo(protocol.Protocol):
def connectionMade(self):
self._counter = Counter()
self._log = logger.new(
connection_id=str(uuid.uuid4()),
peer=self.transport.getPeer().host,
count=self._counter,
)

def dataReceived(self, data):
self._counter.inc()
log = self._log.bind(data=data)
self.transport.write(data)
log.msg('echoed data!')


if __name__ == "__main__":
structlog.configure(
processors=[structlog.twisted.EventAdapter()],
logger_factory=structlog.twisted.LoggerFactory(),
)
twisted.python.log.startLogging(sys.stderr)
reactor.listenTCP(1234, protocol.Factory.forProtocol(Echo))
reactor.run()


It will give you an output like:

2013-09-17 17:40:23+0200 [-] Log opened.
2013-09-17 17:40:23+0200 [-] Factory starting on 1234
2013-09-17 17:40:23+0200 [-] Starting factory 

2013-09-17 17:40:28+0200 [Echo,0,127.0.0.1] peer='127.0.0.1' count=1 
connection_id='4e2ee31c-b3ff-478e-ae06-7b1a492fce45' data='foo\n' event='echoed 
data!'
2013-09-17 17:40:33+0200 [Echo,0,127.0.0.1] peer='127.0.0.1' count=2 
connection_id='4e2ee31c-b3ff-478e-ae06-7b1a492fce45' data='bar\n' event='echoed 
data!'
2013-09-17 17:40:44+0200 [Echo,1,127.0.0.1] peer='127.0.0.1' count=1 
connection_id='3118f673-482b-471f-a206-e8f97f9a9c2c' data='qux\n' event='echoed 
data!'
2013-09-17 17:40:53+0200 [Echo,0,127.0.0.1] peer='127.0.0.1' count=3 
connection_id='4e2ee31c-b3ff-478e-ae06-7b1a492fce45' data='twisted prevails\n' 
event='echoed data!'

(you can find this and more examples at 
)

In short:

- It allows you to build context by binding values to loggers. This context is 
just a dictionary. Once you log an event out (again, arbitrary number of 
key/value pairs), it gets merged with the context, processed by configurable 
processor chain and passed to your original logger.
- Your loggers are immutable (by default infidels can use thread local storage) 
and you’ll get a new one on each binding. Immutable local data is awesome.
- You can define processors that can mangle, filter, and format your log 
entries.
- Configure once, then just call getLogger (which is a Twisted-friendly alias 
for get_logger) in regular code.
- Of course there is a JSON renderer built right in – just tell log stash about 
it and be merry.

*Please* have a look at 
, I don’t want to 
reproduce it here. :)

Credit where credit is due: I picked up the idea of bound loggers from David 
Reid’s work on otter 
 which in turn was 
based on ideas by JP (I’ve been told).

You can find everything you need to know at http://www.structlog.org/ – I’d be 
happy about any constructive feedback and even more so about contributions!

Cheers,
Hynek


signature.asc
Description: Message signed with OpenPGP using GPGMail
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] Twisted at PyConUK 2013

2013-09-17 Thread Richard Wall
Hello everyone,

I'm giving a talk about Twisted and Twisted Names at PyConUK this
year. The schedule hasn't been fixed yet, but it looks like it'll be
this Friday 20 September at 1530.
If you're going to PyConUK I'd welcome your support, especially with
fielding any tricky audience questions. ;-)
 * http://pyconuk.net/Schedule

I'm also hoping to organise a Twisted Sprint, so if you're still
around on Monday come and find me.
 * http://pyconuk.net/Sprints

-RichardW.

PS. I'd love to merge https://tm.tl/5675 before the conference, so if
you're familiar with the DNS RFCs, I'd really appreciate a code
review. I'm rwall on #twisted-dev and #twisted if you want to discuss
it

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


Re: [Twisted-Python] run python application with twistd -y ifinger.tac, error occurs. please help to check

2013-09-17 Thread exarkun

On 09:06 am, _...@lvh.io wrote:

Hi Charles,


Yes, twistd doesn't appear to work on py3k. Not being able to import
_preamble is normal (once Twisted has been installed), but _preamble 
does

assume sys.exc_clear exists, which isn't true on 3.x.

I couldn't find any ticket on this. Perhaps you should file it (and 
maybe

fix it!) :)


I think there are still many unported dependencies of `twistd` to port 
first.
It's my understanding that the new except clause semantics are expected 
to

take care of this problem.

Can someone comment as to why this was put there in the first place, 
and,

specifically, why it can't just be "pass"? Is there some logging system
that looks at the current exception or something when twistd (or some 
other

script) starts?


Both `log.err()´ and `Failure()´ look at the current exception.  If we 
don't `sys.clear_exc()´ here then the first piece of code that tries to 
use either of those may get a surprising result.  The current exception 
state can last a long time so this surprise can hide for a remarkably 
long time before showing up.


The exception state also holds references to lots of extra things on the 
stack which is undesirable even if there are no other side-effects.


Jean-Paul

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


Re: [Twisted-Python] run python application with twistd -y ifinger.tac, error occurs. please help to check

2013-09-17 Thread Laurens Van Houtven
Hi Charles,


Yes, twistd doesn't appear to work on py3k. Not being able to import
_preamble is normal (once Twisted has been installed), but _preamble does
assume sys.exc_clear exists, which isn't true on 3.x.

I couldn't find any ticket on this. Perhaps you should file it (and maybe
fix it!) :)

It's my understanding that the new except clause semantics are expected to
take care of this problem.

Can someone comment as to why this was put there in the first place, and,
specifically, why it can't just be "pass"? Is there some logging system
that looks at the current exception or something when twistd (or some other
script) starts?

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


[Twisted-Python] run python application with twistd -y ifinger.tac, error occurs. please help to check

2013-09-17 Thread 吴志高






Experts:
您好!

my ifinger.tac file content like following:
fromtwisted.applicationimportinternet, 
servicefromtwisted.internetimportprotocol, reactor, 
deferfromtwisted.protocolsimportbasicclassFingerProtocol(basic.LineReceiver):
deflineReceived(self, user):
d = self.factory.getUser(user)

defonError(err):
return'Internal error in server'd.addErrback(onError)

defwriteResponse(message):
self.transport.write(message + '\r\n')
self.transport.loseConnection()
d.addCallback(writeResponse)

classFingerFactory(protocol.ServerFactory):
protocol = FingerProtocoldef__init__(self, **kwargs):
self.users = kwargsdefgetUser(self, user):
returndefer.succeed(self.users.get(user, "No such user"))

application = service.Application('finger', uid=1, gid=1)
factory = FingerFactory(moshez='Happy and well')
internet.TCPServer(79, 
factory).setServiceParent(service.IServiceCollection(application))  
 


when running this script with command-line : twistd -y ifinger.tac, error 
occurs like :


Traceback (most recent call last):
File "/usr/local/bin/twistd", line 7, in 
import _preamble
ImportError: No module named '_preamble'


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
File "/usr/local/bin/twistd", line 9, in 
sys.exc_clear()
AttributeError: 'module' object has no attribute 'exc_clear'


And i run python3 in interactive mode to check if exc_clear method is defined 
in sys,  command line like :
>>>import sys
>>>sys.__dict__["exc_clear"]
Traceback (most recent call last):
File "", line 1, in 
sys.exc_clear()
KeyError: 'exc_clear'
>>>


Is there any configuration i should do ? please help to give me an answer.


 谢谢!!

姓名 : 吴志高/Charles
电话 : (+086)13410859946

邮箱 : wuzhiga...@163.com

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