The following issues were found

tools/power/pm-graph/sleepgraph.py
6995 issues
subprocess call with shell=True identified, security issue.
Security injection

Line: 482
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              	def setCallgraphBlacklist(self, file):
		self.cgblacklist = self.listFromFile(file)
	def rtcWakeAlarmOn(self):
		call('echo 0 > '+self.rtcpath+'/wakealarm', shell=True)
		nowtime = open(self.rtcpath+'/since_epoch', 'r').read().strip()
		if nowtime:
			nowtime = int(nowtime)
		else:
			# if hardware time fails, use the software time

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 490
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              			# if hardware time fails, use the software time
			nowtime = int(datetime.now().strftime('%s'))
		alarm = nowtime + self.rtcwaketime
		call('echo %d > %s/wakealarm' % (alarm, self.rtcpath), shell=True)
	def rtcWakeAlarmOff(self):
		call('echo 0 > %s/wakealarm' % self.rtcpath, shell=True)
	def initdmesg(self):
		# get the latest time stamp from the dmesg log
		lines = Popen('dmesg', stdout=PIPE).stdout.readlines()

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 492
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              		alarm = nowtime + self.rtcwaketime
		call('echo %d > %s/wakealarm' % (alarm, self.rtcpath), shell=True)
	def rtcWakeAlarmOff(self):
		call('echo 0 > %s/wakealarm' % self.rtcpath, shell=True)
	def initdmesg(self):
		# get the latest time stamp from the dmesg log
		lines = Popen('dmesg', stdout=PIPE).stdout.readlines()
		ktime = '0'
		for line in reversed(lines):

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 541
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              	def getFtraceFilterFunctions(self, current):
		self.rootCheck(True)
		if not current:
			call('cat '+self.tpath+'available_filter_functions', shell=True)
			return
		master = self.listFromFile(self.tpath+'available_filter_functions')
		for i in sorted(self.tracefuncs):
			if 'func' in self.tracefuncs[i]:
				i = self.tracefuncs[i]['func']

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 855
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              	def sudoUserchown(self, dir):
		if os.path.exists(dir) and self.sudouser:
			cmd = 'chown -R {0}:{0} {1} > /dev/null 2>&1'
			call(cmd.format(self.sudouser, dir), shell=True)
	def outputResult(self, testdata, num=0):
		if not self.result:
			return
		n = ''
		if num > 0:

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 1235
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              		if self.sudouser:
			xset = 'sudo -u %s %s' % (self.sudouser, xset)
		if cmd == 'init':
			ret = call(xset.format('dpms 0 0 0'), shell=True)
			if not ret:
				ret = call(xset.format('s off'), shell=True)
		elif cmd == 'reset':
			ret = call(xset.format('s reset'), shell=True)
		elif cmd in ['on', 'off', 'standby', 'suspend']:

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 1237
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              		if cmd == 'init':
			ret = call(xset.format('dpms 0 0 0'), shell=True)
			if not ret:
				ret = call(xset.format('s off'), shell=True)
		elif cmd == 'reset':
			ret = call(xset.format('s reset'), shell=True)
		elif cmd in ['on', 'off', 'standby', 'suspend']:
			b4 = self.displayControl('stat')
			ret = call(xset.format('dpms force %s' % cmd), shell=True)

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 1239
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              			if not ret:
				ret = call(xset.format('s off'), shell=True)
		elif cmd == 'reset':
			ret = call(xset.format('s reset'), shell=True)
		elif cmd in ['on', 'off', 'standby', 'suspend']:
			b4 = self.displayControl('stat')
			ret = call(xset.format('dpms force %s' % cmd), shell=True)
			if not ret:
				curr = self.displayControl('stat')

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 1242
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              			ret = call(xset.format('s reset'), shell=True)
		elif cmd in ['on', 'off', 'standby', 'suspend']:
			b4 = self.displayControl('stat')
			ret = call(xset.format('dpms force %s' % cmd), shell=True)
			if not ret:
				curr = self.displayControl('stat')
				self.vprint('Display Switched: %s -> %s' % (b4, curr))
				if curr != cmd:
					self.vprint('WARNING: Display failed to change to %s' % cmd)

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 3071
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              		self.running = False
	def procstat(self):
		c = ['cat /proc/[1-9]*/stat 2>/dev/null']
		process = Popen(c, shell=True, stdout=PIPE)
		running = dict()
		for line in process.stdout:
			data = ascii(line).split()
			pid = data[0]
			name = re.sub('[()]', '', data[1])

            

Reported by Bandit.

tools/perf/scripts/python/exported-sql-viewer.py
5266 issues
Unable to import 'PySide2.QtCore'
Error

Line: 121 Column: 3

              pyside_version_1 = True
