|
132 | 132 | # Standard Unix uses /dev/null
|
133 | 133 | DEV_NULL = '/dev/null'
|
134 | 134 |
|
135 |
| -# Directory to search for configuration information on Unix. |
136 |
| -# Constant used by test_platform to test linux_distribution(). |
137 |
| -_UNIXCONFDIR = '/etc' |
138 |
| - |
139 | 135 | ### Platform specific APIs
|
140 | 136 |
|
141 | 137 | _libc_search = re.compile(b'(__libc_init)'
|
@@ -249,138 +245,6 @@ def _dist_try_harder(distname, version, id):
|
249 | 245 |
|
250 | 246 | return distname, version, id
|
251 | 247 |
|
252 |
| -_release_filename = re.compile(r'(\w+)[-_](release|version)', re.ASCII) |
253 |
| -_lsb_release_version = re.compile(r'(.+)' |
254 |
| - r' release ' |
255 |
| - r'([\d.]+)' |
256 |
| - r'[^(]*(?:\((.+)\))?', re.ASCII) |
257 |
| -_release_version = re.compile(r'([^0-9]+)' |
258 |
| - r'(?: release )?' |
259 |
| - r'([\d.]+)' |
260 |
| - r'[^(]*(?:\((.+)\))?', re.ASCII) |
261 |
| - |
262 |
| -# See also http://www.novell.com/coolsolutions/feature/11251.html |
263 |
| -# and http://linuxmafia.com/faq/Admin/release-files.html |
264 |
| -# and http://data.linux-ntfs.org/rpm/whichrpm |
265 |
| -# and http://www.die.net/doc/linux/man/man1/lsb_release.1.html |
266 |
| - |
267 |
| -_supported_dists = ( |
268 |
| - 'SuSE', 'debian', 'fedora', 'redhat', 'centos', |
269 |
| - 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', |
270 |
| - 'UnitedLinux', 'turbolinux', 'arch', 'mageia') |
271 |
| - |
272 |
| -def _parse_release_file(firstline): |
273 |
| - |
274 |
| - # Default to empty 'version' and 'id' strings. Both defaults are used |
275 |
| - # when 'firstline' is empty. 'id' defaults to empty when an id can not |
276 |
| - # be deduced. |
277 |
| - version = '' |
278 |
| - id = '' |
279 |
| - |
280 |
| - # Parse the first line |
281 |
| - m = _lsb_release_version.match(firstline) |
282 |
| - if m is not None: |
283 |
| - # LSB format: "distro release x.x (codename)" |
284 |
| - return tuple(m.groups()) |
285 |
| - |
286 |
| - # Pre-LSB format: "distro x.x (codename)" |
287 |
| - m = _release_version.match(firstline) |
288 |
| - if m is not None: |
289 |
| - return tuple(m.groups()) |
290 |
| - |
291 |
| - # Unknown format... take the first two words |
292 |
| - l = firstline.strip().split() |
293 |
| - if l: |
294 |
| - version = l[0] |
295 |
| - if len(l) > 1: |
296 |
| - id = l[1] |
297 |
| - return '', version, id |
298 |
| - |
299 |
| -def linux_distribution(distname='', version='', id='', |
300 |
| - |
301 |
| - supported_dists=_supported_dists, |
302 |
| - full_distribution_name=1): |
303 |
| - import warnings |
304 |
| - warnings.warn("dist() and linux_distribution() functions are deprecated " |
305 |
| - "in Python 3.5", DeprecationWarning, stacklevel=2) |
306 |
| - return _linux_distribution(distname, version, id, supported_dists, |
307 |
| - full_distribution_name) |
308 |
| - |
309 |
| -def _linux_distribution(distname, version, id, supported_dists, |
310 |
| - full_distribution_name): |
311 |
| - |
312 |
| - """ Tries to determine the name of the Linux OS distribution name. |
313 |
| -
|
314 |
| - The function first looks for a distribution release file in |
315 |
| - /etc and then reverts to _dist_try_harder() in case no |
316 |
| - suitable files are found. |
317 |
| -
|
318 |
| - supported_dists may be given to define the set of Linux |
319 |
| - distributions to look for. It defaults to a list of currently |
320 |
| - supported Linux distributions identified by their release file |
321 |
| - name. |
322 |
| -
|
323 |
| - If full_distribution_name is true (default), the full |
324 |
| - distribution read from the OS is returned. Otherwise the short |
325 |
| - name taken from supported_dists is used. |
326 |
| -
|
327 |
| - Returns a tuple (distname, version, id) which default to the |
328 |
| - args given as parameters. |
329 |
| -
|
330 |
| - """ |
331 |
| - try: |
332 |
| - etc = os.listdir(_UNIXCONFDIR) |
333 |
| - except OSError: |
334 |
| - # Probably not a Unix system |
335 |
| - return distname, version, id |
336 |
| - etc.sort() |
337 |
| - for file in etc: |
338 |
| - m = _release_filename.match(file) |
339 |
| - if m is not None: |
340 |
| - _distname, dummy = m.groups() |
341 |
| - if _distname in supported_dists: |
342 |
| - distname = _distname |
343 |
| - break |
344 |
| - else: |
345 |
| - return _dist_try_harder(distname, version, id) |
346 |
| - |
347 |
| - # Read the first line |
348 |
| - with open(os.path.join(_UNIXCONFDIR, file), 'r', |
349 |
| - encoding='utf-8', errors='surrogateescape') as f: |
350 |
| - firstline = f.readline() |
351 |
| - _distname, _version, _id = _parse_release_file(firstline) |
352 |
| - |
353 |
| - if _distname and full_distribution_name: |
354 |
| - distname = _distname |
355 |
| - if _version: |
356 |
| - version = _version |
357 |
| - if _id: |
358 |
| - id = _id |
359 |
| - return distname, version, id |
360 |
| - |
361 |
| -# To maintain backwards compatibility: |
362 |
| - |
363 |
| -def dist(distname='', version='', id='', |
364 |
| - |
365 |
| - supported_dists=_supported_dists): |
366 |
| - |
367 |
| - """ Tries to determine the name of the Linux OS distribution name. |
368 |
| -
|
369 |
| - The function first looks for a distribution release file in |
370 |
| - /etc and then reverts to _dist_try_harder() in case no |
371 |
| - suitable files are found. |
372 |
| -
|
373 |
| - Returns a tuple (distname, version, id) which default to the |
374 |
| - args given as parameters. |
375 |
| -
|
376 |
| - """ |
377 |
| - import warnings |
378 |
| - warnings.warn("dist() and linux_distribution() functions are deprecated " |
379 |
| - "in Python 3.5", DeprecationWarning, stacklevel=2) |
380 |
| - return _linux_distribution(distname, version, id, |
381 |
| - supported_dists=supported_dists, |
382 |
| - full_distribution_name=0) |
383 |
| - |
384 | 248 | def popen(cmd, mode='r', bufsize=-1):
|
385 | 249 |
|
386 | 250 | """ Portable popen() interface.
|
@@ -1338,26 +1202,11 @@ def platform(aliased=0, terse=0):
|
1338 | 1202 | platform = _platform(system, release, version, csd)
|
1339 | 1203 |
|
1340 | 1204 | elif system in ('Linux',):
|
1341 |
| - # Linux based systems |
1342 |
| - with warnings.catch_warnings(): |
1343 |
| - # see issue #1322 for more information |
1344 |
| - warnings.filterwarnings( |
1345 |
| - 'ignore', |
1346 |
| - r'dist\(\) and linux_distribution\(\) ' |
1347 |
| - 'functions are deprecated .*', |
1348 |
| - DeprecationWarning, |
1349 |
| - ) |
1350 |
| - distname, distversion, distid = dist('') |
1351 |
| - if distname and not terse: |
1352 |
| - platform = _platform(system, release, machine, processor, |
1353 |
| - 'with', |
1354 |
| - distname, distversion, distid) |
1355 |
| - else: |
1356 |
| - # If the distribution name is unknown check for libc vs. glibc |
1357 |
| - libcname, libcversion = libc_ver(sys.executable) |
1358 |
| - platform = _platform(system, release, machine, processor, |
1359 |
| - 'with', |
1360 |
| - libcname+libcversion) |
| 1205 | + # check for libc vs. glibc |
| 1206 | + libcname, libcversion = libc_ver(sys.executable) |
| 1207 | + platform = _platform(system, release, machine, processor, |
| 1208 | + 'with', |
| 1209 | + libcname+libcversion) |
1361 | 1210 | elif system == 'Java':
|
1362 | 1211 | # Java platforms
|
1363 | 1212 | r, v, vminfo, (os_name, os_version, os_arch) = java_ver()
|
|
0 commit comments