Skip to content

Commit

Permalink
Merge pull request #32 from rasbt/2.9.7
Browse files Browse the repository at this point in the history
raise `ValueError` if `monitor` is set to `True` and `psutils` is not
  • Loading branch information
rasbt committed May 15, 2016
2 parents f914dff + 31f851a commit 70f7d1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 2.9.8
================
- raise `ValueError` if `monitor` is set to `True` and `psutils` is not installed


Version 2.9.7
================
- requirements.txt for `psutil`, now supports `pip install pyprind -r requirements.txt`
Expand Down
2 changes: 1 addition & 1 deletion pyprind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
from .generator_factory import prog_bar


__version__ = '2.9.7'
__version__ = '2.9.8'
15 changes: 12 additions & 3 deletions pyprind/prog_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
import os
from io import UnsupportedOperation

try:
import psutil
psutil_import = True
except ImportError:
psutil_import = False


class Prog():
def __init__(self, iterations, track_time, stream, title,
Expand All @@ -40,9 +46,12 @@ def __init__(self, iterations, track_time, stream, title,
self._print_title()
self.update_interval = update_interval

if self.monitor:
import psutil
self.process = psutil.Process()
if monitor:
if not psutil_import:
raise ValueError('psutil package is required when using'
' the `monitor` option.')
else:
self.process = psutil.Process()
if self.track:
self.eta = 1

Expand Down

0 comments on commit 70f7d1f

Please sign in to comment.