if not "--pyside-version-1" in sys.argv:
	try:
		from PySide2.QtCore import *
		from PySide2.QtGui import *
		from PySide2.QtSql import *
		from PySide2.QtWidgets import *
		pyside_version_1 = False
	except:

            

Reported by Pylint.

Unable to import 'PySide2.QtGui'
Error

Line: 122 Column: 3

              if not "--pyside-version-1" in sys.argv:
	try:
		from PySide2.QtCore import *
		from PySide2.QtGui import *
		from PySide2.QtSql import *
		from PySide2.QtWidgets import *
		pyside_version_1 = False
	except:
		pass

            

Reported by Pylint.

Unable to import 'PySide2.QtSql'
Error

Line: 123 Column: 3

              	try:
		from PySide2.QtCore import *
		from PySide2.QtGui import *
		from PySide2.QtSql import *
		from PySide2.QtWidgets import *
		pyside_version_1 = False
	except:
		pass


            

Reported by Pylint.

Unable to import 'PySide2.QtWidgets'
Error

Line: 124 Column: 3

              		from PySide2.QtCore import *
		from PySide2.QtGui import *
		from PySide2.QtSql import *
		from PySide2.QtWidgets import *
		pyside_version_1 = False
	except:
		pass

if pyside_version_1:

            

Reported by Pylint.

Unable to import 'PySide.QtCore'
Error

Line: 130 Column: 2

              		pass

if pyside_version_1:
	from PySide.QtCore import *
	from PySide.QtGui import *
	from PySide.QtSql import *

from decimal import Decimal, ROUND_HALF_UP
from ctypes import CDLL, Structure, create_string_buffer, addressof, sizeof, \

            

Reported by Pylint.

Unable to import 'PySide.QtGui'
Error

Line: 131 Column: 2

              
if pyside_version_1:
	from PySide.QtCore import *
	from PySide.QtGui import *
	from PySide.QtSql import *

from decimal import Decimal, ROUND_HALF_UP
from ctypes import CDLL, Structure, create_string_buffer, addressof, sizeof, \
		   c_void_p, c_bool, c_byte, c_char, c_int, c_uint, c_longlong, c_ulonglong

            

Reported by Pylint.

Unable to import 'PySide.QtSql'
Error

Line: 132 Column: 2

              if pyside_version_1:
	from PySide.QtCore import *
	from PySide.QtGui import *
	from PySide.QtSql import *

from decimal import Decimal, ROUND_HALF_UP
from ctypes import CDLL, Structure, create_string_buffer, addressof, sizeof, \
		   c_void_p, c_bool, c_byte, c_char, c_int, c_uint, c_longlong, c_ulonglong
from multiprocessing import Process, Array, Value, Event

            

Reported by Pylint.

Undefined variable 'QThread'
Error

Line: 190 Column: 14

              
# Background thread

class Thread(QThread):

	done = Signal(object)

	def __init__(self, task, param=None, parent=None):
		super(Thread, self).__init__(parent)

            

Reported by Pylint.

Undefined variable 'Signal'
Error

Line: 192 Column: 9

              
class Thread(QThread):

	done = Signal(object)

	def __init__(self, task, param=None, parent=None):
		super(Thread, self).__init__(parent)
		self.task = task
		self.param = param

            

Reported by Pylint.

Undefined variable 'QAbstractItemModel'
Error

Line: 211 Column: 17

              
# Tree data model

class TreeModel(QAbstractItemModel):

	def __init__(self, glb, params, parent=None):
		super(TreeModel, self).__init__(parent)
		self.glb = glb
		self.params = params

            

Reported by Pylint.

tools/power/pm-graph/bootgraph.py
1035 issues
subprocess call with shell=True identified, security issue.
Security injection

Line: 466
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              	sysvals.systemInfo(aslib.dmidecode(sysvals.mempath))
	sysvals.initTestOutput('boot')
	sysvals.writeDatafileHeader(sysvals.dmesgfile)
	call('dmesg >> '+sysvals.dmesgfile, shell=True)
	if not sysvals.useftrace:
		return
	# get ftrace
	sysvals.writeDatafileHeader(sysvals.ftracefile)
	call('cat '+sysvals.tpath+'trace >> '+sysvals.ftracefile, shell=True)

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 471
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              		return
	# get ftrace
	sysvals.writeDatafileHeader(sysvals.ftracefile)
	call('cat '+sysvals.tpath+'trace >> '+sysvals.ftracefile, shell=True)

# Function: colorForName
# Description:
#	 Generate a repeatable color from a list for a given name
def colorForName(name):

            

Reported by Bandit.

subprocess call with shell=True identified, security issue.
Security injection

