# Path: web/common.py
# def string_clean_hex(line):
#     """
#     replace non printable chars with their hex code
#     :param line:
#     :return: str
#     """
#     line = str(line)
#     new_line = ''
#     for c in line:
#         if c in string.printable:
#             new_line += c
#         else:
#             new_line += '\\x' + c.encode('hex')
#     return new_line


import logging
import sys
import os
import copy
import StringIO
import json
import volatility.conf as conf
import volatility.obj as obj
import volatility.registry as registry
import volatility.commands as commands
import volatility.addrspace as addrspace
import volatility.constants as constants
import volatility.debug as debug
import volatility.utils as utils
from web.common import string_clean_hex
        :return:
        """
        strio = StringIO.StringIO()
        plugin = plugin_class(copy.deepcopy(self.config))
        plugin.render_dot(strio, plugin.calculate())
        return strio.getvalue()

    def get_json(self, plugin_class):
        """
        return json output for a plugin
        :param plugin_class:
        :return:
        """
        strio = StringIO.StringIO()
        plugin = plugin_class(copy.deepcopy(self.config))
        plugin.render_json(strio, plugin.calculate())
        return json.loads(strio.getvalue(), parse_int=str)

    def get_text(self, plugin_class):
        """
        return text output of a plugin in json format
        :param plugin_class:
        :return:
        """
        strio = StringIO.StringIO()
        plugin = plugin_class(copy.deepcopy(self.config))
        plugin.render_text(strio, plugin.calculate())
        plugin_data = strio.getvalue()

        # AS this is all text lets clean it up a bit so its viable to store in json

# Path: web/common.py
# def string_clean_hex(line):
#     """
#     replace non printable chars with their hex code
#     :param line:
#     :return: str
#     """
#     line = str(line)
#     new_line = ''
#     for c in line:
#         if c in string.printable:
#             new_line += c
#         else:
#             new_line += '\\x' + c.encode('hex')
#     return new_line


# Path: web/vol_interface.py
import logging
import sys
import os
import copy
import StringIO
import json
import volatility.conf as conf
import volatility.obj as obj
import volatility.registry as registry
import volatility.commands as commands
import volatility.addrspace as addrspace
import volatility.constants as constants
import volatility.debug as debug
import volatility.utils as utils
from web.common import string_clean_hex

        :return:
        """
        strio = StringIO.StringIO()
        plugin = plugin_class(copy.deepcopy(self.config))
        plugin.render_dot(strio, plugin.calculate())
        return strio.getvalue()

    def get_json(self, plugin_class):
        """
        return json output for a plugin
        :param plugin_class:
        :return:
        """
        strio = StringIO.StringIO()
        plugin = plugin_class(copy.deepcopy(self.config))
        plugin.render_json(strio, plugin.calculate())
        return json.loads(strio.getvalue(), parse_int=str)

    def get_text(self, plugin_class):
        """
        return text output of a plugin in json format
        :param plugin_class:
        :return:
        """
        strio = StringIO.StringIO()
        plugin = plugin_class(copy.deepcopy(self.config))
        plugin.render_text(strio, plugin.calculate())
        plugin_data = strio.getvalue()

        # AS this is all text lets clean it up a bit so its viable to store in json

        plugin_data = string_clean_hex(plugin_data)