stop trying to be clever handling escape in filesystem views

This commit is contained in:
Michael Hudson-Doyle 2017-04-05 15:12:22 +12:00
parent 395b30451e
commit 387f2c7b76
7 changed files with 20 additions and 29 deletions

View File

@ -16,7 +16,7 @@
import logging import logging
import os import os
from subiquitycore.controller import BaseController, view from subiquitycore.controller import BaseController
from subiquitycore.ui.dummy import DummyView from subiquitycore.ui.dummy import DummyView
from subiquitycore.ui.error import ErrorView from subiquitycore.ui.error import ErrorView
@ -46,7 +46,6 @@ class FilesystemController(BaseController):
self.raid_model = RaidModel() self.raid_model = RaidModel()
self.model.probe() # probe before we complete self.model.probe() # probe before we complete
@view
def default(self, reset=False): def default(self, reset=False):
# FIXME: Is this the best way to zero out this list for a reset? # FIXME: Is this the best way to zero out this list for a reset?
if reset: if reset:
@ -107,7 +106,6 @@ class FilesystemController(BaseController):
self.signal.emit_signal('next-screen') self.signal.emit_signal('next-screen')
# Filesystem/Disk partition ----------------------------------------------- # Filesystem/Disk partition -----------------------------------------------
@view
def partition_disk(self, disk): def partition_disk(self, disk):
log.debug("In disk partition view, using {} as the disk.".format(disk.path)) log.debug("In disk partition view, using {} as the disk.".format(disk.path))
title = ("Partition, format, and mount {}".format(disk.path)) title = ("Partition, format, and mount {}".format(disk.path))
@ -119,7 +117,6 @@ class FilesystemController(BaseController):
self.ui.set_body(dp_view) self.ui.set_body(dp_view)
@view
def add_disk_partition(self, disk): def add_disk_partition(self, disk):
log.debug("Adding partition to {}".format(disk)) log.debug("Adding partition to {}".format(disk))
footer = ("Select whole disk, or partition, to format and mount.") footer = ("Select whole disk, or partition, to format and mount.")
@ -160,9 +157,9 @@ class FilesystemController(BaseController):
self.model.add_mount(fs, spec['mountpoint']) self.model.add_mount(fs, spec['mountpoint'])
log.info("Successfully added partition") log.info("Successfully added partition")
self.prev_view() self.partition_disk(disk)
def add_format_handler(self, volume, spec): def add_format_handler(self, volume, spec, back):
log.debug('add_format_handler') log.debug('add_format_handler')
if spec['fstype'] is not None: if spec['fstype'] is not None:
fs = self.model.add_filesystem(volume, spec['fstype']) fs = self.model.add_filesystem(volume, spec['fstype'])
@ -172,7 +169,7 @@ class FilesystemController(BaseController):
if fs is None: if fs is None:
raise Exception("{} is not formatted".format(volume.path)) raise Exception("{} is not formatted".format(volume.path))
self.model.add_mount(fs, spec['mountpoint']) self.model.add_mount(fs, spec['mountpoint'])
self.prev_view() back()
def connect_iscsi_disk(self, *args, **kwargs): def connect_iscsi_disk(self, *args, **kwargs):
# title = ("Disk and filesystem setup") # title = ("Disk and filesystem setup")
@ -193,7 +190,6 @@ class FilesystemController(BaseController):
# self.signal)) # self.signal))
self.ui.set_body(DummyView(self.signal)) self.ui.set_body(DummyView(self.signal))
@view
def create_volume_group(self, *args, **kwargs): def create_volume_group(self, *args, **kwargs):
title = ("Create Logical Volume Group (\"LVM2\") disk") title = ("Create Logical Volume Group (\"LVM2\") disk")
footer = ("ENTER on a disk will show detailed " footer = ("ENTER on a disk will show detailed "
@ -204,7 +200,6 @@ class FilesystemController(BaseController):
self.ui.set_footer(footer) self.ui.set_footer(footer)
self.ui.set_body(LVMVolumeGroupView(self.model, self.signal)) self.ui.set_body(LVMVolumeGroupView(self.model, self.signal))
@view
def create_raid(self, *args, **kwargs): def create_raid(self, *args, **kwargs):
title = ("Create software RAID (\"MD\") disk") title = ("Create software RAID (\"MD\") disk")
footer = ("ENTER on a disk will show detailed " footer = ("ENTER on a disk will show detailed "
@ -218,7 +213,6 @@ class FilesystemController(BaseController):
self.ui.set_body(RaidView(self.model, self.ui.set_body(RaidView(self.model,
self.signal)) self.signal))
@view
def create_bcache(self, *args, **kwargs): def create_bcache(self, *args, **kwargs):
title = ("Create hierarchical storage (\"bcache\") disk") title = ("Create hierarchical storage (\"bcache\") disk")
footer = ("ENTER on a disk will show detailed " footer = ("ENTER on a disk will show detailed "
@ -236,17 +230,15 @@ class FilesystemController(BaseController):
self.model.add_raid_device(result) self.model.add_raid_device(result)
self.signal.prev_signal() self.signal.prev_signal()
@view
def format_entire(self, disk): def format_entire(self, disk):
log.debug("format_entire {}".format(disk)) log.debug("format_entire {}".format(disk))
header = ("Format and/or mount {}".format(disk.path)) header = ("Format and/or mount {}".format(disk.path))
footer = ("Format or mount whole disk.") footer = ("Format or mount whole disk.")
self.ui.set_header(header) self.ui.set_header(header)
self.ui.set_footer(footer) self.ui.set_footer(footer)
afv_view = AddFormatView(self.model, self, disk) afv_view = AddFormatView(self.model, self, disk, lambda : self.partition_disk(disk))
self.ui.set_body(afv_view) self.ui.set_body(afv_view)
@view
def format_mount_partition(self, partition): def format_mount_partition(self, partition):
log.debug("format_entire {}".format(partition)) log.debug("format_entire {}".format(partition))
if partition.fs() is not None: if partition.fs() is not None:
@ -257,7 +249,7 @@ class FilesystemController(BaseController):
footer = ("Format and mount partition.") footer = ("Format and mount partition.")
self.ui.set_header(header) self.ui.set_header(header)
self.ui.set_footer(footer) self.ui.set_footer(footer)
afv_view = AddFormatView(self.model, self, partition) afv_view = AddFormatView(self.model, self, partition, self.default)
self.ui.set_body(afv_view) self.ui.set_body(afv_view)
def show_disk_information_next(self, disk): def show_disk_information_next(self, disk):

View File

@ -46,10 +46,11 @@ class AddFormatForm(Form):
class AddFormatView(BaseView): class AddFormatView(BaseView):
def __init__(self, model, controller, volume): def __init__(self, model, controller, volume, back):
self.model = model self.model = model
self.controller = controller self.controller = controller
self.volume = volume self.volume = volume
self.back = back
self.form = AddFormatForm(model) self.form = AddFormatForm(model)
if self.volume.fs() is not None: if self.volume.fs() is not None:
@ -71,8 +72,8 @@ class AddFormatView(BaseView):
format_box = Padding.center_50(ListBox(body)) format_box = Padding.center_50(ListBox(body))
super().__init__(format_box) super().__init__(format_box)
def cancel(self, button): def cancel(self, button=None):
self.controller.prev_view() self.back()
def done(self, result): def done(self, result):
""" format spec """ format spec
@ -97,4 +98,4 @@ class AddFormatView(BaseView):
result['fstype'] = None result['fstype'] = None
log.debug("Add Format Result: {}".format(result)) log.debug("Add Format Result: {}".format(result))
self.controller.add_format_handler(self.volume, result) self.controller.add_format_handler(self.volume, result, self.back)

View File

@ -20,11 +20,9 @@ configuration.
""" """
import logging import logging
import os
import re
from urwid import connect_signal, Text from urwid import connect_signal, Text
from subiquitycore.ui.container import Columns, ListBox from subiquitycore.ui.container import ListBox
from subiquitycore.ui.form import ( from subiquitycore.ui.form import (
Form, Form,
FormField, FormField,
@ -114,8 +112,8 @@ class AddPartitionView(BaseView):
partition_box = Padding.center_50(ListBox(body)) partition_box = Padding.center_50(ListBox(body))
super().__init__(partition_box) super().__init__(partition_box)
def cancel(self, button): def cancel(self, button=None):
self.controller.prev_view() self.controller.partition_disk(self.disk)
def done(self, result): def done(self, result):

View File

@ -63,5 +63,5 @@ class DiskInfoView(BaseView):
''' Return to FilesystemView ''' ''' Return to FilesystemView '''
self.controller.partition_disk(self.disk) self.controller.partition_disk(self.disk)
def cancel(self, button): def cancel(self, button=None):
self.controller.partition_disk(self.disk) self.controller.partition_disk(self.disk)

View File

@ -150,7 +150,7 @@ class DiskPartitionView(BaseView):
def done(self, result): def done(self, result):
''' Return to FilesystemView ''' ''' Return to FilesystemView '''
self.controller.prev_view() self.controller.default()
def cancel(self, button): def cancel(self, button=None):
self.controller.prev_view() self.controller.default()

View File

@ -203,7 +203,7 @@ class FilesystemView(BaseView):
user_data=sig))) user_data=sig)))
return Pile(opts) return Pile(opts)
def cancel(self, button): def cancel(self, button=None):
self.controller.cancel() self.controller.cancel()
def reset(self, button): def reset(self, button):

View File

@ -63,5 +63,5 @@ class InstallpathView(BaseView):
def confirm(self, result, sig): def confirm(self, result, sig):
self.signal.emit_signal(sig) self.signal.emit_signal(sig)
def cancel(self, button): def cancel(self, button=None):
self.signal.emit_signal('prev-screen') self.signal.emit_signal('prev-screen')