Line: 1097
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html

              	if testrun and os.path.isdir(sysvals.testdir) and \
		os.getuid() == 0 and 'SUDO_USER' in os.environ:
		cmd = 'chown -R {0}:{0} {1} > /dev/null 2>&1'
		call(cmd.format(os.environ['SUDO_USER'], sysvals.testdir), shell=True)

	sysvals.stamp['boot'] = (data.tUserMode - data.start) * 1000
	sysvals.stamp['lastinit'] = data.end * 1000
	sysvals.outputResult(sysvals.stamp)

            

Reported by Bandit.

Unused import time
Error

Line: 28 Column: 1

              # ----------------- LIBRARIES --------------------

import sys
import time
import os
import string
import re
import platform
import shutil

            

Reported by Pylint.

Unused import string
Error

Line: 30 Column: 1

              import sys
import time
import os
import string
import re
import platform
import shutil
from datetime import datetime, timedelta
from subprocess import call, Popen, PIPE

            

Reported by Pylint.

__init__ method from base class 'SystemValues' is not called
Error

Line: 71 Column: 2

              	timeformat = '%.6f'
	bootloader = 'grub'
	blexec = []
	def __init__(self):
		self.hostname = platform.node()
		self.testtime = datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
		if os.path.exists('/proc/version'):
			fp = open('/proc/version', 'r')
			val = fp.read().strip()

            

Reported by Pylint.

Redefining name 'val' from outer scope (line 920)
Error

Line: 76 Column: 4

              		self.testtime = datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
		if os.path.exists('/proc/version'):
			fp = open('/proc/version', 'r')
			val = fp.read().strip()
			fp.close()
			self.kernel = self.kernelVersion(val)
		else:
			self.kernel = 'unknown'
		self.testdir = datetime.now().strftime('boot-%y%m%d-%H%M%S')

            

Reported by Pylint.

Redefining name 'val' from outer scope (line 920)
Error

Line: 85 Column: 3

              	def kernelVersion(self, msg):
		return msg.split()[2]
	def checkFtraceKernelVersion(self):
		val = tuple(map(int, self.kernel.split('-')[0].split('.')))
		if val >= (4, 10, 0):
			return True
		return False
	def kernelParams(self):
		cmdline = 'initcall_debug log_buf_len=32M'

            

Reported by Pylint.

Redefining name 'val' from outer scope (line 920)
Error

Line: 105 Column: 27

              			'ftrace_graph_filter=%s' % \
				(bs, self.max_graph_depth, self.graph_filter)
		return cmdline
	def setGraphFilter(self, val):
		master = self.getBootFtraceFilterFunctions()
		fs = ''
		for i in val.split(','):
			func = i.strip()
			if func == '':

            

Reported by Pylint.

Redefining built-in 'list'
Error

Line: 130 Column: 3

              		fp = open(self.tpath+'available_filter_functions')
		fulllist = fp.read().split('\n')
		fp.close()
		list = []
		for i in fulllist:
			if not i or ' ' in i or '[' in i or ']' in i:
				continue
			list.append(i)
		return list

            

Reported by Pylint.

tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
928 issues
Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 353
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

                  if os.path.exists('cpu.csv'):
        for index in range(0, current_max_cpu + 1):
            if cpu_mask[int(index)] != 0:
                os.system('grep -m 1 common_cpu cpu.csv > cpu{:0>3}.csv'.format(index))
                os.system('grep CPU_{:0>3} cpu.csv >> cpu{:0>3}.csv'.format(index, index))

def fix_ownership(path):
    """Change the owner of the file to SUDO_UID, if required"""


            

Reported by Bandit.

Starting a process with a shell, possible injection detected, security issue.
Security injection

Line: 354
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b605_start_process_with_a_shell.html

                      for index in range(0, current_max_cpu + 1):
            if cpu_mask[int(index)] != 0:
                os.system('grep -m 1 common_cpu cpu.csv > cpu{:0>3}.csv'.format(index))
                os.system('grep CPU_{:0>3} cpu.csv >> cpu{:0>3}.csv'.format(index, index))

def fix_ownership(path):
    """Change the owner of the file to SUDO_UID, if required"""

    uid = os.environ.get('SUDO_UID')

            

Reported by Bandit.

Unable to import 'Gnuplot'
Error

Line: 35 Column: 1

              import signal
import sys
import getopt
import Gnuplot
from numpy import *
from decimal import *

__author__ = "Srinivas Pandruvada"
__copyright__ = " Copyright (c) 2017, Intel Corporation. "

            

Reported by Pylint.

Unused import normalize_axis_tuple from wildcard import
Error

Line: 36 Column: 1

              import sys
import getopt
import Gnuplot
from numpy import *
from decimal import *

__author__ = "Srinivas Pandruvada"
__copyright__ = " Copyright (c) 2017, Intel Corporation. "
__license__ = "GPL version 2"

            

Reported by Pylint.

Unused import positive from wildcard import
Error

Line: 36 Column: 1

              import sys
