diff --git a/obspy/sac/sacio.py b/obspy/sac/sacio.py index eb90bbe0bd2..27ef4dcc3ee 100644 --- a/obspy/sac/sacio.py +++ b/obspy/sac/sacio.py @@ -25,6 +25,7 @@ from future.builtins import * # NOQA from future.utils import native_str +import os import time import warnings @@ -467,8 +468,9 @@ def IsSACfile(self, fh, fsize=True, lenchk=False): Test for a valid SAC file using arrays. """ cur_pos = fh.tell() - length = fh.seek(0, 2) - fh.seek(cur_pos, 0) + fh.seek(0, os.SEEK_END) + length = fh.tell() + fh.seek(cur_pos, os.SEEK_SET) try: npts = self.GetHvalue('npts') except: @@ -526,7 +528,7 @@ def ReadSacHeader(self, fh): try: # if it is not a valid SAC-file try with big endian # byte order - fh.seek(0, 0) + fh.seek(0, os.SEEK_SET) self.hf = frombuffer(fh.read(4 * 70), dtype=native_str('>f4')) self.hi = frombuffer(fh.read(4 * 40), dtype=native_str('>i4')) # read in the char values @@ -566,7 +568,7 @@ def WriteSacHeader(self, fh): >>> u.GetHvalueFromFile('test2.sac',"kevnm") # doctest: +SKIP 'hullahulla ' """ - fh.seek(0, 0) # set pointer to the file beginning + fh.seek(0, os.SEEK_SET) try: # write the header fh.write(self.hf.data) @@ -616,7 +618,7 @@ def ReadSacFile(self, fh, fsize=True): try: # if it is not a valid SAC-file try with big endian # byte order - fh.seek(0, 0) + fh.seek(0, os.SEEK_SET) self.hf = frombuffer(fh.read(4 * 70), dtype=native_str('>f4')) self.hi = frombuffer(fh.read(4 * 40), dtype=native_str('>i4')) # read in the char values