Changeset 20
- Timestamp:
- 09/17/07 06:42:12 (1 year ago)
- Files:
-
- fizzjik/fizzjik/input/basic.py (modified) (2 diffs)
- fizzjik/fizzjik/output/lpr.py (modified) (1 diff)
- fizzjik/fizzjik/process.py (added)
- fizzjik/test.cfg (modified) (1 diff)
- fizzjik/test.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
fizzjik/fizzjik/input/basic.py
r19 r20 48 48 class PollingInput(Input): 49 49 delay = 10 50 startDelayed = True50 immediate = False 51 51 52 52 def __init__(self): … … 56 56 def startService(self): 57 57 Input.startService(self) 58 self.poller.start(self.delay, not self.startDelayed)58 self.poller.start(self.delay, self.immediate) 59 59 60 60 @if_config('enabled') fizzjik/fizzjik/output/lpr.py
r17 r20 1 1 import os 2 2 3 from twisted.application import service4 from twisted.internet import protocol, reactor3 from fizzjik.interfaces import IOutput, implements 4 from fizzjik.process import ProcessService, ProcessProtocol 5 5 6 7 from fizzjik.interfaces import IOutput, IConfigurable, implements 8 from fizzjik.config import ConfigurableMixin, if_config 9 10 class LPRProcessProtocol(protocol.ProcessProtocol): 6 class LPRProcessProtocol(ProcessProtocol): 11 7 posix_exec = 'lpr' 12 8 posix_args = ['lpr'] 13 9 14 def __init__(self, platform="posix"): 15 self.platform = platform 16 17 def connectionMade(self): 18 print "connection made..." 19 20 def spawn(self, *args): 21 self.running = True 22 reactor.spawnProcess(self, self.getExec(), args=self.getArgs()+list(args), env=os.environ) 23 24 def kill(self): 25 self.transport.signalProcess('KILL') 26 27 def processEnded(self, reason): 28 print reason 29 30 def outReceived(self, line): 31 print "\n".join(["out >> %s"%(x) for x in line.splitlines()]) 32 33 def errReceived(self, line): 34 print "\n".join(["err !! %s"%(x) for x in line.splitlines()]) 35 36 def getExec(self): 37 return getattr(self, '%s_exec'%(self.platform)) 38 39 def getArgs(self): 40 return getattr(self, '%s_args'%(self.platform)) 41 42 def print_(self, f): 43 self.spawn() 10 def print_(self, f, *args): 11 self.spawn(*args) 44 12 data = f.read() 45 13 self.transport.write(data) 46 14 self.transport.closeStdin() 47 15 48 class LPRService( service.Service, ConfigurableMixin):16 class LPRService(ProcessService): 49 17 implements(IOutput) 50 51 18 enabled = True 52 19 platform = "posix" 53 20 54 @if_config('enabled') 55 def startService(self): 56 self.printer = LPRProcessProtocol(self.platform) 57 pass 58 59 def stopService(self): 60 pass 61 62 def print_(self, f): 21 def print_(self, f, *args): 63 22 if self.reallyPrint: 64 self.pr inter.print_(f)23 self.protocol.print_(f, *args) 65 24 else: 66 25 print "would be printing:", 67 26 print f.name 68 69 def stop(self):70 self.printer.stop()71 72 fizzjik/test.cfg
r19 r20 23 23 has_outputs = False 24 24 25 [NetworkConnectionSensor] 26 delay = 10 27 25 28 [MPlayerService] 26 29 enabled = False fizzjik/test.py
r19 r20 20 20 21 21 from fizzjik.output.basic import Echo 22 from fizzjik.output.lpr import LPRService 22 23 from fizzjik.output.growl import GrowlService 23 24
