Skip to content

Commit

Permalink
Enabled linter on loose files in common. (#1976)
Browse files Browse the repository at this point in the history
* Enabled linter on loose files in common.

* Fixed removed comment from merge issue.

* Removed ignore, allowing all files in common to be linted.

Co-authored-by: keclar <keclar@microsoft.com>
  • Loading branch information
kevinclark19a and keclar authored Aug 20, 2020
1 parent c73a8d9 commit a6b00c9
Show file tree
Hide file tree
Showing 53 changed files with 879 additions and 840 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ matrix:
- >-
NOSEOPTS="--verbose --with-timer" SETUPOPTS=""
PYLINTOPTS="--rcfile=2.7.pylintrc"
PYLINTFILES="azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
- python: 3.4
env:
- >-
NOSEOPTS="--verbose --with-timer" SETUPOPTS=""
PYLINTOPTS="--rcfile=2.7.pylintrc"
PYLINTFILES="azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
- python: 3.6
env:
- >-
NOSEOPTS="--verbose --with-timer" SETUPOPTS=""
PYLINTOPTS="--rcfile=3.6.pylintrc"
PYLINTFILES="azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
- python: 3.7
env:
- >-
NOSEOPTS="--verbose --with-timer" SETUPOPTS=""
PYLINTOPTS="--rcfile=3.6.pylintrc"
PYLINTFILES="azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
- python: 3.8
env:
- >-
Expand All @@ -50,7 +50,7 @@ matrix:
--cover-package=azurelinuxagent --cover-xml"
SETUPOPTS=""
PYLINTOPTS="--rcfile=3.6.pylintrc"
PYLINTFILES="azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
install:
- pip install -r requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion azurelinuxagent/common/AgentGlobals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Microsoft Azure Linux Agent
# Microsoft Azure Linux Agent # pylint: disable=C0103
#
# Copyright 2020 Microsoft Corporation
#
Expand Down
34 changes: 17 additions & 17 deletions azurelinuxagent/common/cgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@
MetricValue = namedtuple('Metric', ['category', 'counter', 'instance', 'value'])


class MetricsCategory(object):
class MetricsCategory(object): # pylint: disable=R0903
MEMORY_CATEGORY = "Memory"
CPU_CATEGORY = "CPU"


class MetricsCounter(object):
class MetricsCounter(object): # pylint: disable=R0903
PROCESSOR_PERCENT_TIME = "% Processor Time"
TOTAL_MEM_USAGE = "Total Memory Usage"
MAX_MEM_USAGE = "Max Memory Usage"


re_user_system_times = re.compile(r'user (\d+)\nsystem (\d+)\n')
re_user_system_times = re.compile(r'user (\d+)\nsystem (\d+)\n') # pylint: disable=invalid-name


class CGroupContollers(object):
class CGroupContollers(object): # pylint: disable=R0903
CPU = "cpu"
MEMORY = "memory"

Expand Down Expand Up @@ -105,8 +105,8 @@ def _get_parameters(self, parameter_name, first_line_only=False):
parameter_filename = self._get_cgroup_file(parameter_name)
logger.error("File {0} is empty but should not be".format(parameter_filename))
raise CGroupsException("File {0} is empty but should not be".format(parameter_filename))
except Exception as e:
if isinstance(e, (IOError, OSError)) and e.errno == errno.ENOENT:
except Exception as e: # pylint: disable=C0103
if isinstance(e, (IOError, OSError)) and e.errno == errno.ENOENT: # pylint: disable=E1101
raise e
parameter_filename = self._get_cgroup_file(parameter_name)
raise CGroupsException("Exception while attempting to read {0}".format(parameter_filename), e)
Expand All @@ -116,16 +116,16 @@ def is_active(self):
try:
tasks = self._get_parameters("tasks")
if tasks:
return len(tasks) != 0
except (IOError, OSError) as e:
return len(tasks) != 0 # pylint: disable=len-as-condition
except (IOError, OSError) as e: # pylint: disable=C0103
if e.errno == errno.ENOENT:
# only suppressing file not found exceptions.
pass
else:
logger.periodic_warn(logger.EVERY_HALF_HOUR,
'Could not get list of tasks from "tasks" file in the cgroup: {0}.'
' Internal error: {1}'.format(self.path, ustr(e)))
except CGroupsException as e:
except CGroupsException as e: # pylint: disable=C0103
logger.periodic_warn(logger.EVERY_HALF_HOUR,
'Could not get list of tasks from "tasks" file in the cgroup: {0}.'
' Internal error: {1}'.format(self.path, ustr(e)))
Expand All @@ -138,15 +138,15 @@ def get_tracked_processes(self):
procs = []
try:
procs = self._get_parameters("cgroup.procs")
except (IOError, OSError) as e:
except (IOError, OSError) as e: # pylint: disable=C0103
if e.errno == errno.ENOENT:
# only suppressing file not found exceptions.
pass
else:
logger.periodic_warn(logger.EVERY_HALF_HOUR,
'Could not get list of procs from "cgroup.procs" file in the cgroup: {0}.'
' Internal error: {1}'.format(self.path, ustr(e)))
except CGroupsException as e:
except CGroupsException as e: # pylint: disable=C0103
logger.periodic_warn(logger.EVERY_HALF_HOUR,
'Could not get list of tasks from "cgroup.procs" file in the cgroup: {0}.'
' Internal error: {1}'.format(self.path, ustr(e)))
Expand Down Expand Up @@ -183,8 +183,8 @@ def _get_cpu_ticks(self, allow_no_such_file_or_directory_error=False):
"""
try:
cpu_stat = self._get_file_contents('cpuacct.stat')
except Exception as e:
if not isinstance(e, (IOError, OSError)) or e.errno != errno.ENOENT:
except Exception as e: # pylint: disable=C0103
if not isinstance(e, (IOError, OSError)) or e.errno != errno.ENOENT: # pylint: disable=E1101
raise CGroupsException("Failed to read cpuacct.stat: {0}".format(ustr(e)))
if not allow_no_such_file_or_directory_error:
raise e
Expand Down Expand Up @@ -264,8 +264,8 @@ def get_memory_usage(self):
usage = None
try:
usage = self._get_parameters('memory.usage_in_bytes', first_line_only=True)
except Exception as e:
if isinstance(e, (IOError, OSError)) and e.errno == errno.ENOENT:
except Exception as e: # pylint: disable=C0103
if isinstance(e, (IOError, OSError)) and e.errno == errno.ENOENT: # pylint: disable=E1101
raise
raise CGroupsException("Exception while attempting to read {0}".format("memory.usage_in_bytes"), e)

Expand All @@ -281,8 +281,8 @@ def get_max_memory_usage(self):
usage = None
try:
usage = self._get_parameters('memory.max_usage_in_bytes', first_line_only=True)
except Exception as e:
if isinstance(e, (IOError, OSError)) and e.errno == errno.ENOENT:
except Exception as e: # pylint: disable=C0103
if isinstance(e, (IOError, OSError)) and e.errno == errno.ENOENT: # pylint: disable=E1101
raise
raise CGroupsException("Exception while attempting to read {0}".format("memory.usage_in_bytes"), e)

Expand Down
Loading

0 comments on commit a6b00c9

Please sign in to comment.