|
@@ -10,6 +10,7 @@ import platform
|
|
|
import ctypes as ct
|
|
|
from bitarray import bitarray
|
|
|
from greaseweazle.flux import Flux
|
|
|
+from greaseweazle import error
|
|
|
|
|
|
class CapsDateTimeExt(ct.Structure):
|
|
|
_pack_ = 1
|
|
@@ -139,15 +140,15 @@ class IPF:
|
|
|
ipf = cls(0, 0)
|
|
|
|
|
|
ipf.iid = ipf.lib.CAPSAddImage()
|
|
|
- assert ipf.iid >= 0, "Could not create IPF image container"
|
|
|
+ error.check(ipf.iid >= 0, "Could not create IPF image container")
|
|
|
cname = ct.c_char_p(name.encode())
|
|
|
res = ipf.lib.CAPSLockImage(ipf.iid, cname)
|
|
|
- assert res == 0, "Could not open IPF image '%s'" % name
|
|
|
+ error.check(res == 0, "Could not open IPF image '%s'" % name)
|
|
|
res = ipf.lib.CAPSLoadImage(ipf.iid, DI_LOCK.def_flags)
|
|
|
- assert res == 0, "Could not load IPF image '%s'" % name
|
|
|
+ error.check(res == 0, "Could not load IPF image '%s'" % name)
|
|
|
ipf.pi = CapsImageInfo()
|
|
|
res = ipf.lib.CAPSGetImageInfo(ct.byref(ipf.pi), ipf.iid)
|
|
|
- assert res == 0
|
|
|
+ error.check(res == 0, "Could not get info for IPF '%s'" % name)
|
|
|
print(ipf)
|
|
|
|
|
|
return ipf
|
|
@@ -163,7 +164,7 @@ class IPF:
|
|
|
ti = CapsTrackInfoT2(2)
|
|
|
res = self.lib.CAPSLockTrack(ct.byref(ti), self.iid,
|
|
|
cyl, head, DI_LOCK.def_flags)
|
|
|
- assert res == 0
|
|
|
+ error.check(res == 0, "Could not lock IPF track %d.%d" % (cyl, head))
|
|
|
|
|
|
if not ti.trackbuf:
|
|
|
return None
|
|
@@ -179,16 +180,16 @@ class IPF:
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
- assert ti.weakcnt == 0, "Can't yet handle weak data"
|
|
|
+ error.check(ti.weakcnt == 0, "Can't yet handle weak data")
|
|
|
|
|
|
|
|
|
|
|
@@ -252,16 +253,15 @@ def open_libcaps():
|
|
|
break
|
|
|
except:
|
|
|
pass
|
|
|
- if "lib" not in locals():
|
|
|
- print("""\
|
|
|
-** Could not find SPS/CAPS IPF decode library
|
|
|
+
|
|
|
+ error.check("lib" in locals(), """\
|
|
|
+Could not find SPS/CAPS IPF decode library
|
|
|
For installation instructions please read the wiki:
|
|
|
<https://github.com/keirf/Greaseweazle/wiki/IPF-Images>""")
|
|
|
- sys.exit(1)
|
|
|
|
|
|
|
|
|
res = lib.CAPSInit()
|
|
|
- assert res == 0, "Failure initialising %s" % libname
|
|
|
+ error.check(res == 0, "Failure initialising IPF library '%s'" % name)
|
|
|
|
|
|
return lib
|
|
|
|