Skip to content

Commit

Permalink
v0.6.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Oct 26, 2014
1 parent 9e1c544 commit a75cbdc
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
7 changes: 7 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions docs/monty.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ monty.string module
:show-inheritance:

monty.subprocess module
-------------------
-----------------------

.. automodule:: monty.subprocess
:members:
Expand All @@ -131,9 +131,8 @@ monty.tempfile module
:undoc-members:
:show-inheritance:


monty.termcolor module
---------------------
----------------------

.. automodule:: monty.termcolor
:members:
Expand Down
4 changes: 2 additions & 2 deletions monty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
20 changes: 13 additions & 7 deletions monty/subprocess.py
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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')
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={},
Expand Down

0 comments on commit a75cbdc

Please sign in to comment.