feat(Anaconda): Local Repo

This commit is contained in:
2026-06-13 02:06:34 +02:00
parent 05ae9c36c3
commit c412cd5d33
203 changed files with 23997 additions and 7 deletions
@@ -0,0 +1,60 @@
#!/bin/python3
#
# This file is part of Simpleline Text UI library.
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Simpleline is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simpleline 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Simpleline. If not, see <https://www.gnu.org/licenses/>.
#
# Basic usage of Simpleline.
#
# Only show screen with header and text in it.
#
from simpleline import App
from simpleline.render.screen import UIScreen
from simpleline.render.screen_handler import ScreenHandler
from simpleline.render.widgets import TextWidget
# UIScreen is the main building item for Simpleline. Every screen
# which will user see should be inherited from UIScreen.
class HelloWorld(UIScreen):
def __init__(self):
# Set title of the screen.
super().__init__(title=u"Hello World")
def refresh(self, args=None):
# Fill the self.window attribute by the WindowContainer and set screen title as header.
super().refresh()
widget = TextWidget("Body text")
self.window.add_with_separator(widget)
if __name__ == "__main__":
# Initialize application (create scheduler and event loop).
App.initialize()
# Create our screen.
screen = HelloWorld()
# Schedule screen to the screen scheduler.
# This can be called only after App.initialize().
ScreenHandler.schedule_screen(screen)
# Run the application. You must have some screen scheduled
# otherwise it will end in an infinite loop.
App.run()
@@ -0,0 +1,75 @@
#!/bin/python3
#
# This file is part of Simpleline Text UI library.
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Simpleline is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simpleline 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Simpleline. If not, see <https://www.gnu.org/licenses/>.
#
# Usage of base widgets.
#
# Show base widgets for user interaction in one screen.
#
from simpleline import App
from simpleline.render.screen import UIScreen
from simpleline.render.screen_handler import ScreenHandler
from simpleline.render.widgets import TextWidget, CenterWidget, CheckboxWidget
class HelloWorld(UIScreen):
def __init__(self):
# Set title of the screen.
super().__init__(title=u"Show Widgets")
def refresh(self, args=None):
super().refresh()
# Text widget
# Show text to user. This is basic widget which will handle
# wrapping of words for you.
text_widget = TextWidget("Text widget")
self.window.add_with_separator(text_widget)
# Center widget
# Wrap extisting widget and center it to the middle of the screen.
text = TextWidget("Center widget")
center_widget = CenterWidget(text)
self.window.add_with_separator(center_widget, blank_lines=3) # Add two more blank lines
# Checkbox widget
# Checkbox which can hold 2 states.
checkbox_widget = CheckboxWidget(key="o",
title="Checkbox title",
text="Checkbox text",
completed=True)
self.window.add_with_separator(checkbox_widget)
# Checkbox widget unchecked
checkbox_widget_unchecked = CheckboxWidget(key="o",
title="Checkbox title",
text="Unchecked",
completed=False)
self.window.add_with_separator(checkbox_widget_unchecked)
if __name__ == "__main__":
App.initialize()
screen = HelloWorld()
ScreenHandler.schedule_screen(screen)
App.run()
@@ -0,0 +1,78 @@
#!/bin/python3
#
# This file is part of Simpleline Text UI library.
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Simpleline is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simpleline 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Simpleline. If not, see <https://www.gnu.org/licenses/>.
#
# How to block the input from a user.
#
# This can be used for example to force a user to set all the required values.
# Application quit callback is also used here.
#
from simpleline import App
from simpleline.render.prompt import Prompt
from simpleline.render.screen import UIScreen, InputState
from simpleline.render.screen_handler import ScreenHandler
from simpleline.render.widgets import TextWidget, CenterWidget
def application_quit_cb(args):
"""Call this callback when the application is quitting."""
print("Application is closing. Bye!")
class InfiniteScreen(UIScreen):
def __init__(self):
# We are using title as message here. Any text could be passed to the title.
super().__init__("You need to use 'q' to quit")
self.continue_count = 0
def refresh(self, args=None):
"""Print text to user with number of continue clicked."""
super().refresh(args)
# Print counter to the screen.
widget = TextWidget("You pressed {} times on continue".format(self.continue_count))
# Center this counter to middle of the screen.
center_widget = CenterWidget(widget)
# Add the centered widget to the window container.
self.window.add(center_widget)
def input(self, args, key):
"""Catch 'c' keys for continue and increase counter."""
if key == Prompt.CONTINUE:
self.continue_count += 1
# Do not process 'c' continue anymore.
# This will refresh screen to refresh counter number
return InputState.PROCESSED_AND_REDRAW
# Process other input e.g.: 'r' refresh and 'q' quit.
return key
if __name__ == "__main__":
App.initialize()
screen = InfiniteScreen()
# Get event loop from application.
loop = App.get_event_loop()
# Set quit callback to the loop. When the loop quits this callback will be triggered.
loop.set_quit_callback(application_quit_cb)
ScreenHandler.schedule_screen(screen)
App.run()
@@ -0,0 +1,89 @@
#!/bin/python3
#
# This file is part of Simpleline Text UI library.
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Simpleline is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simpleline 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Simpleline. If not, see <https://www.gnu.org/licenses/>.
#
from simpleline import App
from simpleline.render.screen import UIScreen, InputState
from simpleline.render.screen_handler import ScreenHandler
from simpleline.render.widgets import TextWidget, CenterWidget
class Hub(UIScreen):
def __init__(self):
super().__init__("Hub for entry counter")
self._counter_spoke = CounterScreen()
def refresh(self, args=None):
super().refresh(args)
w = CenterWidget(TextWidget("Press '1' to enter Entry counter"))
self.window.add_with_separator(w)
def input(self, args, key):
"""Run spokes based on the user choice."""
if key == "1":
ScreenHandler.push_screen(self._counter_spoke)
# this input was processed
return InputState.PROCESSED
# return for outer processing
# the basic processing is 'c' for continue, 'r' for refresh, 'q' to quit
# otherwise the input is discarded and waiting for a new input
return key
def prompt(self, args=None):
"""Add our information to the prompt."""
prompt = super().prompt(args)
prompt.add_option("1", "to enter counter spoke")
return prompt
class CounterScreen(UIScreen):
def __init__(self):
super().__init__("Counter Screen")
self._counter = 0
def closed(self):
super().closed()
self.screen_ready = False
def setup(self, args=None):
super().setup(args)
self._counter += 1
return True
def refresh(self, args=None):
"""Write message to user."""
super().refresh(args)
w = TextWidget("Counter {}".format(self._counter))
self.window.add_with_separator(CenterWidget(w))
@property
def counter(self):
return self._counter
if __name__ == "__main__":
App.initialize()
hub = Hub()
ScreenHandler.schedule_screen(hub)
App.run()
@@ -0,0 +1,37 @@
#!/bin/python3
#
# This file is part of Simpleline Text UI library.
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Simpleline is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simpleline 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Simpleline. If not, see <https://www.gnu.org/licenses/>.
#
# Show help screen.
#
# Usage of the HelpScreen advanced widget.
# There are many of advanced widgets which have different uses.
# I've recommend developer to look on them.
from simpleline import App
from simpleline.render.screen_handler import ScreenHandler
from simpleline.render.adv_widgets import HelpScreen
if __name__ == "__main__":
App.initialize()
# You need to pass file with help text to the screen.
s = HelpScreen("./04_help/example_help.txt")
ScreenHandler.schedule_screen(s)
App.run()
@@ -0,0 +1,3 @@
This is help to our AWESOME application.
Everything is so simple, therefore no help is needed!
@@ -0,0 +1,202 @@
#!/bin/python3
#
# This file is part of Simpleline Text UI library.
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Simpleline is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simpleline 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Simpleline. If not, see <https://www.gnu.org/licenses/>.
#
# Hub and spoke implementation.
#
# Advanced example of Simpleline use.
# Hub is the main screen from where you can go to spokes and do work in the spokes
# then you will return to the hub back. You can continue when all the required items
# is set.
# The example of containers use will be showed here.
#
from simpleline import App
from simpleline.render.adv_widgets import PasswordDialog
from simpleline.render.containers import ListRowContainer
from simpleline.render.prompt import Prompt
from simpleline.render.screen import UIScreen, InputState
from simpleline.render.screen_handler import ScreenHandler
from simpleline.render.widgets import TextWidget, CenterWidget
class Hub(UIScreen):
def __init__(self):
super().__init__("Hub")
# Container will be used for spokes positioning. Container is always created in
# the refresh() method.
self._container = None
self._create_spokes()
def _create_spokes(self):
"""Create spokes and use their value."""
# Create name spoke
self._name_spoke = SetNameScreen("First name", "John")
# Create surname spoke
self._surname_spoke = SetNameScreen("Surname", "Doe")
# Create the PasswordDialog advanced widget for getting password from a user.
self._password_spoke = PasswordDialog()
def refresh(self, args=None):
"""Refresh method is called always before the screen will be printed.
All items for printing should be updated or created here.
"""
# Init window container. The windows container will be erased here.
# The window container is the base container. Everything for rendering should be put
# into this container, including other containers.
super().refresh(args)
# Add the screen header message before our items.
header = TextWidget("Please complete all the spokes to continue")
header = CenterWidget(header)
self.window.add_with_separator(header, blank_lines=2)
# Create the empty container.
# It will add numbering, process user input and positioning for us.
self._container = ListRowContainer(2)
# Create widget to get user name.
widget = self._create_name_widget()
# Add widget, callback, arguments to the container.
#
# widget - Widget we want to render. It will be numbered automatically.
# Could be container if needed.
# callback - This callback will be called by the ListRowContainer.process_user_input()
# method when a user press the number of this item. Callback will get args
# passed as 3rd argument.
# args - Argument for callback.
self._container.add(widget, self._push_screen_callback, self._name_spoke)
# Create surname widget and add it to the container.
widget = self._create_surname_widget()
self._container.add(widget, self._push_screen_callback, self._surname_spoke)
# Create password widget and add it to the container.
widget = self._create_password_widget()
self._container.add(widget, self._push_screen_callback, self._password_spoke)
# Add the ListRowContainer container to the WindowContainer container.
self.window.add_with_separator(self._container)
def _create_name_widget(self):
"""Create name spoke widget.
Add the actual value below the spoke name.
"""
msg = "First name"
if self._name_spoke.value:
msg += "\n{}".format(self._name_spoke.value)
return TextWidget(msg)
def _create_surname_widget(self):
"""Create surname spoke widget.
Add the actual value below the spoke name.
"""
msg = "Surname"
if self._surname_spoke.value:
msg += "\n{}".format(self._surname_spoke.value)
return TextWidget(msg)
def _create_password_widget(self):
"""Create password spoke widget.
Add the "Password set" text below the spoke name if set.
"""
msg = "Password"
if self._password_spoke.answer:
msg += "\nPassword set."
return TextWidget(msg)
def input(self, args, key):
"""Run spokes based on the user choice."""
# Find out if a user pressed number for an existing widget and call the callback attached
# to it with arguments passed in the refresh() method.
# Return False if the input is not related to the widget.
if self._container.process_user_input(key):
# Do not process other input if spoke is entered.
return InputState.PROCESSED
# Block continue ('c') if everything is not set.
if key == Prompt.CONTINUE:
if self._name_spoke and self._surname_spoke and self._password_spoke.answer:
return key
# catch 'c' key if not everything set
return InputState.DISCARDED
return key
@staticmethod
def _push_screen_callback(target_screen):
"""Push target screen as new screen.
Target screen is passed in as an argument in the refresh() method.
"""
ScreenHandler.push_screen(target_screen)
def prompt(self, args=None):
"""Add information to prompt for user."""
prompt = super().prompt(args)
# Give user hint that he can press 1, 2 or 3 to enter spokes.
prompt.add_option("1,2,3", "to enter spokes")
return prompt
class SetNameScreen(UIScreen):
def __init__(self, message, def_value):
"""Create spoke for setting name and surname.
:param message: Text message as the body for user.
:param def_value: Default value for this spoke.
"""
super().__init__()
self._value = def_value
self._message = message
def refresh(self, args=None):
"""Write message to user."""
super().refresh(args)
w = TextWidget(self._message)
self.window.add(CenterWidget(w))
def prompt(self, args=None):
"""Take user input."""
self._value = self.get_user_input("Write your name: ")
self.close()
@property
def value(self):
"""Return value set by a user in this spoke."""
return self._value
if __name__ == "__main__":
App.initialize()
screen = Hub()
ScreenHandler.schedule_screen(screen)
App.run()
@@ -0,0 +1,62 @@
#!/bin/python3
#
# This file is part of Simpleline Text UI library.
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Simpleline is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simpleline 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Simpleline. If not, see <https://www.gnu.org/licenses/>.
#
# Use glib event loop instead of the original Simpleline loop.
#
# You need to have the python3-gobject installed.
#
# You can install it on Fedora by running:
#
# dnf install python3-gobject-base
#
#
# This is basic example using Glib event loop.
# You can implement your own loop abstraction. See simpleline/event_loop/glib_event_loop.
#
from simpleline import App
from simpleline.event_loop.glib_event_loop import GLibEventLoop
from simpleline.render.screen import UIScreen
from simpleline.render.screen_handler import ScreenHandler
from simpleline.render.widgets import TextWidget
class HelloWorld(UIScreen):
def __init__(self):
super().__init__(title=u"Hello World with GLib")
def refresh(self, args=None):
super().refresh()
self.window.add_with_separator(TextWidget("Body text"))
if __name__ == "__main__":
# Create Glib event loop.
glib_loop = GLibEventLoop()
# Use glib event loop instead of the original one.
# Everything else should behave the same as with the original Simpleline loop.
App.initialize(event_loop=glib_loop)
screen = HelloWorld()
ScreenHandler.schedule_screen(screen)
# Run the application.
App.run()
@@ -0,0 +1,102 @@
#!/bin/python3
#
# This file is part of Simpleline Text UI library.
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Simpleline is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simpleline 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Simpleline. If not, see <https://www.gnu.org/licenses/>.
#
# Simple divider screen.
#
# User input processing example.
#
#
import re
from simpleline import App
from simpleline.render.screen import UIScreen, InputState
from simpleline.render.screen_handler import ScreenHandler
from simpleline.render.widgets import TextWidget
class DividerScreen(UIScreen):
def __init__(self):
# Set title of the screen.
super().__init__(title=u"Divider")
self._message = 0
def refresh(self, args=None):
# Fill the self.window attribute by the WindowContainer and set screen title as header.
super().refresh()
widget = TextWidget("Result: " + str(self._message))
self.window.add_with_separator(widget)
def prompt(self, args=None):
# Change user prompt
prompt = super().prompt()
# Set message to the user prompt. Give a user hint how he/she may control our application.
prompt.set_message("Pass numbers to divider in a format: 'num / num'")
# Remove continue option from the control. There is no need for that
# when we have only one screen.
prompt.remove_option('c')
return prompt
def input(self, args, key):
"""Process input from user and catch numbers with '/' symbol."""
# Test if user passed valid input for divider.
# This will basically take number + number and nothing else and only positive numbers.
groups = re.match(r'(\d+) *\/ *(\d+)$', key)
if groups:
num1 = int(groups[1])
num2 = int(groups[2])
# Dividing by zero is not valid so we won't accept this input from the user. New
# input is then required from the user.
if num2 == 0:
return InputState.DISCARDED
self._message = int(num1 / num2)
# Because this input is processed we need to show this screen (show the result).
# This will call refresh so our new result will be processed inside of the refresh()
# method.
return InputState.PROCESSED_AND_REDRAW
# Not input for our screen, try other default inputs. This will result in the
# same state as DISCARDED when no default option is used.
return key
if __name__ == "__main__":
# Initialize application (create scheduler and event loop).
App.initialize()
# Create our screen.
screen = DividerScreen()
# Schedule screen to the screen scheduler.
# This can be called only after App.initialize().
ScreenHandler.schedule_screen(screen)
# Run the application. You must have some screen scheduled
# otherwise it will end in an infinite loop.
App.run()
@@ -0,0 +1,51 @@
#!/bin/bash
#
# This file is part of Simpleline Text UI library.
#
# Copyright (C) 2020 Red Hat, Inc.
#
# Simpleline is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Simpleline 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Simpleline. If not, see <https://www.gnu.org/licenses/>.
#
# Script for starting examples from source code.
#
# Author(s): Jiri Konecny <jkonecny@redhat.com>
#
function print_help {
echo "run_example.sh - easy way how to run example without installing module"
echo ""
echo "./run_example.sh [example]"
echo ""
echo "There is one required argument [example] which is name of the test."
echo ""
}
if [[ $# -ne 1 ]]; then
echo "Bad number of arguments" 1>&2
print_help
exit 1
elif [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
print_help
exit 0
fi
PROJECT_NAME=${1%%/}
pushd $(pwd)
cd $(dirname $0)/
PYTHONPATH="..:." python3 ./$PROJECT_NAME/$PROJECT_NAME.py
popd