debian/apport/source_grub2.py: Fix flake8 errors

This commit is contained in:
Colin Watson 2019-08-03 13:04:54 +01:00
parent e3c076c431
commit 598127c3f7
2 changed files with 9 additions and 4 deletions

View File

@ -23,6 +23,7 @@ from apport.hookutils import (
path_to_key, path_to_key,
) )
def check_shell_syntax(path): def check_shell_syntax(path):
''' Check the syntax of a shell script ''' ''' Check the syntax of a shell script '''
try: try:
@ -32,6 +33,7 @@ def check_shell_syntax(path):
return False return False
return True return True
def check_shell_syntax_harder(path): def check_shell_syntax_harder(path):
''' Check the syntax of a shell script ''' ''' Check the syntax of a shell script '''
try: try:
@ -61,7 +63,7 @@ def check_shell_syntax_harder(path):
def add_info(report): def add_info(report):
if report['ProblemType'] == 'Package': if report['ProblemType'] == 'Package':
# To detect if root fs is a loop device # To detect if root fs is a loop device
attach_file(report, '/proc/cmdline','ProcCmdLine') attach_file(report, '/proc/cmdline', 'ProcCmdLine')
attach_default_grub(report, 'EtcDefaultGrub') attach_default_grub(report, 'EtcDefaultGrub')
attach_file_if_exists(report, '/boot/grub/device.map', 'DeviceMap') attach_file_if_exists(report, '/boot/grub/device.map', 'DeviceMap')
try: try:
@ -80,9 +82,9 @@ def add_info(report):
# Check scripts in /etc/grub.d since some users directly change # Check scripts in /etc/grub.d since some users directly change
# configuration there # configuration there
grubdir='/etc/grub.d' grubdir = '/etc/grub.d'
for f in os.listdir(grubdir): for f in os.listdir(grubdir):
fullpath=os.path.join(grubdir, f) fullpath = os.path.join(grubdir, f)
if f != 'README' and os.access(fullpath, os.X_OK) \ if f != 'README' and os.access(fullpath, os.X_OK) \
and not check_shell_syntax(fullpath): and not check_shell_syntax(fullpath):
invalid_grub_script.append(fullpath) invalid_grub_script.append(fullpath)
@ -93,6 +95,7 @@ def add_info(report):
if invalid_grub_script: if invalid_grub_script:
report['InvalidGrubScript'] = ' '.join(invalid_grub_script) report['InvalidGrubScript'] = ' '.join(invalid_grub_script)
if __name__ == '__main__': if __name__ == '__main__':
r = {} r = {}
r['ProblemType'] = 'Package' r['ProblemType'] = 'Package'

4
debian/changelog vendored
View File

@ -6,7 +6,9 @@ grub2 (2.04-2) UNRELEASED; urgency=medium
[ Colin Watson ] [ Colin Watson ]
* Use debhelper-compat instead of debian/compat. * Use debhelper-compat instead of debian/compat.
* debian/apport/source_grub2.py: Avoid star import. * debian/apport/source_grub2.py:
- Avoid star import.
- Fix flake8 errors.
-- Colin Watson <cjwatson@debian.org> Tue, 09 Jul 2019 15:04:41 +0100 -- Colin Watson <cjwatson@debian.org> Tue, 09 Jul 2019 15:04:41 +0100