diff vxi_11.py @ 56:91b476ebc0f2

Run through 2to3
author Daniel O'Connor <doconnor@gsoft.com.au>
date Tue, 08 Dec 2020 14:00:45 +1030
parents cba1c44060f5
children
line wrap: on
line diff
--- a/vxi_11.py	Tue Dec 08 13:59:05 2020 +1030
+++ b/vxi_11.py	Tue Dec 08 14:00:45 2020 +1030
@@ -22,7 +22,7 @@
 
 def close_all_connections():
 	"disconnect and close out all vxi_11 connections created here, even if their object references have been lost" 
-	for wobj in connection_dict.keys():
+	for wobj in list(connection_dict.keys()):
 		name, wconn=connection_dict[wobj]
 		conn=wconn() #dereference weak ref
 		if conn is not None:
@@ -55,10 +55,10 @@
 				"notconnected": "Device not connected"}
 	
 	def identify_vxi_11_error(self, error):
-		if self.vxi_11_errors.has_key(error):
-			return `error`+": "+self.vxi_11_errors[error]
+		if error in self.vxi_11_errors:
+			return repr(error)+": "+self.vxi_11_errors[error]
 		else:
-			return `error`+": Unknown error code"
+			return repr(error)+": Unknown error code"
 	
 
 	def __init__(self, code,  **other_info):
@@ -170,7 +170,7 @@
 		if level <= self.debug_level:
 			if file is None:
 				file=sys.stderr
-			print >> file, self.device_name, message
+			print(self.device_name, message, file=file)
 			
 	def fancy_log_error(self, message, level=debug_error, file=None):
 		if level <= self.debug_level:
@@ -178,8 +178,8 @@
 			level_str=("**INFO*****", "**ERROR****", "**WARNING**", "**DEBUG****")[level]
 			if file is None:
 				file=sys.stderr
-			print >> file, time.asctime().strip(), '\t', level_str, '\t', self.shortname, '\t', \
-				message.replace('\n','\n\t** ').replace('\r','\n\t** ')
+			print(time.asctime().strip(), '\t', level_str, '\t', self.shortname, '\t', \
+				message.replace('\n','\n\t** ').replace('\r','\n\t** '), file=file)
 
 	def log_error(self, message, level=debug_error, file=None):
 		"override log_error() for sending messages to special places or formatting differently"
@@ -273,7 +273,7 @@
 		
 		if err and self.raise_on_err:
 			e=_VXI_11_enumerated_exceptions #common, correctable exceptions
-			if e.has_key(err):
+			if err in e:
 				raise e[err](err) #raise these exceptions explicitly
 			else:
 				raise VXI_11_Error(err) #raise generic VXI_11 exception