@@ -77,7 +77,7 @@ def sendHeader(self):
7777 pass
7878
7979 def _write (self , data ):
80- print ('usbresponse write' )
80+ Print . info ('usbresponse write' )
8181 if self .bytesSent == 0 and not self .headersSent :
8282 self .sendHeader ()
8383
@@ -99,10 +99,9 @@ def __init__(self, url):
9999 self .head = False
100100 self .url = urlparse (self .path )
101101
102- print ('url ' + self .path );
102+ Print . info ('url ' + self .path );
103103
104104 self .bits = [x for x in self .url .path .split ('/' ) if x ]
105- print (self .bits )
106105 self .query = parse_qs (self .url .query )
107106
108107 try :
@@ -126,9 +125,9 @@ def __init__(self, i, o):
126125 self .o = o
127126
128127 def recv (self , timeout = 60000 ):
129- print ('begin recv' )
128+ Print . info ('begin recv' )
130129 header = bytes (self .i .read (32 , timeout = timeout ))
131- print ('read complete' )
130+ Print . info ('read complete' )
132131 magic = header [:4 ]
133132 self .command = int .from_bytes (header [4 :8 ], byteorder = 'little' )
134133 self .size = int .from_bytes (header [8 :16 ], byteorder = 'little' )
@@ -138,15 +137,15 @@ def recv(self, timeout = 60000):
138137 self .timestamp = int .from_bytes (header [24 :32 ], byteorder = 'little' )
139138
140139 if magic != b'\x12 \x12 \x12 \x12 ' :
141- print ('invalid magic! ' + str (magic ));
140+ Print . error ('invalid magic! ' + str (magic ));
142141 return False
143142
144- print ('receiving %d bytes' % self .size )
143+ Print . info ('receiving %d bytes' % self .size )
145144 self .payload = bytes (self .i .read (self .size , timeout = 0 ))
146145 return True
147146
148147 def send (self , timeout = 60000 ):
149- print ('sending %d bytes' % len (self .payload ))
148+ Print . info ('sending %d bytes' % len (self .payload ))
150149 self .o .write (b'\x12 \x12 \x12 \x12 ' , timeout = timeout )
151150 self .o .write (struct .pack ('<I' , self .command ), timeout = timeout )
152151 self .o .write (struct .pack ('<Q' , len (self .payload )), timeout = timeout ) # size
@@ -161,14 +160,14 @@ def poll_commands(in_ep, out_ep):
161160 while True :
162161 if p .recv (0 ):
163162 if p .command == 1 :
164- print ('Recv command! %d' % p .command )
163+ Print . debug ('Recv command! %d' % p .command )
165164 req = UsbRequest (p .payload .decode ('utf-8' ))
166165 with UsbResponse (p ) as resp :
167166 Server .route (req , resp )
168167 else :
169- print ('Unknown command! %d' % p .command )
168+ Print . error ('Unknown command! %d' % p .command )
170169 else :
171- print ('failed to read!' )
170+ Print . error ('failed to read!' )
172171
173172def daemon ():
174173 global status
@@ -199,5 +198,5 @@ def daemon():
199198
200199 poll_commands (in_ep , out_ep )
201200 except BaseException as e :
202- print ('usb exception: ' + str (e ))
201+ Print . error ('usb exception: ' + str (e ))
203202 time .sleep (1 )
0 commit comments