-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from workhorsy/bye_bye_py2
Bye bye py2
- Loading branch information
Showing
16 changed files
with
41 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014-2021 Matthew Brennan Jones <[email protected]> | ||
Copyright (c) 2014-2022 Matthew Brennan Jones <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
|
||
import sys | ||
|
||
if sys.version_info[0] == 2: | ||
from cpuinfo import * | ||
else: | ||
from cpuinfo.cpuinfo import * | ||
from cpuinfo.cpuinfo import * | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: UTF-8 -*- | ||
|
||
# Copyright (c) 2014-2021 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python 2 & 3 | ||
# Copyright (c) 2014-2022 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python | ||
# It uses the MIT License | ||
# It is hosted at: https://github.com/workhorsy/py-cpuinfo | ||
# | ||
|
@@ -34,7 +34,6 @@ | |
import ctypes | ||
|
||
|
||
IS_PY2 = sys.version_info[0] == 2 | ||
CAN_CALL_CPUID_IN_SUBPROCESS = True | ||
|
||
g_trace = None | ||
|
@@ -47,11 +46,7 @@ def __init__(self, is_active, is_stored_in_string): | |
return | ||
|
||
from datetime import datetime | ||
|
||
if IS_PY2: | ||
from cStringIO import StringIO | ||
else: | ||
from io import StringIO | ||
from io import StringIO | ||
|
||
if is_stored_in_string: | ||
self._output = StringIO() | ||
|
@@ -335,9 +330,8 @@ def _run_and_get_stdout(command, pipe_command=None): | |
|
||
# Get the stdout and stderr | ||
stdout_output, stderr_output = p1.communicate() | ||
if not IS_PY2: | ||
stdout_output = stdout_output.decode(encoding='UTF-8') | ||
stderr_output = stderr_output.decode(encoding='UTF-8') | ||
stdout_output = stdout_output.decode(encoding='UTF-8') | ||
stderr_output = stderr_output.decode(encoding='UTF-8') | ||
|
||
# Send the result to the logger | ||
g_trace.command_output('return code:', str(p1.returncode)) | ||
|
@@ -394,9 +388,7 @@ def _b64_to_obj(thing): | |
return {} | ||
|
||
def _utf_to_str(input): | ||
if IS_PY2 and isinstance(input, unicode): | ||
return input.encode('utf-8') | ||
elif isinstance(input, list): | ||
if isinstance(input, list): | ||
return [_utf_to_str(element) for element in input] | ||
elif isinstance(input, dict): | ||
return {_utf_to_str(key): _utf_to_str(value) | ||
|
@@ -1516,10 +1508,7 @@ def _get_cpu_info_from_cpuid_actual(): | |
It will safely call this function in another process. | ||
''' | ||
|
||
if IS_PY2: | ||
from cStringIO import StringIO | ||
else: | ||
from io import StringIO | ||
from io import StringIO | ||
|
||
trace = Trace(True, True) | ||
info = {} | ||
|
@@ -2733,8 +2722,7 @@ def get_cpu_info_json(): | |
if p1.returncode != 0: | ||
return "{}" | ||
|
||
if not IS_PY2: | ||
output = output.decode(encoding='UTF-8') | ||
output = output.decode(encoding='UTF-8') | ||
|
||
return output | ||
|
||
|
@@ -2758,7 +2746,7 @@ def main(): | |
import json | ||
|
||
# Parse args | ||
parser = ArgumentParser(description='Gets CPU info with pure Python 2 & 3') | ||
parser = ArgumentParser(description='Gets CPU info with pure Python') | ||
parser.add_argument('--json', action='store_true', help='Return the info in JSON format') | ||
parser.add_argument('--version', action='store_true', help='Return the version of py-cpuinfo') | ||
parser.add_argument('--trace', action='store_true', help='Traces code paths used to find CPU info to file') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools == 44.1.1", | ||
"setuptools_scm == 2.1.0", | ||
"setuptools", | ||
"wheel", | ||
] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[bdist_wheel] | ||
universal = 1 | ||
universal = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Copyright (c) 2014-2021 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python 2 & 3 | ||
# Copyright (c) 2014-2022 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python | ||
# It uses the MIT License | ||
# It is hosted at: https://github.com/workhorsy/py-cpuinfo | ||
|
||
|
@@ -14,7 +14,7 @@ | |
version = "8.0.0", | ||
author = "Matthew Brennan Jones", | ||
author_email = "[email protected]", | ||
description = "Get CPU info with pure Python 2 & 3", | ||
description = "Get CPU info with pure Python", | ||
long_description=readme_content, | ||
license = "MIT", | ||
url = "https://github.com/workhorsy/py-cpuinfo", | ||
|
@@ -27,7 +27,6 @@ | |
"Development Status :: 5 - Production/Stable", | ||
"Topic :: Utilities", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 2.7", | ||
"Programming Language :: Python :: 3" | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: UTF-8 -*- | ||
|
||
# Copyright (c) 2014-2021 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python 2 & 3 | ||
# Copyright (c) 2014-2022 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python | ||
# It uses the MIT License | ||
# It is hosted at: https://github.com/workhorsy/py-cpuinfo | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: UTF-8 -*- | ||
|
||
# Copyright (c) 2014-2021 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python 2 & 3 | ||
# Copyright (c) 2014-2022 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python | ||
# It uses the MIT License | ||
# It is hosted at: https://github.com/workhorsy/py-cpuinfo | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: UTF-8 -*- | ||
|
||
# Copyright (c) 2014-2021 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python 2 & 3 | ||
# Copyright (c) 2014-2022 Matthew Brennan Jones <[email protected]> | ||
# Py-cpuinfo gets CPU info with pure Python | ||
# It uses the MIT License | ||
# It is hosted at: https://github.com/workhorsy/py-cpuinfo | ||
# | ||
|
@@ -40,7 +40,6 @@ | |
except ImportError as err: | ||
pass | ||
|
||
IS_PY2 = sys.version_info[0] == 2 | ||
is_windows = platform.system().lower() == 'windows' | ||
|
||
out_file_name = 'system_info.txt' | ||
|
@@ -53,16 +52,14 @@ def run_and_get_stdout(command, pipe_command=None): | |
if not pipe_command: | ||
p1 = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) | ||
output = p1.communicate()[0] | ||
if not IS_PY2: | ||
output = output.decode(encoding='UTF-8') | ||
output = output.decode(encoding='UTF-8') | ||
return p1.returncode, output | ||
else: | ||
p1 = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) | ||
p2 = Popen(pipe_command, stdin=p1.stdout, stdout=PIPE, stderr=PIPE) | ||
p1.stdout.close() | ||
output = p2.communicate()[0] | ||
if not IS_PY2: | ||
output = output.decode(encoding='UTF-8') | ||
output = output.decode(encoding='UTF-8') | ||
return p2.returncode, output | ||
|
||
def program_paths(program_name): | ||
|