Skip to content

Commit

Permalink
Users don't need psutil module
Browse files Browse the repository at this point in the history
  • Loading branch information
andresriancho committed Jan 27, 2015
1 parent ea8c342 commit e6914ce
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions w3af/core/controllers/profiling/psutil_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"""
import os
import sys
import json
import psutil

from .utils.ps_mem import get_memory_usage, cmd_with_count
from .utils import get_filename_fmt, dump_data_every_thread, cancel_thread
Expand All @@ -32,11 +32,27 @@
SAVE_PSUTIL_PTR = []


def user_wants_psutil():
_should_profile = os.environ.get('W3AF_PSUTILS', '0')

if _should_profile.isdigit() and int(_should_profile) == 1:
return True

return False


if user_wants_psutil():
try:
# User's don't need this module
import psutil
except ImportError, ie:
print('Failed to import psutil: %s' % ie)
sys.exit(-1)


def should_dump_psutil(wrapped):
def inner(w3af_core):
_should_profile = os.environ.get('W3AF_PSUTILS', '0')

if _should_profile.isdigit() and int(_should_profile) == 1:
if user_wants_psutil():
return wrapped(w3af_core)

return inner
Expand Down

0 comments on commit e6914ce

Please sign in to comment.