# Path: debug_logging/utils.py
# def get_revision():
#     vcs = getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}).get('VCS', None)
#     if vcs == 'git':
#         module = import_module(settings.SETTINGS_MODULE)
#         path = os.path.realpath(os.path.dirname(module.__file__))
#         cmd = 'cd %s && git rev-parse --verify --short HEAD' % path
#         proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
#         proc_stdout, proc_stderr = proc.communicate()
#         return proc_stdout


from django.utils.translation import ugettext_lazy as _
from debug_logging.utils import get_revision
from debug_toolbar.panels import DebugPanel


class RevisionLoggingPanel(DebugPanel):
    """
    A panel to display the current source code revision. Currently only
    supports git.
    """
    name = 'Revision'
    has_content = False

    def nav_title(self):
        return _('Revision')

    def nav_subtitle(self):

# Path: debug_logging/utils.py
# def get_revision():
#     vcs = getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}).get('VCS', None)
#     if vcs == 'git':
#         module = import_module(settings.SETTINGS_MODULE)
#         path = os.path.realpath(os.path.dirname(module.__file__))
#         cmd = 'cd %s && git rev-parse --verify --short HEAD' % path
#         proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
#         proc_stdout, proc_stderr = proc.communicate()
#         return proc_stdout


# Path: debug_logging/panels/revision.py
from django.utils.translation import ugettext_lazy as _
from debug_logging.utils import get_revision
from debug_toolbar.panels import DebugPanel



class RevisionLoggingPanel(DebugPanel):
    """
    A panel to display the current source code revision. Currently only
    supports git.
    """
    name = 'Revision'
    has_content = False

    def nav_title(self):
        return _('Revision')

    def nav_subtitle(self):

        return self.get_revision() or 'Revision unavailable'