import getopt
import Gnuplot
from numpy import *
from decimal import *

__author__ = "Srinivas Pandruvada"
__copyright__ = " Copyright (c) 2017, Intel Corporation. "
__license__ = "GPL version 2"

            

Reported by Pylint.

Unused import rad2deg from wildcard import
Error

Line: 36 Column: 1

              import sys
import getopt
import Gnuplot
from numpy import *
from decimal import *

__author__ = "Srinivas Pandruvada"
__copyright__ = " Copyright (c) 2017, Intel Corporation. "
__license__ = "GPL version 2"

            

Reported by Pylint.

Unused import reciprocal from wildcard import
Error

Line: 36 Column: 1

              import sys
import getopt
import Gnuplot
from numpy import *
from decimal import *

__author__ = "Srinivas Pandruvada"
__copyright__ = " Copyright (c) 2017, Intel Corporation. "
__license__ = "GPL version 2"

            

Reported by Pylint.

Unused import rint from wildcard import
Error

Line: 36 Column: 1

              import sys
import getopt
import Gnuplot
from numpy import *
from decimal import *

__author__ = "Srinivas Pandruvada"
__copyright__ = " Copyright (c) 2017, Intel Corporation. "
__license__ = "GPL version 2"

            

Reported by Pylint.

Unused import sign from wildcard import
Error

Line: 36 Column: 1

              import sys
import getopt
import Gnuplot
from numpy import *
from decimal import *

__author__ = "Srinivas Pandruvada"
__copyright__ = " Copyright (c) 2017, Intel Corporation. "
__license__ = "GPL version 2"

            

Reported by Pylint.

Unused import signbit from wildcard import
Error

Line: 36 Column: 1

              import sys
import getopt
import Gnuplot
from numpy import *
from decimal import *

__author__ = "Srinivas Pandruvada"
__copyright__ = " Copyright (c) 2017, Intel Corporation. "
__license__ = "GPL version 2"

            

Reported by Pylint.

tools/perf/scripts/python/export-to-postgresql.py
558 issues
Unable to import 'PySide2.QtSql'
Error

Line: 218 Column: 3

              pyside_version_1 = True
if not "pyside-version-1" in sys.argv:
	try:
		from PySide2.QtSql import *
		pyside_version_1 = False
	except:
		pass

if pyside_version_1:

            

Reported by Pylint.

Unable to import 'PySide.QtSql'
Error

Line: 224 Column: 2

              		pass

if pyside_version_1:
	from PySide.QtSql import *

if sys.version_info < (3, 0):
	def toserverstr(str):
		return str
	def toclientstr(str):

            

Reported by Pylint.

Undefined variable 'QSqlDatabase'
Error

Line: 322 Column: 6

              
printdate("Creating database...")

db = QSqlDatabase.addDatabase('QPSQL')
query = QSqlQuery(db)
db.setDatabaseName('postgres')
db.open()
try:
	do_query(query, 'CREATE DATABASE ' + dbname)

            

Reported by Pylint.

Undefined variable 'QSqlQuery'
Error

Line: 323 Column: 9

              printdate("Creating database...")

db = QSqlDatabase.addDatabase('QPSQL')
query = QSqlQuery(db)
db.setDatabaseName('postgres')
db.open()
try:
	do_query(query, 'CREATE DATABASE ' + dbname)
except:

            

Reported by Pylint.

Undefined variable 'QSqlQuery'
Error

Line: 338 Column: 9

              db.setDatabaseName(dbname)
db.open()

query = QSqlQuery(db)
do_query(query, 'SET client_min_messages TO WARNING')

do_query(query, 'CREATE TABLE selected_events ('
		'id		bigint		NOT NULL,'
		'name		varchar(80))')

            

Reported by Pylint.

Wildcard import PySide2.QtSql
Error

Line: 218 Column: 3

              pyside_version_1 = True
if not "pyside-version-1" in sys.argv:
	try:
		from PySide2.QtSql import *
		pyside_version_1 = False
	except:
		pass

if pyside_version_1:

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 220 Column: 2

              	try:
		from PySide2.QtSql import *
		pyside_version_1 = False
	except:
		pass

if pyside_version_1:
	from PySide.QtSql import *


            

Reported by Pylint.

Wildcard import PySide.QtSql
Error

Line: 224 Column: 2

              		pass

if pyside_version_1:
	from PySide.QtSql import *

if sys.version_info < (3, 0):
	def toserverstr(str):
		return str
	def toclientstr(str):

            

Reported by Pylint.

Redefining built-in 'str'
Error

Line: 227 Column: 18

              	from PySide.QtSql import *

if sys.version_info < (3, 0):
	def toserverstr(str):
		return str
	def toclientstr(str):
		return str
else:
	# Assume UTF-8 server_encoding and client_encoding

            

Reported by Pylint.

