Skip to content

Commit 7380375

Browse files
author
Andreas Buesching
committed
* notifier/version.py: set version to 0.8.3
* notifier/nf_generic.py (step): remove socket if poll returned state POLLNVAL * notifier/popen.py (Process.dead): check if output object is not None before flushing the buffer
1 parent edb7b44 commit 7380375

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

notifier/dispatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# a generic dispatcher implementation
77
#
8-
# Copyright (C) 2006, 2007, 2009
8+
# Copyright (C) 2006, 2007, 2009, 2010
99
# Andreas Büsching <crunchy@bitkipper.net>
1010
#
1111
# This library is free software; you can redistribute it and/or modify

notifier/log.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# log - a logging facility for the generic notifier module
77
#
8-
# Copyright (C) 2005, 2006
8+
# Copyright (C) 2005, 2006, 2010
99
# Andreas Büsching <crunchy@bitkipper.net>
1010
#
1111
# This library is free software; you can redistribute it and/or modify
@@ -26,11 +26,23 @@
2626
import sys
2727

2828
instance = logging.getLogger( 'notifier' )
29-
instance.addHandler( logging.StreamHandler( sys.stderr ) )
29+
formatter = logging.Formatter( "%(asctime)s: %(name)s: %(levelname)-8s: %(message)s" )
30+
stream = logging.StreamHandler( sys.stderr )
31+
stream.setFormatter( formatter )
32+
try:
33+
file = logging.FileHandler( '/var/log/python-notifier.log' )
34+
file.setFormatter( formatter )
35+
except:
36+
pass
37+
38+
instance.addHandler( stream )
39+
instance.addHandler( file )
3040

3141
debug = instance.debug
3242
info = instance.info
3343
warn = instance.warn
3444
error = instance.error
3545
critical = instance.critical
3646
exception = instance.exception
47+
48+
set_level = instance.setLevel

notifier/nf_generic.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,23 @@ def socket_add( id, method, condition = IO_READ ):
7676
global __sockets, __sock_objects, __poll
7777

7878
# ensure that already registered condition do not get lost
79+
conditions = condition
7980
for cond in ( IO_READ, IO_WRITE, IO_EXCEPT ):
8081
if id in __sockets[ cond ]:
81-
condition |= cond
82+
conditions |= cond
8283

8384
fd = _get_fd( id )
8485
if fd >= 0:
8586
__sock_objects[ fd ] = id
8687
__sockets[ condition ][ fd ] = method
87-
__poll.register( fd, condition )
88+
__poll.register( fd, conditions )
8889
else:
8990
raise AttributeError( 'could not get file description: %s' % id )
9091

9192
def socket_remove( id, condition = IO_READ ):
9293
"""Removes the given socket from scheduler. If no condition is
9394
specified the default is IO_READ."""
94-
global __sockets, __poll
95+
global __sockets, __poll, __sock_objects
9596

9697
if condition == IO_ALL:
9798
for c in ( IO_READ, IO_WRITE, IO_EXCEPT ):
@@ -104,7 +105,7 @@ def socket_remove( id, condition = IO_READ ):
104105
fd = None
105106
# file descriptor already closed
106107
for cond in ( IO_READ, IO_WRITE, IO_EXCEPT ):
107-
for deskriptor, item in __sockets[ cond ].items():
108+
for descriptor, item in __sock_objects.items():
108109
if item == id:
109110
fd = descriptor
110111
break
@@ -244,7 +245,7 @@ def step( sleep = True, external = True ):
244245
# check for errors
245246
if condition == select.POLLERR:
246247
if fd in __sockets[ IO_EXCEPT ] and not __sockets[ IO_EXCEPT ][ fd ]( sock_obj ):
247-
socket_remove( sock_obj, cond )
248+
socket_remove( sock_obj, IO_EXCEPT )
248249
continue
249250
for cond in ( IO_READ, IO_WRITE ):
250251
if cond & condition and fd in __sockets[ cond ] and \

notifier/signals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# a generic signal implementation for propagating asynchron events
77
#
8-
# Copyright (C) 2005, 2006
8+
# Copyright (C) 2005, 2006, 2010
99
# Andreas Büsching <crunchy@bitkipper.net>
1010
#
1111
# This library is free software; you can redistribute it and/or modify

0 commit comments

Comments
 (0)