<commit_before># coding=utf-8
"""
"""
from __future__ import absolute_import, print_function, division

import os
import sys
import pkg_resources
from pip.vcs import vcs
from pathlib import Path

from flask import render_template

from ..panel import AdminPanel


class SysinfoPanel(AdminPanel):
  id = 'sysinfo'
  label = 'System information'
  icon = 'hdd'

  def get(self):
    uname = os.popen("uname -a").read()
    python_version = sys.version.strip()

    packages = []

    for dist in pkg_resources.working_set:
      package = dict(
          name=dist.project_name,
          key=dist.key,
          version=dist.version if dist.has_version() else u'Unknown version',
          vcs=None,
      )

      location = unicode(Path(dist.location).absolute())
      vcs_name = vcs.get_backend_name(location)

      if vcs_name:
        vc = vcs.get_backend_from_location(location)()
        url, revision = vc.get_info(location)
        package['vcs'] = dict(name=vcs_name, url=url, revision=revision)

      packages.append(package)
      packages.sort(key=lambda d: d.get('key', None))

    return render_template("admin/sysinfo.html",
                           python_version=python_version,
                           packages=packages,
                           uname=uname)<commit_msg>fix when package has no git remote repository<commit_after># coding=utf-8
"""
"""
from __future__ import absolute_import, print_function, division

import os
import sys
import pkg_resources
import pip
from pip.vcs import vcs
from pathlib import Path

from flask import render_template

from ..panel import AdminPanel


class SysinfoPanel(AdminPanel):
  id = 'sysinfo'
  label = 'System information'
  icon = 'hdd'

  def get(self):
    uname = os.popen("uname -a").read()
    python_version = sys.version.strip()

    packages = []

    for dist in pkg_resources.working_set:
      package = dict(
          name=dist.project_name,
          key=dist.key,
          version=dist.version if dist.has_version() else u'Unknown version',
          vcs=None,
      )

      location = unicode(Path(dist.location).absolute())
      vcs_name = vcs.get_backend_name(location)

      if vcs_name:
        vc = vcs.get_backend(vcs_name)()
        try:
          url = vc.get_url(location)
        except pip.exceptions.InstallationError:
          url = 'None'
        try:
          revision = vc.get_revision(location)
        except pip.exceptions.InstallationError:
          revision = 'None'
        package['vcs'] = dict(name=vcs_name, url=url, revision=revision)

      packages.append(package)
      packages.sort(key=lambda d: d.get('key', None))

    return render_template("admin/sysinfo.html",
                           python_version=python_version,
                           packages=packages,
                           uname=uname)
{'fraction_non_alphanumeric': 0.10042283298097252, 'fraction_numerical': 0.0007047216349541931, 'mean_word_length': 2.5531914893617023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7468129', 'n_tokens_mistral': 864, 'n_tokens_neox': 838, 'n_words': 193}