示例#1
0
def generate_report(title, log_url=None, trace=None, connection_info={}):
    """Build our formatted GitHub issue string"""
    try:
        # os.uname() is not available on Windows
        uname = platform.uname()
        os_string = ' (%s %s %s)' % (uname[0], uname[2], uname[4])
    except AttributeError:
        os_string = ''

    content = [
        "*Automatic bug report from end-user.*",
        "\n## Environment\n",
        "**Add-on Name:** %s" % utils.get_addon_name(),
        "**Add-on ID:** %s" % utils.get_addon_id(),
        "**Add-on Version:** %s" % utils.get_addon_version(),
        "**Add-on URL:** %s" % sys.argv[2],
        "**Kodi Version:** %s" % utils.get_kodi_version(),
        "**Python Version:** %s" % sys.version.replace('\n', ''),
        "**IP Address:** %s" % connection_info.get('ip', 'N/A'),
        "**Hostname:** %s" % connection_info.get('hostname', 'N/A'),
        "**Country:** %s" % connection_info.get('country', 'N/A'),
        "**ISP:** %s" % connection_info.get('org', 'N/A'),
        "**Operating System:** %s %s" % (sys.platform, os_string),
        "**Platform:** %s" % utils.get_platform(),
        "**Python Path:**\n```\n%s\n```" % '\n'.join(sys.path),
    ]

    if trace:
        content.append("\n## Traceback\n```\n%s\n```" % trace)

    if log_url:
        content.append("\n[Full log](%s)" % log_url)

    short_id = utils.get_addon_id().split('.')[-1]
    title = '[%s] %s' % (short_id, title)
    # Github throws HTTP 422 if title is too long
    report = {
        'title': title[:255],
        'body': '\n'.join(content)
    }

    return report
示例#2
0
 def test_get_addon_name(self):
     addon_name = utils.get_addon_name()
     self.assertEqual('Test Add-on', addon_name)