"platforms/vscode:/vscode.git/clone" did not exist on "dd80fb3fdcba6a75803f8e68f444a657fe42d4f5"
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.
__author__ = "Peter Eastman"
__version__ = "1.0"
import bz2
import gzip
try:
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.unit as unit
import math
......@@ -83,8 +91,12 @@ class StateDataReporter(object):
# Detect the desired compression scheme from the filename extension
# and open all files unbuffered
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))
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)
else:
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