Redefining built-in 'str'
Error

Line: 229 Column: 18

              if sys.version_info < (3, 0):
	def toserverstr(str):
		return str
	def toclientstr(str):
		return str
else:
	# Assume UTF-8 server_encoding and client_encoding
	def toserverstr(str):
		return bytes(str, "UTF_8")

            

Reported by Pylint.

tools/perf/scripts/python/sched-migration.py
520 issues
Unable to import 'perf_trace_context'
Error

Line: 26 Column: 1

              	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
sys.path.append('scripts/python/Perf-Trace-Util/lib/Perf/Trace')

from perf_trace_context import *
from Core import *
from SchedGui import *


threads = { 0 : "idle"}

            

Reported by Pylint.

Unable to import 'Core'
Error

Line: 27 Column: 1

              sys.path.append('scripts/python/Perf-Trace-Util/lib/Perf/Trace')

from perf_trace_context import *
from Core import *
from SchedGui import *


threads = { 0 : "idle"}


            

Reported by Pylint.

Unable to import 'SchedGui'
Error

Line: 28 Column: 1

              
from perf_trace_context import *
from Core import *
from SchedGui import *


threads = { 0 : "idle"}

def thread_name(pid):

            

Reported by Pylint.

Undefined variable 'taskState'
Error

Line: 107 Column: 6

              	def sched_switch(self, prev, prev_state, next):
		event = RunqueueEventUnknown()

		if taskState(prev_state) == "R" and next in self.tasks \
			and prev in self.tasks:
			return self

		if taskState(prev_state) != "R":
			event = RunqueueEventSleep(prev)

            

Reported by Pylint.

Undefined variable 'taskState'
Error

Line: 111 Column: 6

              			and prev in self.tasks:
			return self

		if taskState(prev_state) != "R":
			event = RunqueueEventSleep(prev)

		next_tasks = list(self.tasks[:])
		if prev in self.tasks:
			if taskState(prev_state) != "R":

            

Reported by Pylint.

Undefined variable 'taskState'
Error

Line: 116 Column: 7

              
		next_tasks = list(self.tasks[:])
		if prev in self.tasks:
			if taskState(prev_state) != "R":
				next_tasks.remove(prev)
		elif taskState(prev_state) == "R":
			next_tasks.append(prev)

		if next not in next_tasks:

            

Reported by Pylint.

Undefined variable 'taskState'
Error

Line: 118 Column: 8

              		if prev in self.tasks:
			if taskState(prev_state) != "R":
				next_tasks.remove(prev)
		elif taskState(prev_state) == "R":
			next_tasks.append(prev)

		if next not in next_tasks:
			next_tasks.append(next)


            

Reported by Pylint.

Instance of 'RunqueueSnapshot' has no 'origin_tostring' member
Error

Line: 157 Column: 10

              
	def __repr__(self):
		ret = self.tasks.__repr__()
		ret += self.origin_tostring()

		return ret

class TimeSlice:
	def __init__(self, start, prev):

            

Reported by Pylint.

Undefined variable 'wx'
Error

Line: 367 Column: 8

              	parser = SchedEventProxy()

def trace_end():
	app = wx.App(False)
	timeslices = parser.timeslices
	frame = RootFrame(timeslices, "Migration")
	app.MainLoop()

