__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# Copyright 2020 Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from abc import abstractmethod
import asyncio
import logging
from subiquitycore.controller import BaseController
log = logging.getLogger("subiquitycore.tuicontroller")
class Skip(Exception):
"""Raise this from a controller's make_ui method to skip a screen."""
class TuiController(BaseController):
"""Base class for controllers."""
def __init__(self, app):
super().__init__(app)
self.ui = app.ui
self.answers = app.answers.get(self.name, {})
@abstractmethod
def cancel(self):
pass
@property
def showing(self):
inst = self.app.controllers.cur
while isinstance(inst, RepeatedController):
inst = inst.orig
return inst is self
@abstractmethod
def make_ui(self):
"""Return the view for this controller's UI."""
def end_ui(self):
"""Stop running this controller's UI.
This method doesn't actually need to remove this controller's UI
as the next one is about to replace it, it's more of a hook to
stop any background tasks that can be stopped when the UI is not
running.
"""
# Stuff for fine grained actions, used by filesystem and network
# controller at time of writing this comment.
async def _enter_form_data(self, form, data, submit, clean_suffix=''):
for k, v in data.items():
c = getattr(
self, '_action_clean_{}_{}'.format(k, clean_suffix), None)
if c is None:
c = getattr(self, '_action_clean_{}'.format(k), lambda x: x)
field = getattr(form, k)
from subiquitycore.ui.selector import Selector
v = c(v)
if isinstance(field.widget, Selector):
field.widget._emit('select', v)
field.value = v
yield
for bf in form._fields:
bf.validate()
form.validated()
if submit:
if not form.done_btn.enabled:
raise Exception("answers left form invalid!")
form._click_done(None)
async def _run_actions(self, actions):
delay = 0.2/self.app.scale_factor
for action in actions:
async for _ in self._answers_action(action):
await asyncio.sleep(delay)
delay /= 1.1
class RepeatedController(BaseController):
def __init__(self, orig, index):
self.name = "{}-{}".format(orig.name, index)
self.orig = orig
self.index = index
self.context = orig.context
def make_ui(self):
return self.orig.make_ui(self.index)
def run_answers(self):
self.orig.run_answers()
def end_ui(self):
self.orig.end_ui()
def cancel(self):
self.orig.cancel()
@property
def answers(self):
return self.orig.answers
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| controllers | Folder | 0755 |
|
|
| models | Folder | 0755 |
|
|
| testing | Folder | 0755 |
|
|
| tests | Folder | 0755 |
|
|
| ui | Folder | 0755 |
|
|
| __init__.py | File | 710 B | 0644 |
|
| async_helpers.py | File | 2.27 KB | 0644 |
|
| context.py | File | 4.42 KB | 0644 |
|
| controller.py | File | 1.68 KB | 0644 |
|
| controllerset.py | File | 1.9 KB | 0644 |
|
| core.py | File | 4.5 KB | 0644 |
|
| file_util.py | File | 1.67 KB | 0644 |
|
| i18n.py | File | 1.7 KB | 0644 |
|
| log.py | File | 1.8 KB | 0644 |
|
| lsb_release.py | File | 947 B | 0644 |
|
| netplan.py | File | 5.34 KB | 0644 |
|
| palette.py | File | 4.53 KB | 0644 |
|
| prober.py | File | 1.96 KB | 0644 |
|
| pubsub.py | File | 1.22 KB | 0644 |
|
| screen.py | File | 4.9 KB | 0644 |
|
| snapd.py | File | 6.1 KB | 0644 |
|
| ssh.py | File | 3.54 KB | 0644 |
|
| tui.py | File | 12.98 KB | 0644 |
|
| tuicontroller.py | File | 3.38 KB | 0644 |
|
| utils.py | File | 5.71 KB | 0644 |
|
| view.py | File | 3.35 KB | 0644 |
|