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)
|
||||
endif
|
||||
|
||||
.PHONY: run clean
|
||||
.PHONY: run clean check
|
||||
|
||||
all: dryrun
|
||||
|
||||
|
@ -50,13 +50,15 @@ ui-view-serial:
|
|||
|
||||
lint:
|
||||
echo "Running flake8 lint tests..."
|
||||
flake8 bin/$(PYTHONSRC)-tui --ignore=F403
|
||||
flake8 --exclude $(PYTHONSRC)/tests/ $(PYTHONSRC) --ignore=F403
|
||||
python3 /usr/bin/flake8 bin/$(PYTHONSRC)-tui --ignore=F403
|
||||
python3 /usr/bin/flake8 --exclude $(PYTHONSRC)/tests/ $(PYTHONSRC) --ignore=F403
|
||||
|
||||
unit:
|
||||
echo "Running unit tests..."
|
||||
nosetests3 $(PYTHONSRC)/tests
|
||||
|
||||
check: lint unit
|
||||
|
||||
installer/$(INSTALLIMG): installer/geninstaller installer/runinstaller $(INSTALLER_RESOURCES) probert
|
||||
(cd installer && TOPDIR=$(TOPDIR)/installer ./geninstaller -v -r $(RELEASE) -a $(ARCH) -s $(STREAM) -b $(BOOTLOADER))
|
||||
echo $(INSTALLER_RESOURCES)
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
# 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/>.
|
||||
|
||||
from .welcome import WelcomeController
|
||||
from .installpath import InstallpathController
|
||||
from .network import NetworkController
|
||||
from .filesystem import FilesystemController
|
||||
from .installprogress import InstallProgressController
|
||||
from .identity import IdentityController
|
||||
from .welcome import WelcomeController # NOQA
|
||||
from .installpath import InstallpathController # NOQA
|
||||
from .network import NetworkController # NOQA
|
||||
from .filesystem import FilesystemController # NOQA
|
||||
from .installprogress import InstallProgressController # NOQA
|
||||
from .identity import IdentityController # NOQA
|
||||
|
|
|
@ -23,7 +23,6 @@ from subiquity.models.filesystem import (_humanize_size)
|
|||
from subiquity.ui.views import (DiskPartitionView, AddPartitionView,
|
||||
AddFormatView, FilesystemView,
|
||||
DiskInfoView, RaidView)
|
||||
import subiquity.utils as utils
|
||||
from subiquity.ui.dummy import DummyView
|
||||
from subiquity.ui.error import ErrorView
|
||||
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")
|
||||
|
||||
|
||||
class NetworkController(ControllerPolicy):
|
||||
def __init__(self, common):
|
||||
super().__init__(common)
|
||||
|
|
|
@ -62,15 +62,23 @@ network:
|
|||
config:
|
||||
"""
|
||||
|
||||
# TODO, this should be moved to the in-target cloud-config seed so on first boot
|
||||
# of the target, it reconfigures datasource_list to none for subsequent boots
|
||||
# 12_ds_to_none: [curtin, in-target, --, sh, '-c', "echo 'datasource_list: [ None ]' > /etc/cloud/cloud.cfg.d/
|
||||
POST_INSTALL = '''
|
||||
late_commands:
|
||||
10_mkdir_seed: curtin in-target -- 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"]
|
||||
'''
|
||||
# TODO, this should be moved to the in-target cloud-config seed so on first
|
||||
# boot of the target, it reconfigures datasource_list to none for subsequent
|
||||
# boots.
|
||||
# Reworked for flake8, but it does make it harder to read.
|
||||
POST_INSTALL_LIST = [
|
||||
("late_commands:"),
|
||||
(" 10_mkdir_seed: curtin in-target -- "
|
||||
"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):
|
||||
|
|
|
@ -20,6 +20,7 @@ from logging.handlers import TimedRotatingFileHandler
|
|||
LOGDIR = "logs"
|
||||
LOGFILE = os.path.join(LOGDIR, "debug.log")
|
||||
|
||||
|
||||
def setup_logger(name=__name__):
|
||||
if not os.path.isdir(LOGDIR):
|
||||
os.makedirs(LOGDIR)
|
||||
|
|
|
@ -112,6 +112,7 @@ class DiskAction():
|
|||
self._type = 'disk'
|
||||
|
||||
__hash__ = None
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
return (self._action_id == other._action_id and
|
||||
|
@ -170,6 +171,7 @@ class RaidAction(DiskAction):
|
|||
self._type = 'raid'
|
||||
|
||||
__hash__ = None
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
return (self._action_id == other._action_id and
|
||||
|
@ -209,6 +211,7 @@ class PartitionAction(DiskAction):
|
|||
self._action_id = 'bios_boot_partition'
|
||||
|
||||
__hash__ = None
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
return (self._action_id == other._action_id and
|
||||
|
@ -221,7 +224,6 @@ class PartitionAction(DiskAction):
|
|||
else:
|
||||
return False
|
||||
|
||||
|
||||
@property
|
||||
def path(self):
|
||||
return "{}{}".format(self.parent.action_id, self.partnum)
|
||||
|
@ -279,6 +281,7 @@ class FormatAction(DiskAction):
|
|||
self._action_id = self._action_id[:11]
|
||||
|
||||
__hash__ = None
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
return (self._action_id == other._action_id and
|
||||
|
@ -288,7 +291,6 @@ class FormatAction(DiskAction):
|
|||
else:
|
||||
return False
|
||||
|
||||
|
||||
@property
|
||||
def fstype(self):
|
||||
return self._fstype
|
||||
|
@ -310,6 +312,7 @@ class MountAction(DiskAction):
|
|||
self._type = 'mount'
|
||||
|
||||
__hash__ = None
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
return (self._action_id == other._action_id and
|
||||
|
|
|
@ -78,7 +78,7 @@ class Disk():
|
|||
self._partitions = OrderedDict()
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
if isinstance(other, self.__class__):
|
||||
print('disk same class, checking members')
|
||||
return (self._devpath == other._devpath and
|
||||
self._serial == other._serial and
|
||||
|
@ -88,7 +88,9 @@ class Disk():
|
|||
self._partitions == other._partitions)
|
||||
else:
|
||||
return False
|
||||
__hash__ = None
|
||||
|
||||
__hash__ = None # declare we don't supply a hash
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
|
@ -112,12 +114,12 @@ class Disk():
|
|||
|
||||
def __repr__(self):
|
||||
o = {
|
||||
'devpath': self.devpath,
|
||||
'serial': self.serial,
|
||||
'model': self.model,
|
||||
'parttype': self.parttype,
|
||||
'size': self.size,
|
||||
'partitions': self.partitions
|
||||
'devpath': self.devpath,
|
||||
'serial': self.serial,
|
||||
'model': self.model,
|
||||
'parttype': self.parttype,
|
||||
'size': self.size,
|
||||
'partitions': self.partitions
|
||||
}
|
||||
return yaml.dump(o, default_flow_style=False)
|
||||
|
||||
|
@ -164,19 +166,20 @@ class Blockdev():
|
|||
self.disk.parttype)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
if isinstance(other, self.__class__):
|
||||
return (self.disk == other.disk and
|
||||
self._filesystems == other._filesystems and
|
||||
self._mounts == other._mounts and
|
||||
self._mountactions == other._mountactions and
|
||||
self.bcache == other.bcache and
|
||||
self.lvm == other.lvm and
|
||||
self.lvm == other.lvm and
|
||||
self.holder == other.holder and
|
||||
self.baseaction == other.baseaction)
|
||||
else:
|
||||
return False
|
||||
|
||||
__hash__ = None
|
||||
__hash__ = None # declare we don't supply a hash
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
|
@ -265,14 +268,14 @@ class Blockdev():
|
|||
|
||||
@property
|
||||
def available_partitions(self):
|
||||
''' return list of non-zero sized partitions that are
|
||||
''' return list of non-zero sized partitions that are
|
||||
defined but not mounted, not formatted, and not used in
|
||||
raid, lvm, bcache'''
|
||||
return [part.devpath for (num, part) in self.partitions.items()
|
||||
if part.size > 0 and
|
||||
part.flags not in ['raid', 'lvm', 'bcache'] and
|
||||
(part.devpath not in self._mounts.keys() and
|
||||
part.devpath not in self._filesystems.keys())]
|
||||
if (part.size > 0 and
|
||||
part.flags not in ['raid', 'lvm', 'bcache'] and
|
||||
(part.devpath not in self._mounts.keys() and
|
||||
part.devpath not in self._filesystems.keys()))]
|
||||
|
||||
@property
|
||||
def mounted(self):
|
||||
|
@ -402,16 +405,17 @@ class Blockdev():
|
|||
|
||||
def get_actions(self):
|
||||
if self.is_mounted():
|
||||
log.debug(
|
||||
'Emitting no actions, device ({}) is mounted'.format(self.devpath))
|
||||
log.debug('Emitting no actions, device '
|
||||
'({}) is mounted'.format(self.devpath))
|
||||
return []
|
||||
|
||||
actions = []
|
||||
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()]
|
||||
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
|
||||
log.debug('actions ({}):\n{}'.format(len(actions), actions))
|
||||
|
||||
return actions
|
||||
|
@ -450,6 +454,7 @@ class Raiddev(Blockdev):
|
|||
self._raid_level,
|
||||
self._spare_devices)
|
||||
|
||||
|
||||
def sort_actions(actions):
|
||||
def type_index(t):
|
||||
order = ['disk', 'partition', 'raid', 'format', 'mount']
|
||||
|
@ -467,8 +472,8 @@ def sort_actions(actions):
|
|||
# for type==mount, count the number of dirs
|
||||
if a.get('type') == 'mount':
|
||||
score += path_count(a)
|
||||
elif a.get('type') == 'partition' and \
|
||||
a.get('id').startswith('md'):
|
||||
elif (a.get('type') == 'partition' and
|
||||
a.get('id').startswith('md')):
|
||||
score += 2
|
||||
log.debug('a={} score={}'.format(a, score))
|
||||
return score
|
||||
|
@ -481,7 +486,6 @@ def sort_actions(actions):
|
|||
return actions
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def get_filesystems(devices):
|
||||
print("FILE SYSTEM")
|
||||
|
|
|
@ -418,7 +418,8 @@ class FilesystemModel(ModelPolicy):
|
|||
len(dev.mounts) == 0 and \
|
||||
len(dev.filesystems) == 0:
|
||||
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
|
||||
|
||||
def get_empty_disk_names(self):
|
||||
|
|
|
@ -23,10 +23,12 @@ from probert.network import (Network,
|
|||
|
||||
log = logging.getLogger('subiquity.prober')
|
||||
|
||||
|
||||
class ProberException(Exception):
|
||||
'''Base Prober Exception'''
|
||||
pass
|
||||
|
||||
|
||||
class Prober():
|
||||
def __init__(self, opts):
|
||||
self.opts = opts
|
||||
|
|
|
@ -23,8 +23,8 @@ from .ceph import CephDiskView # NOQA
|
|||
from .iscsi import IscsiDiskView # NOQA
|
||||
from .network import NetworkView # NOQA
|
||||
from .network_default_route import NetworkSetDefaultRouteView # NOQA
|
||||
from .network_configure_interface import NetworkConfigureInterfaceView #NOQA
|
||||
from .network_configure_ipv4_interface import NetworkConfigureIPv4InterfaceView #NOQA
|
||||
from .network_configure_interface import NetworkConfigureInterfaceView # NOQA
|
||||
from .network_configure_ipv4_interface import NetworkConfigureIPv4InterfaceView # NOQA
|
||||
from .installpath import InstallpathView # NOQA
|
||||
from .installprogress import ProgressView # NOQA
|
||||
from .welcome import WelcomeView # NOQA
|
||||
|
|
|
@ -89,6 +89,7 @@ class DiskInfoView(ViewPolicy):
|
|||
def cancel(self, button):
|
||||
self.signal.emit_signal('filesystem:show')
|
||||
|
||||
|
||||
class AddFormatView(WidgetWrap):
|
||||
|
||||
def __init__(self, model, signal, selected_disk):
|
||||
|
@ -148,7 +149,7 @@ class AddFormatView(WidgetWrap):
|
|||
def done(self, result):
|
||||
""" format spec
|
||||
|
||||
{
|
||||
{
|
||||
'format' Str(ext4|btrfs..,
|
||||
'mountpoint': Str
|
||||
}
|
||||
|
@ -160,7 +161,7 @@ class AddFormatView(WidgetWrap):
|
|||
}
|
||||
|
||||
try:
|
||||
valid = self.model.valid_mount(result)
|
||||
self.model.valid_mount(result)
|
||||
except ValueError as e:
|
||||
log.exception('Invalid mount point')
|
||||
self.mountpoint.set_error('Error: {}'.format(str(e)))
|
||||
|
@ -338,9 +339,8 @@ class AddPartitionView(WidgetWrap):
|
|||
self.size.set_error('ERROR: {}'.format(result['bytes']))
|
||||
return
|
||||
# Validate mountpoint input
|
||||
valid = False
|
||||
try:
|
||||
valid = self.model.valid_mount(result)
|
||||
self.model.valid_mount(result)
|
||||
except ValueError as e:
|
||||
log.exception('Invalid mount point')
|
||||
self.mountpoint.set_error('Error: {}'.format(str(e)))
|
||||
|
@ -511,8 +511,9 @@ class FilesystemView(ViewPolicy):
|
|||
def _build_partition_list(self):
|
||||
log.debug('FileSystemView: building part list')
|
||||
pl = []
|
||||
if (len(self.model.get_partitions()) == 0 and
|
||||
len(self.model.get_filesystems()) == 0):
|
||||
nr_parts = len(self.model.get_partitions())
|
||||
nr_fs = len(self.model.get_filesystems())
|
||||
if nr_parts == 0 and nr_fs == 0:
|
||||
pl.append(Color.info_minor(
|
||||
Text("No disks or partitions mounted")))
|
||||
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.utils import Padding, Color
|
||||
from subiquity.view import ViewPolicy
|
||||
from subiquity.models.actions import RouteAction
|
||||
|
||||
|
||||
log = logging.getLogger('subiquity.network')
|
||||
|
|
|
@ -42,10 +42,12 @@ checks:
|
|||
- /usr/bin/curtin
|
||||
'''
|
||||
|
||||
|
||||
def environment_check(check=ENVIRONMENT_CHECK):
|
||||
''' Check the environment to ensure subiquity can run without issues.
|
||||
'''
|
||||
log.info('Checking environment for installer requirements...')
|
||||
|
||||
def is_file(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 i in items:
|
||||
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
|
||||
continue
|
||||
if check_map[ftype](i) is False:
|
||||
|
@ -92,8 +95,8 @@ def environment_check(check=ENVIRONMENT_CHECK):
|
|||
env_ok = False
|
||||
continue
|
||||
if check_map[check_type](i) is False:
|
||||
log.error('FAIL: {} does NOT have required attr: {}'.format(i,
|
||||
check_type))
|
||||
log.error('FAIL: {} does NOT have required attr:'
|
||||
' {}'.format(i, check_type))
|
||||
env_ok = False
|
||||
|
||||
return env_ok
|
||||
|
|
|
@ -20,6 +20,7 @@ Contains some default key navigations
|
|||
|
||||
from urwid import WidgetWrap
|
||||
|
||||
|
||||
class ViewPolicy(WidgetWrap):
|
||||
def keypress(self, size, key):
|
||||
if key == 'esc':
|
||||
|
|
Loading…
Reference in New Issue