def sched__sched_stat_runtime(event_name, context, common_cpu,

            

Reported by Pylint.

Undefined variable 'RootFrame'
Error

Line: 369 Column: 10

              def trace_end():
	app = wx.App(False)
	timeslices = parser.timeslices
	frame = RootFrame(timeslices, "Migration")
	app.MainLoop()

def sched__sched_stat_runtime(event_name, context, common_cpu,
	common_secs, common_nsecs, common_pid, common_comm,
	common_callchain, comm, pid, runtime, vruntime):

            

Reported by Pylint.

tools/perf/scripts/python/netdev-times.py
474 issues
Unable to import 'perf_trace_context'
Error

Line: 19 Column: 1

              sys.path.append(os.environ['PERF_EXEC_PATH'] + \
	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')

from perf_trace_context import *
from Core import *
from Util import *
from functools import cmp_to_key

all_event_list = []; # insert all tracepoint event related with this script

            

Reported by Pylint.

Unable to import 'Core'
Error

Line: 20 Column: 1

              	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')

from perf_trace_context import *
from Core import *
from Util import *
from functools import cmp_to_key

all_event_list = []; # insert all tracepoint event related with this script
irq_dic = {}; # key is cpu and value is a list which stacks irqs

            

Reported by Pylint.

Unable to import 'Util'
Error

Line: 21 Column: 1

              
from perf_trace_context import *
from Core import *
from Util import *
from functools import cmp_to_key

all_event_list = []; # insert all tracepoint event related with this script
irq_dic = {}; # key is cpu and value is a list which stacks irqs
              # which raise NET_RX softirq

            

Reported by Pylint.

Undefined variable 'nsecs_secs'
Error

Line: 69 Column: 3

              		return
	print("%7s %5d %6d.%06dsec %12.3fmsec      %12.3fmsec" %
		(hunk['dev'], hunk['len'],
		nsecs_secs(hunk['queue_t']),
		nsecs_nsecs(hunk['queue_t'])/1000,
		diff_msec(hunk['queue_t'], hunk['xmit_t']),
		diff_msec(hunk['xmit_t'], hunk['free_t'])))

# Format for displaying rx packet processing

            

Reported by Pylint.

Undefined variable 'nsecs_nsecs'
Error

Line: 70 Column: 3

              	print("%7s %5d %6d.%06dsec %12.3fmsec      %12.3fmsec" %
		(hunk['dev'], hunk['len'],
		nsecs_secs(hunk['queue_t']),
		nsecs_nsecs(hunk['queue_t'])/1000,
		diff_msec(hunk['queue_t'], hunk['xmit_t']),
		diff_msec(hunk['xmit_t'], hunk['free_t'])))

# Format for displaying rx packet processing
PF_IRQ_ENTRY= "  irq_entry(+%.3fmsec irq=%d:%s)"

            

Reported by Pylint.

Undefined variable 'nsecs_nsecs'
Error

Line: 105 Column: 24

              		return

	print("%d.%06dsec cpu=%d" %
		(nsecs_secs(base_t), nsecs_nsecs(base_t)/1000, cpu))
	for i in range(len(irq_list)):
		print(PF_IRQ_ENTRY %
			(diff_msec(base_t, irq_list[i]['irq_ent_t']),
			irq_list[i]['irq'], irq_list[i]['name']))
		print(PF_JOINT)

            

Reported by Pylint.

Undefined variable 'nsecs_secs'
Error

Line: 105 Column: 4

              		return

	print("%d.%06dsec cpu=%d" %
		(nsecs_secs(base_t), nsecs_nsecs(base_t)/1000, cpu))
	for i in range(len(irq_list)):
		print(PF_IRQ_ENTRY %
			(diff_msec(base_t, irq_list[i]['irq_ent_t']),
			irq_list[i]['irq'], irq_list[i]['name']))
		print(PF_JOINT)

            

Reported by Pylint.

Undefined variable 'symbol_str'
Error

Line: 233 Column: 5

              
# called from perf, when it finds a correspoinding event
def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
	if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
		return
	event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
	all_event_list.append(event_info)

def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, callchain, vec):

            

Reported by Pylint.

Undefined variable 'nsecs'
Error

Line: 235 Column: 36

              def irq__softirq_entry(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
	if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
		return
	event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
	all_event_list.append(event_info)

def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
	if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
		return

            

Reported by Pylint.

Undefined variable 'symbol_str'
Error

Line: 239 Column: 5

              	all_event_list.append(event_info)

def irq__softirq_exit(name, context, cpu, sec, nsec, pid, comm, callchain, vec):
	if symbol_str("irq__softirq_entry", "vec", vec) != "NET_RX":
		return
	event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, vec)
	all_event_list.append(event_info)

def irq__softirq_raise(name, context, cpu, sec, nsec, pid, comm, callchain, vec):

            

Reported by Pylint.

tools/testing/kunit/kunit_tool_test.py
366 issues
Using the global statement
Error

Line: 29 Column: 2

              abs_test_data_dir = ''

def setUpModule():
	global test_tmpdir, abs_test_data_dir
	test_tmpdir = tempfile.mkdtemp()
	abs_test_data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'test_data'))

def tearDownModule():
	shutil.rmtree(test_tmpdir)

            

Reported by Pylint.

Unused variable 'result'
Error

Line: 184 Column: 4

              		crash_log = test_data_path('test_insufficient_memory.log')
		print_mock = mock.patch('builtins.print').start()
		with open(crash_log) as file:
			result = kunit_parser.parse_run_tests(
				kunit_parser.extract_tap_lines(file.readlines()))
		print_mock.assert_any_call(StrContains('could not parse test results!'))
		print_mock.stop()
		file.close()


            

Reported by Pylint.

Unused variable 'tree'
Error

Line: 286 Column: 4

              
	def test_valid_kunitconfig(self):
		with tempfile.NamedTemporaryFile('wt') as kunitconfig:
			tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=kunitconfig.name)

	def test_dir_kunitconfig(self):
		with tempfile.TemporaryDirectory('') as dir:
			with open(os.path.join(dir, '.kunitconfig'), 'w') as f:
				pass

            

Reported by Pylint.

Redefining built-in 'dir'
Error

