From d1984d149899932c19a534c107bb40f27d5a6b82 Mon Sep 17 00:00:00 2001 From: Maeva Pourpoint <maeva@passcal.nmt.edu> Date: Wed, 14 Oct 2020 14:25:30 -0600 Subject: [PATCH] Update code to handle "error writing fixed header" bug --- mseedpeek/libtrace.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mseedpeek/libtrace.py b/mseedpeek/libtrace.py index e8a3f41..4a7f924 100755 --- a/mseedpeek/libtrace.py +++ b/mseedpeek/libtrace.py @@ -134,7 +134,7 @@ class futils: """ def __init__(self, infile): - self.infile = open(infile, 'rb') + self.infile = open(infile, 'r+b') def close(self): self.infile.close() @@ -557,10 +557,19 @@ class Mseed(futils): SeqNum = self.Pad(hdrlist[0][0], 6) # SeqNum DQual = hdrlist[0][1] # DataQual Res = hdrlist[0][2] # Reserved + Stat = self.Pad(hdrlist[0][3], 5) # Stat Loc = self.Pad(hdrlist[0][4], 2) # Loc Chan = self.Pad(hdrlist[0][5], 3) # Chan Net = self.Pad(hdrlist[0][6], 2) # Net + if isinstance(Stat, str): + Stat = Stat.encode() + if isinstance(Loc, str): + Loc = Loc.encode() + if isinstance(Chan, str): + Chan = Chan.encode() + if isinstance(Net, str): + Net = Net.encode() # time info # fmtstr1 = fmtorderstr + "HHBBBBH" @@ -592,8 +601,8 @@ class Mseed(futils): self.infilewrite(pack_hdr) return 48 - except Exception: - print("error writing fixed header") + except Exception as e: + print("error writing fixed header - {}".format(e)) return 0 ######################################################### -- GitLab