aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/version_check.py
blob: 63f3e87662d5ef73a5f8b87bb21310f811918419 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
Having installed a wrong version of pyOpenSSL or netlib is unfortunately a
very common source of error. Check before every start that both versions
are somewhat okay.
"""
from __future__ import division, absolute_import, print_function
import sys
import inspect
import os.path
import six

import OpenSSL

PYOPENSSL_MIN_VERSION = (0, 15)


def check_pyopenssl_version(min_version=PYOPENSSL_MIN_VERSION, fp=sys.stderr):
    min_version_str = u".".join(six.text_type(x) for x in min_version)
    try:
        v = tuple(int(x) for x in OpenSSL.__version__.split(".")[:2])
    except ValueError:
        print(
            u"Cannot parse pyOpenSSL version: {}"
            u"mitmproxy requires pyOpenSSL {} or greater.".format(
                OpenSSL.__version__, min_version_str
            ),
            file=fp
        )
        return
    if v < min_version:
        print(
            u"You are using an outdated version of pyOpenSSL: "
            u"mitmproxy requires pyOpenSSL {} or greater.".format(min_version_str),
            file=fp
        )
        # Some users apparently have multiple versions of pyOpenSSL installed.
        # Report which one we got.
        pyopenssl_path = os.path.dirname(inspect.getfile(OpenSSL))
        print(
            u"Your pyOpenSSL {} installation is located at {}".format(
                OpenSSL.__version__, pyopenssl_path
            ),
            file=fp
        )
        sys.exit(1)
n class="n">ADM5120_GPIO_PIN6, "wan_cond", NULL), GPIO_LED_INV(ADM5120_GPIO_PIN7, "wifi", NULL), GPIO_LED_INV(ADM5120_GPIO_P0L2, "usb1", NULL), GPIO_LED_INV(ADM5120_GPIO_P1L0, "lan1", NULL), GPIO_LED_INV(ADM5120_GPIO_P1L2, "usb2", NULL), GPIO_LED_INV(ADM5120_GPIO_P2L0, "lan2", NULL), GPIO_LED_INV(ADM5120_GPIO_P2L2, "usb3", NULL), GPIO_LED_INV(ADM5120_GPIO_P3L0, "lan3", NULL), GPIO_LED_INV(ADM5120_GPIO_P3L2, "usb4", NULL), GPIO_LED_INV(ADM5120_GPIO_P4L0, "wan", NULL), }; static u8 np28g_vlans[6] __initdata = { 0x50, 0x42, 0x44, 0x48, 0x00, 0x00 }; static void np28g_reset(void) { gpio_set_value(ADM5120_GPIO_PIN4, 0); } static void __init np28g_setup(void) { compex_generic_setup(); /* setup reset line */ gpio_request(ADM5120_GPIO_PIN4, NULL); gpio_direction_output(ADM5120_GPIO_PIN4, 1); adm5120_board_reset = np28g_reset; adm5120_add_device_switch(4, np28g_vlans); adm5120_add_device_usb(); adm5120_add_device_gpio_leds(ARRAY_SIZE(np28g_gpio_leds), np28g_gpio_leds); adm5120_pci_set_irq_map(ARRAY_SIZE(np28g_pci_irqs), np28g_pci_irqs); } ADM5120_BOARD(MACH_ADM5120_NP28G, "Compex NetPassage 28G", np28g_setup);