diff scpi.py @ 71:00800345fbae

Python3ise RSIB code
author Daniel O'Connor <doconnor@gsoft.com.au>
date Thu, 24 Aug 2023 16:52:10 +0930
parents e2833d081413
children ca5a822c550a
line wrap: on
line diff
--- a/scpi.py	Mon Aug 30 12:40:43 2021 +0930
+++ b/scpi.py	Thu Aug 24 16:52:10 2023 +0930
@@ -25,7 +25,6 @@
 # SUCH DAMAGE.
 #
 
-import exceptions
 import numpy
 import re
 
@@ -56,7 +55,7 @@
     data = clean(data)
 
     if data[0] != '#':
-        raise exceptions.ValueError('data length header incorrect')
+        raise ValueError('data length header incorrect')
     dlenlen = int(data[1])
     if dlenlen == 0:
         return numpy.array([])
@@ -71,7 +70,7 @@
         data = data[0:-1]
         
     if len(data) != wanted:
-        raise exceptions.ValueError('length mismatch, header says %d, actually got %d bytes' % (wanted, len(data)))
+        raise ValueError('length mismatch, header says %d, actually got %d bytes' % (wanted, len(data)))
     return numpy.frombuffer(data[2 + dlenlen:], dtype = dtype)
 
 def ascdecode(data, dtype = numpy.float32, sep = None):
@@ -96,7 +95,7 @@
 def instURL(url):
     m = insturlre.match(url)
     if m == None:
-        raise exceptions.ValueError('Unable to parse URL')
+        raise ValueError('Unable to parse URL')
     proto, xxx, user, xxx, pwd, address, xxx, port = m.groups()
     if proto == 'rsib':
         import rsib
@@ -113,6 +112,6 @@
         import scpisock
         return scpisock.SCPISockDevice(address, port)
     else:
-        raise exceptions.NotImplementedError("unknown protocol " + proto)
+        raise NotImplementedError("unknown protocol " + proto)