Line: 289 Column: 43

              			tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=kunitconfig.name)

	def test_dir_kunitconfig(self):
		with tempfile.TemporaryDirectory('') as dir:
			with open(os.path.join(dir, '.kunitconfig'), 'w') as f:
				pass
			tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=dir)

	# TODO: add more test cases.

            

Reported by Pylint.

Unused variable 'f'
Error

Line: 290 Column: 57

              
	def test_dir_kunitconfig(self):
		with tempfile.TemporaryDirectory('') as dir:
			with open(os.path.join(dir, '.kunitconfig'), 'w') as f:
				pass
			tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=dir)

	# TODO: add more test cases.


            

Reported by Pylint.

Unused variable 'tree'
Error

Line: 292 Column: 4

              		with tempfile.TemporaryDirectory('') as dir:
			with open(os.path.join(dir, '.kunitconfig'), 'w') as f:
				pass
			tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=dir)

	# TODO: add more test cases.


class KUnitJsonTest(unittest.TestCase):

            

Reported by Pylint.

TODO: add more test cases.
Error

Line: 294 Column: 3

              				pass
			tree = kunit_kernel.LinuxSourceTree('', kunitconfig_path=dir)

	# TODO: add more test cases.


class KUnitJsonTest(unittest.TestCase):

	def _json_for(self, log_file):

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
#
# A collection of tests for tools/testing/kunit/kunit.py
#
# Copyright (C) 2019, Google LLC.
# Author: Brendan Higgins <brendanhiggins@google.com>

import unittest

            

Reported by Pylint.

Multiple imports on one line (tempfile, shutil)
Error

Line: 12 Column: 1

              import unittest
from unittest import mock

import tempfile, shutil # Handling test_tmpdir

import itertools
import json
import signal
import os

            

Reported by Pylint.

Constant name "test_tmpdir" doesn't conform to UPPER_CASE naming style
Error

Line: 25 Column: 1

              import kunit_json
import kunit

test_tmpdir = ''
abs_test_data_dir = ''

def setUpModule():
	global test_tmpdir, abs_test_data_dir
	test_tmpdir = tempfile.mkdtemp()

            

Reported by Pylint.

tools/perf/scripts/python/compaction-times.py
357 issues
Using variable 'opt_disp' before assignment
Error

Line: 46 Column: 19

              
def set_type(t):
	global opt_disp
	opt_disp = (t if opt_disp == topt.DISP_ALL else opt_disp|t)

def ns(sec, nsec):
	return (sec * 1000000000) + nsec

def time(ns):

            

Reported by Pylint.

Instance of 'chead' has no 'ns' member
Error

Line: 168 Column: 3

              		self.list = []

	def __add__(self, rhs):
		self.ns += rhs.ns
		self.val += rhs.val
		return self

	def mark_pending(self, secs, nsecs):
		self.pending = cnode(ns(secs, nsecs))

            

Reported by Pylint.

Unused import os
Error

Line: 7 Column: 1

              # testing:
# 'echo 1 > /proc/sys/vm/compact_memory' to force compaction of all zones

import os
import sys
import re

import signal
signal.signal(signal.SIGPIPE, signal.SIG_DFL)

            

Reported by Pylint.

Redefining name 're' from outer scope (line 9)
Error

Line: 29 Column: 21

              	DISP_ALL = 7

class comm_filter:
	def __init__(self, re):
		self.re = re

	def filter(self, pid, comm):
		m = self.re.search(comm)
		return m == None or m.group() == ""

            

Reported by Pylint.

Unused argument 'pid'
Error

Line: 32 Column: 19

              	def __init__(self, re):
		self.re = re

	def filter(self, pid, comm):
		m = self.re.search(comm)
		return m == None or m.group() == ""

class pid_filter:
	def __init__(self, low, high):

            

Reported by Pylint.

Redefining name 'm' from outer scope (line 297)
Error

Line: 33 Column: 3

              		self.re = re

	def filter(self, pid, comm):
		m = self.re.search(comm)
		return m == None or m.group() == ""

class pid_filter:
	def __init__(self, low, high):
		self.low = (0 if low == "" else int(low))

            

Reported by Pylint.

Unused argument 'comm'
Error

Line: 41 Column: 24

              		self.low = (0 if low == "" else int(low))
		self.high = (0 if high == "" else int(high))

	def filter(self, pid, comm):
		return not (pid >= self.low and (self.high == 0 or pid <= self.high))

def set_type(t):
	global opt_disp
	opt_disp = (t if opt_disp == topt.DISP_ALL else opt_disp|t)

            

Reported by Pylint.

Using the global statement
Error

Line: 45 Column: 2

              		return not (pid >= self.low and (self.high == 0 or pid <= self.high))

def set_type(t):
	global opt_disp
	opt_disp = (t if opt_disp == topt.DISP_ALL else opt_disp|t)

def ns(sec, nsec):
	return (sec * 1000000000) + nsec


            

