Skip to content

Commit b0864df

Browse files
committed
style/lint improvements
1 parent 01aed3e commit b0864df

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

amdgpu-chk

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,19 @@ warnings.filterwarnings('ignore')
4343

4444

4545
class GutConst:
46+
"""
47+
Base object for chk util. These are simplified versions of what are in env module designed to run in python2
48+
in order to detect setup issues even if wrong version of python.
49+
"""
4650
def __init__(self):
4751
self.DEBUG = False
4852

4953
def check_env(self):
54+
"""
55+
Checks python version, kernel version, and amd gpu driver version.
56+
:return: A list of 3 integers representing status of 3 check items.
57+
:rtype: list
58+
"""
5059
ret_val = [0, 0, 0]
5160
# Check python version
5261
required_pversion = [3, 6]
@@ -133,11 +142,16 @@ GUT_CONST = GutConst()
133142

134143

135144
def is_venv_installed():
145+
"""
146+
Check if a venv is being used
147+
:return: True if using venv
148+
:rtype: bool
149+
"""
136150
cmdstr = 'python3 -m venv -h > /dev/null'
137151
try:
138152
p = subprocess.Popen(shlex.split(cmdstr), shell=False, stdin=subprocess.PIPE,
139153
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
140-
output, error = p.communicate()
154+
output, _error = p.communicate()
141155
# print('subprocess output: ', output.decode(), 'subprocess error: ', error.decode())
142156
if not re.fullmatch(r'.*No module named.*', output.decode()):
143157
print('python3 venv is installed')
@@ -152,6 +166,11 @@ def is_venv_installed():
152166

153167

154168
def does_amdgpu_utils_env_exist():
169+
"""
170+
Check if venv exists.
171+
:return: Return True if venv exists.
172+
:rtype: bool
173+
"""
155174
env_name = './amdgpu-utils-env/bin/activate'
156175

157176
if os.path.isfile(env_name):
@@ -164,6 +183,11 @@ def does_amdgpu_utils_env_exist():
164183

165184

166185
def is_in_venv():
186+
"""
187+
Check if execution is from within a venv.
188+
:return: True if in venv
189+
:rtype: bool
190+
"""
167191
try:
168192
python_path = shutil.which('python')
169193
except (NameError, AttributeError):
@@ -180,6 +204,10 @@ def is_in_venv():
180204

181205

182206
def main():
207+
"""
208+
Main flow for chk utility.
209+
:return: None
210+
"""
183211
parser = argparse.ArgumentParser()
184212
parser.add_argument('--about', help='README', action='store_true', default=False)
185213
parser.add_argument('-d', '--debug', help='Debug output', action='store_true', default=False)

0 commit comments

Comments
 (0)