<s> """<STR_LIT>""" <EOL> from twisted . python import log , usage <EOL> import sys <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> from twisted . internet import win32eventreactor <EOL> win32eventreactor . install ( ) <EOL> class GPSFixLogger : <EOL> def handle_fix ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> log . msg ( '<STR_LIT>' + <EOL> '<STR_LIT:\n>' . join ( map ( lambda n : '<STR_LIT>' % tuple ( n ) , zip ( ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , map ( repr , args ) ) ) ) ) <EOL> class GPSOptions ( usage . Options ) : <EOL> optFlags = [ <EOL> [ '<STR_LIT>' , '<STR_LIT:z>' , '<STR_LIT>' ] , <EOL> ] <EOL> optParameters = [ <EOL> [ '<STR_LIT>' , '<STR_LIT:o>' , None , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT:b>' , None , '<STR_LIT>' ] , <EOL> [ '<STR_LIT:port>' , '<STR_LIT:p>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> ] <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from twisted . internet import reactor <EOL> from twisted . internet . serialport import SerialPort <EOL> o = GPSOptions ( ) <EOL> try : <EOL> o . parseOptions ( ) <EOL> except usage . UsageError , errortext : <EOL> print '<STR_LIT>' % ( sys . argv [ <NUM_LIT:0> ] , errortext ) <EOL> print '<STR_LIT>' % ( sys . argv [ <NUM_LIT:0> ] ) <EOL> raise SystemExit , <NUM_LIT:1> <EOL> logFile = o . opts [ '<STR_LIT>' ] <EOL> if logFile is None : <EOL> logFile = sys . stdout <EOL> log . startLogging ( logFile ) <EOL> if o . opts [ '<STR_LIT>' ] : <EOL> from twisted . protocols . gps . rockwell import Zodiac as GPSProtocolBase <EOL> baudrate = <NUM_LIT> <EOL> else : <EOL> from twisted . protocols . gps . nmea import NMEAReceiver as GPSProtocolBase <EOL> baudrate = <NUM_LIT> <EOL> class GPSTest ( GPSProtocolBase , GPSFixLogger ) : <EOL> pass <EOL> if o . opts [ '<STR_LIT>' ] : <EOL> baudrate = int ( o . opts [ '<STR_LIT>' ] ) <EOL> port = o . opts [ '<STR_LIT:port>' ] <EOL> log . msg ( '<STR_LIT>' % ( port , baudrate , GPSProtocolBase . __name__ ) ) <EOL> s = SerialPort ( GPSTest ( ) , o . opts [ '<STR_LIT:port>' ] , reactor , baudrate = baudrate ) <EOL> reactor . run ( ) </s>