Reported by Pylint.

Redefining name 'ns' from outer scope (line 48)
Error

Line: 51 Column: 10

              def ns(sec, nsec):
	return (sec * 1000000000) + nsec

def time(ns):
	return "%dns" % ns if opt_ns else "%dus" % (round(ns, -3) / 1000)

class pair:
	def __init__(self, aval, bval, alabel = None, blabel = None):
		self.alabel = alabel

            

Reported by Pylint.

Redefining name 'ns' from outer scope (line 48)
Error

Line: 70 Column: 21

              		return "%s=%d %s=%d" % (self.alabel, self.aval, self.blabel, self.bval)

class cnode:
	def __init__(self, ns):
		self.ns = ns
		self.migrated = pair(0, 0, "moved", "failed")
		self.fscan = pair(0,0, "scanned", "isolated")
		self.mscan = pair(0,0, "scanned", "isolated")


            

Reported by Pylint.

tools/testing/kunit/kunit_parser.py
350 issues
Missing module docstring
Error

Line: 1 Column: 1

              # SPDX-License-Identifier: GPL-2.0
#
# Parses test results from a kernel dmesg log.
#
# Copyright (C) 2019, Google LLC.
# Author: Felix Guo <felixguoxiuping@gmail.com>
# Author: Brendan Higgins <brendanhiggins@google.com>

import re

            

Reported by Pylint.

Missing class docstring
Error

Line: 19 Column: 1

              
TestResult = namedtuple('TestResult', ['status','suites','log'])

class TestSuite(object):
	def __init__(self) -> None:
		self.status = TestStatus.SUCCESS
		self.name = ''
		self.cases = []  # type: List[TestCase]


            

Reported by Pylint.

Class 'TestSuite' inherits from object, can be safely removed from bases in python3
Error

Line: 19 Column: 1

              
TestResult = namedtuple('TestResult', ['status','suites','log'])

class TestSuite(object):
	def __init__(self) -> None:
		self.status = TestStatus.SUCCESS
		self.name = ''
		self.cases = []  # type: List[TestCase]


            

Reported by Pylint.

Bad indentation. Found 1 spaces, expected 4
Style

Line: 20 Column: 1

              TestResult = namedtuple('TestResult', ['status','suites','log'])

class TestSuite(object):
	def __init__(self) -> None:
		self.status = TestStatus.SUCCESS
		self.name = ''
		self.cases = []  # type: List[TestCase]

	def __str__(self) -> str:

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 8
Style

Line: 21 Column: 1

              
class TestSuite(object):
	def __init__(self) -> None:
		self.status = TestStatus.SUCCESS
		self.name = ''
		self.cases = []  # type: List[TestCase]

	def __str__(self) -> str:
		return 'TestSuite(' + str(self.status) + ',' + self.name + ',' + str(self.cases) + ')'

            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 8
Style

Line: 22 Column: 1

              class TestSuite(object):
	def __init__(self) -> None:
		self.status = TestStatus.SUCCESS
		self.name = ''
		self.cases = []  # type: List[TestCase]

	def __str__(self) -> str:
		return 'TestSuite(' + str(self.status) + ',' + self.name + ',' + str(self.cases) + ')'


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 8
Style

Line: 23 Column: 1

              	def __init__(self) -> None:
		self.status = TestStatus.SUCCESS
		self.name = ''
		self.cases = []  # type: List[TestCase]

	def __str__(self) -> str:
		return 'TestSuite(' + str(self.status) + ',' + self.name + ',' + str(self.cases) + ')'

	def __repr__(self) -> str:

            

Reported by Pylint.

Bad indentation. Found 1 spaces, expected 4
Style

Line: 25 Column: 1

              		self.name = ''
		self.cases = []  # type: List[TestCase]

	def __str__(self) -> str:
		return 'TestSuite(' + str(self.status) + ',' + self.name + ',' + str(self.cases) + ')'

	def __repr__(self) -> str:
		return str(self)


            

Reported by Pylint.

Bad indentation. Found 2 spaces, expected 8
Style

Line: 26 Column: 1

              		self.cases = []  # type: List[TestCase]

	def __str__(self) -> str:
		return 'TestSuite(' + str(self.status) + ',' + self.name + ',' + str(self.cases) + ')'

	def __repr__(self) -> str:
		return str(self)

class TestCase(object):

            

Reported by Pylint.

Bad indentation. Found 1 spaces, expected 4
Style

Line: 28 Column: 1

              	def __str__(self) -> str:
		return 'TestSuite(' + str(self.status) + ',' + self.name + ',' + str(self.cases) + ')'

	def __repr__(self) -> str:
		return str(self)

class TestCase(object):
	def __init__(self) -> None:
		self.status = TestStatus.SUCCESS

            

Reported by Pylint.