Re: [Twisted-Python] accurate periodic call

2012-02-22 Thread Phil Mayers
On 02/22/2012 03:20 AM, Tristan Seligmann wrote:
> On Tue, Feb 21, 2012 at 1:05 PM, Phil Mayers  wrote:
>> I realise this is tricky to solve, but I'll note it's not impossible for
>> really REALLY big clock skews to happen. For example: recently we had a
>> server kernel panic and need a cold reboot. The machine booted and read
>> it's time from the CMOS clock, which was way WAY out. A minute or two
>> after the machine had booted, NTP slewed the clock back by months...
>
> This is kind of a nitpick, but I think it's a fairly important one:
> "slewing" the clock refers to a process where the clock frequency is

Sorry, you're quite right. Stepping, not slewing. Brain hiccup.

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


[Twisted-Python] Conch text attribute flattening quirks

2012-02-22 Thread Jonathan Jacobs
Hello,

I'm hoping to wrap up work on ticket #3844 [1] before the next release of 
Twisted, however there are a few quirks in the small DSL used for specifying 
text with attributes (see the ticket for some commentary on these.)

I decided to look more closely at what happens with Conch (which is where the 
DSL originally came from and has remained largely unchanged) in some of the 
places I was having problems with the IRC formatting. I was struck by something 
that looks like it is rather incorrect behaviour (on Twisted trunk as of 
2012/2/22 and Twisted 11.0.0 on Debian):

>>> from twisted.conch.insults.helper import CharacterAttribute
>>> from twisted.conch.insults.text import flatten, attributes as A
>>> flatten(A.normal['hello', A.bold[' world '], 'quux'], CharacterAttribute())
'hello\x1b[1m world quux'

My expectations are that only " world " will be marked up with bold attributes, 
since it is the only piece of content in the "bold" attribute, while "hello" 
and "quux" both appear in normal text, i.e. without any additional markup. 
Looking at the output you can see that "hello" appears as normal text and then 
" world quux" appears in bold.

Is this the expected behaviour? There are no tests that actually test this 
particular case, as far as I can tell, except for 
twisted.conch.test.test_text.EfficiencyTestCase but that is marked as "todo" 
(the tests themselves do indeed fail.) While the name of this test case 
indicates tests for efficient markup, as far as I can tell these tests also 
assume (and fail) that the structure is flattened the same way I was expecting.

Any guidance would be appreciated.

Regards

[1] 

-- 
Jonathan



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


Re: [Twisted-Python] Conch text attribute flattening quirks

2012-02-22 Thread Tim Allen
On Wed, Feb 22, 2012 at 01:47:46PM +0200, Jonathan Jacobs wrote:
> >>> from twisted.conch.insults.helper import CharacterAttribute
> >>> from twisted.conch.insults.text import flatten, attributes as A
> >>> flatten(A.normal['hello', A.bold[' world '], 'quux'], 
> >>> CharacterAttribute())
> 'hello\x1b[1m world quux'
> 
> My expectations are that only " world " will be marked up with bold
> attributes, since it is the only piece of content in the "bold"
> attribute, while "hello" and "quux" both appear in normal text, i.e.
> without any additional markup. Looking at the output you can see that
> "hello" appears as normal text and then " world quux" appears in bold.

Since it's in twisted.conch, I'm guessing that this character-attribute
stuff is designed to model the VT100 character attribute system, rather
than some generic tree-of-strings-and-attributes. For example, somebody
used to the way HTML works might want to nest bold and italics like
this:

hello world quux

However, to achieve the same result on a traditional terminal (and using
the tput(1) command to produce the formatting codes), you'd have to do
something like this:

tput sitm   # enable italics
echo -n "hello "
tput bold   # enable bold
echo -n "world"
tput sgr0   # disable all special attributes
tput sitm   # enable italics again
echo " quux"

...that is, there's no code for 'end bold' or 'end italics' (or blink, dim,
underline, invisible, any kind of colouring, etc.) just an 'end all
special attributes' code. Therefore it's reasonable for conch's helper
library to not handle nested formatting, since no terminal program will
produce such a thing, because it's impossible to represent in the
VT100/VT200 formatting language.

I guess an argument could be made that the helper function should track
which attributes are enabled at any particular point in the string, and
calculate the correct sequence of disable-everything/re-enable-the-
remaining-attributes codes, but evidently nobody's needed such a thing
before.

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


Re: [Twisted-Python] Conch text attribute flattening quirks

2012-02-22 Thread Jonathan Jacobs
On Wed, Feb 22, 2012 at 17:25, Tim Allen  wrote:
> ...that is, there's no code for 'end bold' or 'end italics' (or blink, dim,
> underline, invisible, any kind of colouring, etc.) just an 'end all
> special attributes' code. Therefore it's reasonable for conch's helper
> library to not handle nested formatting, since no terminal program will
> produce such a thing, because it's impossible to represent in the
> VT100/VT200 formatting language.

I understand this, but then what is the point of placing content into
A.bold in the first place? Why not just drop A.bold into a flat
stream: [foo, A.bold, bar]

What's more confusing is that there are a handful of tests that
describe this nesting and even test it, although none of them (except
for the one marked TODO, which fails because of the problem I've
described) actually test adding things to the parent level after
nesting an attribute.

> I guess an argument could be made that the helper function should track
> which attributes are enabled at any particular point in the string, and
> calculate the correct sequence of disable-everything/re-enable-the-
> remaining-attributes codes, but evidently nobody's needed such a thing
> before.

It's not actually even all that hard, there is nothing in particular
to additionally track if you don't mind being a little inefficient
about it, which is how the IRC code in #3844 does it.

-- 
Jonathan

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


Re: [Twisted-Python] Which mocker tool for trial ?

2012-02-22 Thread Nicolas AGIUS
Thanks for the tips, Mockito work great with Trial.

But it's a bit lazy for my needs, I think I''ll try to use Mock 
(http://www.voidspace.org.uk/python/mock/)

Thx

--- En date de : Mar 21.2.12, Johan Rydberg  a 
écrit :

De: Johan Rydberg 
Objet: Re: [Twisted-Python] Which mocker tool for trial ?
À: nicolas.ag...@lps-it.fr, "Twisted general discussion" 

Date: Mardi 21 février 2012, 8h58

We're using python-mockito and it works pretty good.  I've also hacked it a 
bitso that it works with zope interfaces.  See this post, which also contains a 
linkto the bitbucket project:
http://jrydberg.me/post/10519590583/strict-mocking-with-zope-interfaces
On Feb 20, 2012, at 6:04 PM, Nicolas AGIUS wrote:
Which tool are you using for mocking ?
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python