|
34 | 34 | import datetime
|
35 | 35 | import logging
|
36 | 36 | import os
|
37 |
| -import platform |
38 | 37 | import socket
|
39 | 38 | import struct
|
40 | 39 | import time
|
|
55 | 54 | MySQLCursorBufferedNamedTuple)
|
56 | 55 | from .network import MySQLUnixSocket, MySQLTCPSocket
|
57 | 56 | from .protocol import MySQLProtocol
|
58 |
| -from .utils import int1store, int4store, lc_int, linux_distribution |
| 57 | +from .utils import int1store, int4store, lc_int, get_platform |
59 | 58 | from .abstracts import MySQLConnectionAbstract
|
60 | 59 |
|
61 | 60 | logging.getLogger(__name__).addHandler(logging.NullHandler())
|
@@ -120,34 +119,23 @@ def __init__(self, *args, **kwargs):
|
120 | 119 |
|
121 | 120 | def _add_default_conn_attrs(self):
|
122 | 121 | """Add the default connection attributes."""
|
123 |
| - if os.name == "nt": |
124 |
| - if "64" in platform.architecture()[0]: |
125 |
| - platform_arch = "x86_64" |
126 |
| - elif "32" in platform.architecture()[0]: |
127 |
| - platform_arch = "i386" |
128 |
| - else: |
129 |
| - platform_arch = platform.architecture() |
130 |
| - os_ver = "Windows-{}".format(platform.win32_ver()[1]) |
131 |
| - else: |
132 |
| - platform_arch = platform.machine() |
133 |
| - if platform.system() == "Darwin": |
134 |
| - os_ver = "{}-{}".format("macOS", platform.mac_ver()[0]) |
135 |
| - else: |
136 |
| - os_ver = "-".join(linux_distribution()[0:2]) |
137 |
| - |
| 122 | + platform = get_platform() |
138 | 123 | license_chunks = version.LICENSE.split(" ")
|
139 | 124 | if license_chunks[0] == "GPLv2":
|
140 | 125 | client_license = "GPL-2.0"
|
141 | 126 | else:
|
142 | 127 | client_license = "Commercial"
|
143 | 128 | default_conn_attrs = {
|
144 | 129 | "_pid": str(os.getpid()),
|
145 |
| - "_platform": platform_arch, |
| 130 | + "_platform": platform["arch"], |
146 | 131 | "_source_host": socket.gethostname(),
|
147 | 132 | "_client_name": "mysql-connector-python",
|
148 | 133 | "_client_license": client_license,
|
149 |
| - "_client_version": ".".join([str(x) for x in version.VERSION[0:3]]), |
150 |
| - "_os": os_ver} |
| 134 | + "_client_version": ".".join( |
| 135 | + [str(x) for x in version.VERSION[0:3]] |
| 136 | + ), |
| 137 | + "_os": platform["version"], |
| 138 | + } |
151 | 139 |
|
152 | 140 | self._conn_attrs.update((default_conn_attrs))
|
153 | 141 |
|
|
0 commit comments