Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
f0d9458c
Commit
f0d9458c
authored
Dec 10, 2013
by
Lee-Ping Wang
Browse files
Check for presence of gzip and bz2 modules
parent
8e656070
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
wrappers/python/simtk/openmm/app/statedatareporter.py
wrappers/python/simtk/openmm/app/statedatareporter.py
+14
-2
No files found.
wrappers/python/simtk/openmm/app/statedatareporter.py
View file @
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
...
...
@@ -71,8 +79,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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment