diff --git a/docs/index.rst b/docs/index.rst index df8c204d2..cbdfcf748 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -37,6 +37,13 @@ Monty is tested to work on Python 2.7 and 3.x. Latest Change Log ================= +v0.6.0 +------ +1. New frozendict and MongoDict (allows for Javascript like access of nested + dicts) classes (Matteo). +2. New Command class in subprocess which allows commands to be run in separate + thread with timeout (Matteo). + v0.5.9 ------ 1. More fixes for reverse read of gzipped files ofr Py3k. diff --git a/docs/monty.rst b/docs/monty.rst index 9cbcd61f4..bfb32ea4f 100644 --- a/docs/monty.rst +++ b/docs/monty.rst @@ -116,7 +116,7 @@ monty.string module :show-inheritance: monty.subprocess module -------------------- +----------------------- .. automodule:: monty.subprocess :members: @@ -131,9 +131,8 @@ monty.tempfile module :undoc-members: :show-inheritance: - monty.termcolor module ---------------------- +---------------------- .. automodule:: monty.termcolor :members: diff --git a/monty/__init__.py b/monty/__init__.py index d8858bc97..6f7b891e3 100644 --- a/monty/__init__.py +++ b/monty/__init__.py @@ -7,7 +7,7 @@ __author__ = 'Shyue Ping Ong' __copyright__ = 'Copyright 2014, The Materials Virtual Lab' -__version__ = '0.5.9' +__version__ = '0.6.0' __maintainer__ = 'Shyue Ping Ong' __email__ = 'ongsp@ucsd.edu' -__date__ = 'Oct 5 2014' +__date__ = 'Oct 22 2014' diff --git a/monty/subprocess.py b/monty/subprocess.py index 5ec72dae1..a14cc67a3 100644 --- a/monty/subprocess.py +++ b/monty/subprocess.py @@ -1,5 +1,6 @@ # coding: utf-8 -from __future__ import absolute_import, print_function, division, unicode_literals +from __future__ import absolute_import, print_function, division, \ + unicode_literals __author__ = 'Matteo Giantomass' __copyright__ = "Copyright 2014, The Materials Virtual Lab" @@ -11,7 +12,8 @@ class Command(object): """ - Enables to run subprocess commands in a different thread with TIMEOUT option. + Enables to run subprocess commands in a different thread with TIMEOUT + option. Based on jcollado's solution: http://stackoverflow.com/questions/1191374/subprocess-with-timeout/4825933#4825933 @@ -51,7 +53,7 @@ def __init__(self, command): self.killed = False def __str__(self): - return "command: %s, retcode: %s" % (str(self.command), str(self.retcode)) + return "command: %s, retcode: %s" % (self.command, self.retcode) def run(self, timeout=None, **kwargs): """ @@ -61,10 +63,11 @@ def run(self, timeout=None, **kwargs): Return: self """ from subprocess import Popen, PIPE - def target(**kwargs): + + def target(**kw): try: #print('Thread started') - self.process = Popen(self.command, **kwargs) + self.process = Popen(self.command, **kw) self.output, self.error = self.process.communicate() self.retcode = self.process.returncode #print('Thread stopped') @@ -74,8 +77,11 @@ def target(**kwargs): self.retcode = -1 # default stdout and stderr - if 'stdout' not in kwargs: kwargs['stdout'] = PIPE - if 'stderr' not in kwargs: kwargs['stderr'] = PIPE + if 'stdout' not in kwargs: + kwargs['stdout'] = PIPE + + if 'stderr' not in kwargs: + kwargs['stderr'] = PIPE # thread import threading diff --git a/setup.py b/setup.py index 559f427ca..6a9787200 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="monty", packages=find_packages(), - version="0.5.9", + version="0.6.0", install_requires=[], extras_require={"yaml": ["pyyaml>=3.1"],}, package_data={},