File: help.py

package info (click to toggle)
python-cloudscraper 1.2.71~git20230426.cbb3c0ea-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,608 kB
  • sloc: python: 2,496; makefile: 37
file content (72 lines) | stat: -rw-r--r-- 2,100 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import json
import platform
import requests
import ssl
import sys
import urllib3

from collections import OrderedDict
from . import __version__ as cloudscraper_version

# ------------------------------------------------------------------------------- #


def getPossibleCiphers():
    try:
        context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
        context.set_ciphers('ALL')
        return sorted([cipher['name'] for cipher in context.get_ciphers()])
    except AttributeError:
        return 'get_ciphers() is unsupported'

# ------------------------------------------------------------------------------- #


def _pythonVersion():
    interpreter = platform.python_implementation()
    interpreter_version = platform.python_version()

    if interpreter == 'PyPy':
        interpreter_version = \
            f'{sys.pypy_version_info.major}.{sys.pypy_version_info.minor}.{sys.pypy_version_info.micro}'
        if sys.pypy_version_info.releaselevel != 'final':
            interpreter_version = f'{interpreter_version}{sys.pypy_version_info.releaselevel}'
    return {
        'name': interpreter,
        'version': interpreter_version
    }

# ------------------------------------------------------------------------------- #


def systemInfo():
    try:
        platform_info = {
            'system': platform.system(),
            'release': platform.release(),
        }
    except IOError:
        platform_info = {
            'system': 'Unknown',
            'release': 'Unknown',
        }

    return OrderedDict([
        ('platform', platform_info),
        ('interpreter', _pythonVersion()),
        ('cloudscraper', cloudscraper_version),
        ('requests', requests.__version__),
        ('urllib3', urllib3.__version__),
        ('OpenSSL', OrderedDict(
            [
                ('version', ssl.OPENSSL_VERSION),
                ('ciphers', getPossibleCiphers())
            ]
        ))
    ])

# ------------------------------------------------------------------------------- #


if __name__ == '__main__':
    print(json.dumps(systemInfo(), indent=4))