Commit d284e2b8 authored by Lee-Ping's avatar Lee-Ping
Browse files

Merge branch 'master' of https://github.com/leeping/openmm

parents 19d2885a f0d9458c
...@@ -31,8 +31,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. ...@@ -31,8 +31,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
__author__ = "Peter Eastman" __author__ = "Peter Eastman"
__version__ = "1.0" __version__ = "1.0"
import bz2 try:
import gzip import bz2
have_bz2 = True
except: have_bz2 = False
try:
import gzip
have_gzip = True
except: have_gzip = False
import simtk.openmm as mm import simtk.openmm as mm
import simtk.unit as unit import simtk.unit as unit
import math import math
...@@ -83,8 +91,12 @@ class StateDataReporter(object): ...@@ -83,8 +91,12 @@ class StateDataReporter(object):
# Detect the desired compression scheme from the filename extension # Detect the desired compression scheme from the filename extension
# and open all files unbuffered # and open all files unbuffered
if file.endswith('.gz'): if file.endswith('.gz'):
if not have_gzip:
raise RuntimeError("Cannpt write .gz file because Python could not import gzip library")
self._out = gzip.GzipFile(fileobj=open(file, 'wb', 0)) self._out = gzip.GzipFile(fileobj=open(file, 'wb', 0))
elif file.endswith('.bz2'): elif file.endswith('.bz2'):
if not have_bz2:
raise RuntimeError("Cannpt write .bz2 file because Python could not import bz2 library")
self._out = bz2.BZ2File(file, 'w', 0) self._out = bz2.BZ2File(file, 'w', 0)
else: else:
self._out = open(file, 'w', 0) self._out = open(file, 'w', 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment