-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing Linter errors: undefined-variables<E0602>. #1999
Changes from all commits
013a365
e67ff5f
e9a3ab8
fce88f1
9346212
118034b
7e7ed0b
40fd349
703d1ba
8672bce
6a20713
bd69ad0
7f0707c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,16 +25,38 @@ | |
|
||
bytebuffer = memoryview # pylint: disable=C0103 | ||
|
||
# We aren't using these imports in this file, but we want them to be available | ||
# to import from this module in others. | ||
# Additionally, python2 doesn't have this, so we need to disable import-error | ||
# as well. | ||
from builtins import int, range # pylint: disable=unused-import,import-error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wont this throw if py2 doesnt have these? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just off screen in the GitHub view, but we're in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh got it! Thanks! |
||
|
||
from collections import OrderedDict # pylint: disable=W0611 | ||
|
||
elif sys.version_info[0] == 2: | ||
import httplib as httpclient # pylint: disable=E0401,W0611 | ||
from urlparse import urlparse # pylint: disable=E0401 | ||
|
||
"""Rename Python2 unicode to ustr""" # pylint: disable=W0105 | ||
ustr = unicode # pylint: disable=E0602,invalid-name | ||
|
||
bytebuffer = buffer # pylint: disable=E0602,invalid-name | ||
|
||
# We want to suppress the following: | ||
# - undefined-variable<E0602>: | ||
# These builtins are not defined in python3 | ||
# - invalid-name<C0103>: | ||
# The defined variables are constants, but don't use UPPER_SNAKE_CASE | ||
# as we're redefining some builtins that also do not use that format. | ||
# - redefined-builtin<W0622>: | ||
# This is intentional, so that code that wants to use builtins we're | ||
# assigning new names to doesn't need to check python versions before | ||
# doing so. | ||
|
||
# pylint: disable=undefined-variable,invalid-name,redefined-builtin | ||
|
||
ustr = unicode # Rename Python2 unicode to ustr | ||
bytebuffer = buffer | ||
range = xrange | ||
int = long | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these all for Py2? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's right. |
||
|
||
# pylint: enable=undefined-variable,invalid-name,redefined-builtin | ||
|
||
if sys.version_info[1] >= 7: | ||
from collections import OrderedDict # For Py 2.7+ # pylint: disable=C0412 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,13 @@ | |
# Requires Python 2.6+ and Openssl 1.0+ | ||
# | ||
|
||
import os | ||
|
||
import azurelinuxagent.common.logger as logger | ||
import azurelinuxagent.common.utils.shellutil as shellutil | ||
from azurelinuxagent.common.future import ustr | ||
from azurelinuxagent.common.osutil.default import DefaultOSUtil | ||
from azurelinuxagent.common.osutil.redhat import Redhat6xOSUtil # pylint: disable=W0611 | ||
from azurelinuxagent.common.utils import textutil # pylint: disable=W0611 | ||
from azurelinuxagent.common.osutil.default import DefaultOSUtil, PRODUCT_ID_FILE, DMIDECODE_CMD, UUID_PATTERN | ||
from azurelinuxagent.common.utils import textutil, fileutil # pylint: disable=W0611 | ||
|
||
# pylint: disable=W0105 | ||
''' | ||
|
@@ -58,7 +59,7 @@ def publish_hostname(self, hostname): | |
Restart NetworkManager first before publishing hostname | ||
""" | ||
shellutil.run("service NetworkManager restart") | ||
super(RedhatOSUtil, self).publish_hostname(hostname) # pylint: disable=E0602 | ||
super(IosxeOSUtil, self).publish_hostname(hostname) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like it was copy-pasted from Redhat. Anyone know if this is the case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure, most of these distro-specific modules that are not endorsed came from external contributors. |
||
|
||
def register_agent_service(self): | ||
return shellutil.run("systemctl enable waagent", chk_err=False) | ||
|
@@ -79,13 +80,13 @@ def get_instance_id(self): | |
If that is missing, then extracts from dmidecode | ||
If nothing works (for old VMs), return the empty string | ||
''' | ||
if os.path.isfile(PRODUCT_ID_FILE): # pylint: disable=E0602 | ||
if os.path.isfile(PRODUCT_ID_FILE): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol whoever wrote the code (and reviewed it) didnt do a good job :p |
||
try: | ||
s = fileutil.read_file(PRODUCT_ID_FILE).strip() # pylint: disable=E0602,C0103 | ||
s = fileutil.read_file(PRODUCT_ID_FILE).strip() # pylint: disable=C0103 | ||
return self._correct_instance_id(s.strip()) | ||
except IOError: | ||
pass | ||
rc, s = shellutil.run_get_output(DMIDECODE_CMD) # pylint: disable=E0602,C0103 | ||
if rc != 0 or UUID_PATTERN.match(s) is None: # pylint: disable=E0602 | ||
rc, s = shellutil.run_get_output(DMIDECODE_CMD) # pylint: disable=C0103 | ||
if rc != 0 or UUID_PATTERN.match(s) is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, this time with |
||
return "" | ||
return self._correct_instance_id(s.strip()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,7 +126,7 @@ def restart_ssh_service(self): # pylint: disable=R1710 | |
if os.path.exists("/etc/init.d/sshd"): # pylint: disable=R1705 | ||
return shellutil.run("/etc/init.d/sshd restart", chk_err=True) | ||
else: | ||
logger.warn("sshd service does not exists", username) # pylint: disable=E0602 | ||
logger.warn("sshd service does not exists") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like this was just copy-pasted from a method with |
||
|
||
def stop_agent_service(self): | ||
return shellutil.run("/etc/init.d/{0} stop".format(self.service_name), chk_err=True) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning these up!