diff --git a/printer.py b/printer.py index 2872f7e..6be494d 100644 --- a/printer.py +++ b/printer.py @@ -17,7 +17,7 @@ from auth import Auth from urlparse import urlparse -class Printer(): +class Printer: BOUNDARY = mimetools.choose_boundary() CRLF = '\r\n' PROTOCOL = 'cloudprint://' @@ -92,7 +92,7 @@ def addPrinter( self, printername, uri, connection ) : connection.enablePrinter(printername) connection.acceptJobs(printername) connection.setPrinterShared(printername, False) - except Exception as error: + except Exception , error: result = error if result == None: print("Added " + printername) @@ -172,9 +172,8 @@ def readFile(self, pathname): s = f.read() except IOError, e: print('ERROR: Error reading %s\n%s', pathname, e) - finally: - f.close() - return s + f.close() + return s except IOError, e: print('ERROR: Error opening %s\n%s', pathname, e) return None @@ -196,8 +195,7 @@ def writeFile(self, file_name, data): f.write(data) except IOError, e: status = False - finally: - f.close() + f.close() except IOError, e: status = False @@ -353,6 +351,6 @@ def submitJob(self, printerid, jobtype, jobfile, jobname, printername ): print('ERROR: Print job %s failed with %s', jobtype, responseobj['message']) return False - except Exception as error_msg: + except Exception, error_msg: print('ERROR: Print job %s failed with %s', jobtype, error_msg) return False