Merge pull request #116 from CanonicalLtd/run_flake8_via_python3
Run flake8 via python3
This commit is contained in:
commit
6caf75b990
8
Makefile
8
Makefile
|
@ -24,7 +24,7 @@ ifneq (,$(MACHINE))
|
||||||
MACHARGS=--machine=$(MACHINE)
|
MACHARGS=--machine=$(MACHINE)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: run clean
|
.PHONY: run clean check
|
||||||
|
|
||||||
all: dryrun
|
all: dryrun
|
||||||
|
|
||||||
|
@ -50,13 +50,15 @@ ui-view-serial:
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
echo "Running flake8 lint tests..."
|
echo "Running flake8 lint tests..."
|
||||||
flake8 bin/$(PYTHONSRC)-tui --ignore=F403
|
python3 /usr/bin/flake8 bin/$(PYTHONSRC)-tui --ignore=F403
|
||||||
flake8 --exclude $(PYTHONSRC)/tests/ $(PYTHONSRC) --ignore=F403
|
python3 /usr/bin/flake8 --exclude $(PYTHONSRC)/tests/ $(PYTHONSRC) --ignore=F403
|
||||||
|
|
||||||
unit:
|
unit:
|
||||||
echo "Running unit tests..."
|
echo "Running unit tests..."
|
||||||
nosetests3 $(PYTHONSRC)/tests
|
nosetests3 $(PYTHONSRC)/tests
|
||||||
|
|
||||||
|
check: lint unit
|
||||||
|
|
||||||
installer/$(INSTALLIMG): installer/geninstaller installer/runinstaller $(INSTALLER_RESOURCES) probert
|
installer/$(INSTALLIMG): installer/geninstaller installer/runinstaller $(INSTALLER_RESOURCES) probert
|
||||||
(cd installer && TOPDIR=$(TOPDIR)/installer ./geninstaller -v -r $(RELEASE) -a $(ARCH) -s $(STREAM) -b $(BOOTLOADER))
|
(cd installer && TOPDIR=$(TOPDIR)/installer ./geninstaller -v -r $(RELEASE) -a $(ARCH) -s $(STREAM) -b $(BOOTLOADER))
|
||||||
echo $(INSTALLER_RESOURCES)
|
echo $(INSTALLER_RESOURCES)
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from .welcome import WelcomeController
|
from .welcome import WelcomeController # NOQA
|
||||||
from .installpath import InstallpathController
|
from .installpath import InstallpathController # NOQA
|
||||||
from .network import NetworkController
|
from .network import NetworkController # NOQA
|
||||||
from .filesystem import FilesystemController
|
from .filesystem import FilesystemController # NOQA
|
||||||
from .installprogress import InstallProgressController
|
from .installprogress import InstallProgressController # NOQA
|
||||||
from .identity import IdentityController
|
from .identity import IdentityController # NOQA
|
||||||
|
|
|
@ -23,7 +23,6 @@ from subiquity.models.filesystem import (_humanize_size)
|
||||||
from subiquity.ui.views import (DiskPartitionView, AddPartitionView,
|
from subiquity.ui.views import (DiskPartitionView, AddPartitionView,
|
||||||
AddFormatView, FilesystemView,
|
AddFormatView, FilesystemView,
|
||||||
DiskInfoView, RaidView)
|
DiskInfoView, RaidView)
|
||||||
import subiquity.utils as utils
|
|
||||||
from subiquity.ui.dummy import DummyView
|
from subiquity.ui.dummy import DummyView
|
||||||
from subiquity.ui.error import ErrorView
|
from subiquity.ui.error import ErrorView
|
||||||
from subiquity.curtin import (curtin_write_storage_actions,
|
from subiquity.curtin import (curtin_write_storage_actions,
|
||||||
|
|
|
@ -26,6 +26,7 @@ from subiquity.curtin import curtin_write_network_actions
|
||||||
|
|
||||||
log = logging.getLogger("subiquity.controller.network")
|
log = logging.getLogger("subiquity.controller.network")
|
||||||
|
|
||||||
|
|
||||||
class NetworkController(ControllerPolicy):
|
class NetworkController(ControllerPolicy):
|
||||||
def __init__(self, common):
|
def __init__(self, common):
|
||||||
super().__init__(common)
|
super().__init__(common)
|
||||||
|
|
|
@ -62,15 +62,23 @@ network:
|
||||||
config:
|
config:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# TODO, this should be moved to the in-target cloud-config seed so on first boot
|
# TODO, this should be moved to the in-target cloud-config seed so on first
|
||||||
# of the target, it reconfigures datasource_list to none for subsequent boots
|
# boot of the target, it reconfigures datasource_list to none for subsequent
|
||||||
# 12_ds_to_none: [curtin, in-target, --, sh, '-c', "echo 'datasource_list: [ None ]' > /etc/cloud/cloud.cfg.d/
|
# boots.
|
||||||
POST_INSTALL = '''
|
# Reworked for flake8, but it does make it harder to read.
|
||||||
late_commands:
|
POST_INSTALL_LIST = [
|
||||||
10_mkdir_seed: curtin in-target -- mkdir -p /var/lib/cloud/seed/nocloud-net
|
("late_commands:"),
|
||||||
11_postinst_metadata: [curtin, in-target, --, sh, '-c',"/bin/echo -e instance-id: inst-3011 > /var/lib/cloud/seed/nocloud-net/meta-data"]
|
(" 10_mkdir_seed: curtin in-target -- "
|
||||||
12_postinst_userdata: [curtin, in-target, --, sh, '-c',"/bin/echo -e '#cloud-config\\npassword: passw0rd\\nchpasswd: {{ expire: False }}\\nusers:\\n{users}' > /var/lib/cloud/seed/nocloud-net/user-data"]
|
"mkdir -p /var/lib/cloud/seed/nocloud-net"),
|
||||||
'''
|
(" 11_postinst_metadata: [curtin, in-target, --, sh, '-c',"
|
||||||
|
'"/bin/echo -e instance-id: inst-3011 '
|
||||||
|
'> /var/lib/cloud/seed/nocloud-net/meta-data"]'),
|
||||||
|
(" 12_postinst_userdata: [curtin, in-target, --, sh, '-c',"
|
||||||
|
"\"/bin/echo -e '#cloud-config\\npassword: passw0rd\\nchpasswd: "
|
||||||
|
"{{ expire: False }}\\nusers:\\n{users}' > "
|
||||||
|
"/var/lib/cloud/seed/nocloud-net/user-data\"]"),
|
||||||
|
]
|
||||||
|
POST_INSTALL = '\n' + "\n".join(POST_INSTALL_LIST) + '\n'
|
||||||
|
|
||||||
|
|
||||||
def curtin_userinfo_to_config(userinfo):
|
def curtin_userinfo_to_config(userinfo):
|
||||||
|
|
|
@ -20,6 +20,7 @@ from logging.handlers import TimedRotatingFileHandler
|
||||||
LOGDIR = "logs"
|
LOGDIR = "logs"
|
||||||
LOGFILE = os.path.join(LOGDIR, "debug.log")
|
LOGFILE = os.path.join(LOGDIR, "debug.log")
|
||||||
|
|
||||||
|
|
||||||
def setup_logger(name=__name__):
|
def setup_logger(name=__name__):
|
||||||
if not os.path.isdir(LOGDIR):
|
if not os.path.isdir(LOGDIR):
|
||||||
os.makedirs(LOGDIR)
|
os.makedirs(LOGDIR)
|
||||||
|
|
|
@ -112,6 +112,7 @@ class DiskAction():
|
||||||
self._type = 'disk'
|
self._type = 'disk'
|
||||||
|
|
||||||
__hash__ = None
|
__hash__ = None
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, self.__class__):
|
if isinstance(other, self.__class__):
|
||||||
return (self._action_id == other._action_id and
|
return (self._action_id == other._action_id and
|
||||||
|
@ -170,6 +171,7 @@ class RaidAction(DiskAction):
|
||||||
self._type = 'raid'
|
self._type = 'raid'
|
||||||
|
|
||||||
__hash__ = None
|
__hash__ = None
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, self.__class__):
|
if isinstance(other, self.__class__):
|
||||||
return (self._action_id == other._action_id and
|
return (self._action_id == other._action_id and
|
||||||
|
@ -209,6 +211,7 @@ class PartitionAction(DiskAction):
|
||||||
self._action_id = 'bios_boot_partition'
|
self._action_id = 'bios_boot_partition'
|
||||||
|
|
||||||
__hash__ = None
|
__hash__ = None
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, self.__class__):
|
if isinstance(other, self.__class__):
|
||||||
return (self._action_id == other._action_id and
|
return (self._action_id == other._action_id and
|
||||||
|
@ -221,7 +224,6 @@ class PartitionAction(DiskAction):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self):
|
def path(self):
|
||||||
return "{}{}".format(self.parent.action_id, self.partnum)
|
return "{}{}".format(self.parent.action_id, self.partnum)
|
||||||
|
@ -279,6 +281,7 @@ class FormatAction(DiskAction):
|
||||||
self._action_id = self._action_id[:11]
|
self._action_id = self._action_id[:11]
|
||||||
|
|
||||||
__hash__ = None
|
__hash__ = None
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, self.__class__):
|
if isinstance(other, self.__class__):
|
||||||
return (self._action_id == other._action_id and
|
return (self._action_id == other._action_id and
|
||||||
|
@ -288,7 +291,6 @@ class FormatAction(DiskAction):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fstype(self):
|
def fstype(self):
|
||||||
return self._fstype
|
return self._fstype
|
||||||
|
@ -310,6 +312,7 @@ class MountAction(DiskAction):
|
||||||
self._type = 'mount'
|
self._type = 'mount'
|
||||||
|
|
||||||
__hash__ = None
|
__hash__ = None
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, self.__class__):
|
if isinstance(other, self.__class__):
|
||||||
return (self._action_id == other._action_id and
|
return (self._action_id == other._action_id and
|
||||||
|
|
|
@ -88,7 +88,9 @@ class Disk():
|
||||||
self._partitions == other._partitions)
|
self._partitions == other._partitions)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
__hash__ = None
|
|
||||||
|
__hash__ = None # declare we don't supply a hash
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return not self.__eq__(other)
|
return not self.__eq__(other)
|
||||||
|
|
||||||
|
@ -176,7 +178,8 @@ class Blockdev():
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
__hash__ = None
|
__hash__ = None # declare we don't supply a hash
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return not self.__eq__(other)
|
return not self.__eq__(other)
|
||||||
|
|
||||||
|
@ -269,10 +272,10 @@ class Blockdev():
|
||||||
defined but not mounted, not formatted, and not used in
|
defined but not mounted, not formatted, and not used in
|
||||||
raid, lvm, bcache'''
|
raid, lvm, bcache'''
|
||||||
return [part.devpath for (num, part) in self.partitions.items()
|
return [part.devpath for (num, part) in self.partitions.items()
|
||||||
if part.size > 0 and
|
if (part.size > 0 and
|
||||||
part.flags not in ['raid', 'lvm', 'bcache'] and
|
part.flags not in ['raid', 'lvm', 'bcache'] and
|
||||||
(part.devpath not in self._mounts.keys() and
|
(part.devpath not in self._mounts.keys() and
|
||||||
part.devpath not in self._filesystems.keys())]
|
part.devpath not in self._filesystems.keys()))]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mounted(self):
|
def mounted(self):
|
||||||
|
@ -402,13 +405,14 @@ class Blockdev():
|
||||||
|
|
||||||
def get_actions(self):
|
def get_actions(self):
|
||||||
if self.is_mounted():
|
if self.is_mounted():
|
||||||
log.debug(
|
log.debug('Emitting no actions, device '
|
||||||
'Emitting no actions, device ({}) is mounted'.format(self.devpath))
|
'({}) is mounted'.format(self.devpath))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
actions = []
|
actions = []
|
||||||
action = self.baseaction.get()
|
action = self.baseaction.get()
|
||||||
part_actions = [part.get() for (num, part) in self.disk.partitions.items()]
|
part_actions = [part.get() for (num, part) in
|
||||||
|
self.disk.partitions.items()]
|
||||||
fs_actions = [fs.get() for fs in self.filesystems.values()]
|
fs_actions = [fs.get() for fs in self.filesystems.values()]
|
||||||
mount_actions = [m.get() for m in self._mountactions.values()]
|
mount_actions = [m.get() for m in self._mountactions.values()]
|
||||||
actions = [action] + part_actions + fs_actions + mount_actions
|
actions = [action] + part_actions + fs_actions + mount_actions
|
||||||
|
@ -450,6 +454,7 @@ class Raiddev(Blockdev):
|
||||||
self._raid_level,
|
self._raid_level,
|
||||||
self._spare_devices)
|
self._spare_devices)
|
||||||
|
|
||||||
|
|
||||||
def sort_actions(actions):
|
def sort_actions(actions):
|
||||||
def type_index(t):
|
def type_index(t):
|
||||||
order = ['disk', 'partition', 'raid', 'format', 'mount']
|
order = ['disk', 'partition', 'raid', 'format', 'mount']
|
||||||
|
@ -467,8 +472,8 @@ def sort_actions(actions):
|
||||||
# for type==mount, count the number of dirs
|
# for type==mount, count the number of dirs
|
||||||
if a.get('type') == 'mount':
|
if a.get('type') == 'mount':
|
||||||
score += path_count(a)
|
score += path_count(a)
|
||||||
elif a.get('type') == 'partition' and \
|
elif (a.get('type') == 'partition' and
|
||||||
a.get('id').startswith('md'):
|
a.get('id').startswith('md')):
|
||||||
score += 2
|
score += 2
|
||||||
log.debug('a={} score={}'.format(a, score))
|
log.debug('a={} score={}'.format(a, score))
|
||||||
return score
|
return score
|
||||||
|
@ -481,7 +486,6 @@ def sort_actions(actions):
|
||||||
return actions
|
return actions
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
def get_filesystems(devices):
|
def get_filesystems(devices):
|
||||||
print("FILE SYSTEM")
|
print("FILE SYSTEM")
|
||||||
|
|
|
@ -418,7 +418,8 @@ class FilesystemModel(ModelPolicy):
|
||||||
len(dev.mounts) == 0 and \
|
len(dev.mounts) == 0 and \
|
||||||
len(dev.filesystems) == 0:
|
len(dev.filesystems) == 0:
|
||||||
empty.append(dev)
|
empty.append(dev)
|
||||||
log.debug('empty_disks: {}'.format(", ".join([dev.path for dev in empty])))
|
log.debug('empty_disks: {}'.format(
|
||||||
|
", ".join([dev.path for dev in empty])))
|
||||||
return empty
|
return empty
|
||||||
|
|
||||||
def get_empty_disk_names(self):
|
def get_empty_disk_names(self):
|
||||||
|
|
|
@ -23,10 +23,12 @@ from probert.network import (Network,
|
||||||
|
|
||||||
log = logging.getLogger('subiquity.prober')
|
log = logging.getLogger('subiquity.prober')
|
||||||
|
|
||||||
|
|
||||||
class ProberException(Exception):
|
class ProberException(Exception):
|
||||||
'''Base Prober Exception'''
|
'''Base Prober Exception'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Prober():
|
class Prober():
|
||||||
def __init__(self, opts):
|
def __init__(self, opts):
|
||||||
self.opts = opts
|
self.opts = opts
|
||||||
|
|
|
@ -89,6 +89,7 @@ class DiskInfoView(ViewPolicy):
|
||||||
def cancel(self, button):
|
def cancel(self, button):
|
||||||
self.signal.emit_signal('filesystem:show')
|
self.signal.emit_signal('filesystem:show')
|
||||||
|
|
||||||
|
|
||||||
class AddFormatView(WidgetWrap):
|
class AddFormatView(WidgetWrap):
|
||||||
|
|
||||||
def __init__(self, model, signal, selected_disk):
|
def __init__(self, model, signal, selected_disk):
|
||||||
|
@ -160,7 +161,7 @@ class AddFormatView(WidgetWrap):
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
valid = self.model.valid_mount(result)
|
self.model.valid_mount(result)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
log.exception('Invalid mount point')
|
log.exception('Invalid mount point')
|
||||||
self.mountpoint.set_error('Error: {}'.format(str(e)))
|
self.mountpoint.set_error('Error: {}'.format(str(e)))
|
||||||
|
@ -338,9 +339,8 @@ class AddPartitionView(WidgetWrap):
|
||||||
self.size.set_error('ERROR: {}'.format(result['bytes']))
|
self.size.set_error('ERROR: {}'.format(result['bytes']))
|
||||||
return
|
return
|
||||||
# Validate mountpoint input
|
# Validate mountpoint input
|
||||||
valid = False
|
|
||||||
try:
|
try:
|
||||||
valid = self.model.valid_mount(result)
|
self.model.valid_mount(result)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
log.exception('Invalid mount point')
|
log.exception('Invalid mount point')
|
||||||
self.mountpoint.set_error('Error: {}'.format(str(e)))
|
self.mountpoint.set_error('Error: {}'.format(str(e)))
|
||||||
|
@ -511,8 +511,9 @@ class FilesystemView(ViewPolicy):
|
||||||
def _build_partition_list(self):
|
def _build_partition_list(self):
|
||||||
log.debug('FileSystemView: building part list')
|
log.debug('FileSystemView: building part list')
|
||||||
pl = []
|
pl = []
|
||||||
if (len(self.model.get_partitions()) == 0 and
|
nr_parts = len(self.model.get_partitions())
|
||||||
len(self.model.get_filesystems()) == 0):
|
nr_fs = len(self.model.get_filesystems())
|
||||||
|
if nr_parts == 0 and nr_fs == 0:
|
||||||
pl.append(Color.info_minor(
|
pl.append(Color.info_minor(
|
||||||
Text("No disks or partitions mounted")))
|
Text("No disks or partitions mounted")))
|
||||||
log.debug('FileSystemView: no partitions')
|
log.debug('FileSystemView: no partitions')
|
||||||
|
|
|
@ -27,7 +27,6 @@ from subiquity.ui.lists import SimpleList
|
||||||
from subiquity.ui.buttons import cancel_btn, menu_btn, done_btn
|
from subiquity.ui.buttons import cancel_btn, menu_btn, done_btn
|
||||||
from subiquity.ui.utils import Padding, Color
|
from subiquity.ui.utils import Padding, Color
|
||||||
from subiquity.view import ViewPolicy
|
from subiquity.view import ViewPolicy
|
||||||
from subiquity.models.actions import RouteAction
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger('subiquity.network')
|
log = logging.getLogger('subiquity.network')
|
||||||
|
|
|
@ -42,10 +42,12 @@ checks:
|
||||||
- /usr/bin/curtin
|
- /usr/bin/curtin
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def environment_check(check=ENVIRONMENT_CHECK):
|
def environment_check(check=ENVIRONMENT_CHECK):
|
||||||
''' Check the environment to ensure subiquity can run without issues.
|
''' Check the environment to ensure subiquity can run without issues.
|
||||||
'''
|
'''
|
||||||
log.info('Checking environment for installer requirements...')
|
log.info('Checking environment for installer requirements...')
|
||||||
|
|
||||||
def is_file(x):
|
def is_file(x):
|
||||||
return os.path.isfile(x)
|
return os.path.isfile(x)
|
||||||
|
|
||||||
|
@ -84,7 +86,8 @@ def environment_check(check=ENVIRONMENT_CHECK):
|
||||||
for ftype, items in checks[check_type].items():
|
for ftype, items in checks[check_type].items():
|
||||||
for i in items:
|
for i in items:
|
||||||
if not os.path.exists(i):
|
if not os.path.exists(i):
|
||||||
log.error('FAIL: {} is not found on the filesystem'.format(i))
|
log.error('FAIL: {} is not found on the'
|
||||||
|
' filesystem'.format(i))
|
||||||
env_ok = False
|
env_ok = False
|
||||||
continue
|
continue
|
||||||
if check_map[ftype](i) is False:
|
if check_map[ftype](i) is False:
|
||||||
|
@ -92,8 +95,8 @@ def environment_check(check=ENVIRONMENT_CHECK):
|
||||||
env_ok = False
|
env_ok = False
|
||||||
continue
|
continue
|
||||||
if check_map[check_type](i) is False:
|
if check_map[check_type](i) is False:
|
||||||
log.error('FAIL: {} does NOT have required attr: {}'.format(i,
|
log.error('FAIL: {} does NOT have required attr:'
|
||||||
check_type))
|
' {}'.format(i, check_type))
|
||||||
env_ok = False
|
env_ok = False
|
||||||
|
|
||||||
return env_ok
|
return env_ok
|
||||||
|
|
|
@ -20,6 +20,7 @@ Contains some default key navigations
|
||||||
|
|
||||||
from urwid import WidgetWrap
|
from urwid import WidgetWrap
|
||||||
|
|
||||||
|
|
||||||
class ViewPolicy(WidgetWrap):
|
class ViewPolicy(WidgetWrap):
|
||||||
def keypress(self, size, key):
|
def keypress(self, size, key):
|
||||||
if key == 'esc':
|
if key == 'esc':
|
||||||
|
|
Loading…
Reference in New Issue