-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d060b6
commit cdf99c4
Showing
14 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Author: Yiannis Charalambous | ||
|
||
from .base_menu import BaseMenu | ||
|
||
__all__ = [ | ||
"BaseMenu", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Author: Yiannis Charalambous | ||
|
||
from .esbmc_menu import ESBMCMenu | ||
|
||
__all__ = ["ESBMCMenu"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Author: Yiannis Charalambous | ||
|
||
from typing_extensions import override | ||
import requests | ||
from requests.status_codes import codes as status_codes | ||
|
||
import urwid | ||
|
||
from esbmc_ai_config.models import ConfigManager | ||
from esbmc_ai_config.context import Context | ||
from esbmc_ai_config.widgets.back_button import BackButton | ||
|
||
|
||
class ESBMCManage(Context): | ||
license_url: str = "https://raw.githubusercontent.com/esbmc/esbmc/master/COPYING" | ||
|
||
def __init__(self) -> None: | ||
response: requests.Response = requests.get(ESBMCManage.license_url) | ||
if response.status_code == status_codes.ok: | ||
self.license: str = response.text | ||
else: | ||
self.license: str = ( | ||
f"Couldn't get the license: status code: {response.status_code}" | ||
) | ||
|
||
super().__init__(self.build_ui()) | ||
|
||
@property | ||
def license_accepted(self) -> bool: | ||
return bool(ConfigManager.env_config.values["ESBMC_LICENSE_AGREEMENT"]) | ||
|
||
@license_accepted.setter | ||
def license_accepted(self, value: bool) -> None: | ||
ConfigManager.env_config.values["ESBMC_LICENSE_AGREEMENT"] = value | ||
|
||
def _on_accept_license(self, button) -> None: | ||
self.license_accepted = True | ||
self.frame.set_body(self._build_ui()) | ||
|
||
def _build_ui_license_agreement(self) -> urwid.Widget: | ||
body: list[urwid.Widget] = [ | ||
urwid.Divider(), | ||
urwid.Text("Read and accept the license agreement of ESBMC"), | ||
urwid.Divider(), | ||
urwid.Text(self.license), | ||
urwid.Columns( | ||
[ | ||
BackButton(), | ||
urwid.AttrMap( | ||
urwid.Button( | ||
"Accept License", | ||
on_press=self._on_accept_license, | ||
), | ||
None, | ||
focus_map="reversed", | ||
), | ||
] | ||
), | ||
] | ||
|
||
return urwid.ScrollBar(urwid.ListBox(urwid.SimpleFocusListWalker(body))) | ||
|
||
def _build_ui(self) -> urwid.Widget: | ||
body: list[urwid.Widget] = [ | ||
urwid.Divider(), | ||
BackButton(), | ||
] | ||
|
||
return urwid.ScrollBar(urwid.ListBox(urwid.SimpleFocusListWalker(body))) | ||
|
||
@override | ||
def build_ui(self) -> urwid.Widget: | ||
content: urwid.Widget | ||
if self.license_accepted: | ||
content = self._build_ui() | ||
else: | ||
content = self._build_ui_license_agreement() | ||
|
||
self.frame: urwid.Frame = urwid.Frame( | ||
header=urwid.Text("Manage ESBMC Installations"), | ||
footer=urwid.Text("www.esbmc.org"), | ||
body=content, | ||
focus_part="body", | ||
) | ||
|
||
return self.frame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Author: Yiannis Charalambous | ||
|
||
|
||
class ESBMCParams(object): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Author: Yiannis Charalambous | ||
|
||
from .config_manager import ConfigManager | ||
from .env_config_loader import EnvConfigField, EnvConfigLoader | ||
from .json_config_loader import JsonConfigField, JsonConfigLoader | ||
|
||
__all__ = [ | ||
"ConfigManager", | ||
"EnvConfigField", | ||
"EnvConfigLoader", | ||
"JsonConfigField", | ||
"JsonConfigLoader", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Author: Yiannis Charalambous | ||
|
||
import urwid | ||
from urwid.widget import Button | ||
|
||
from esbmc_ai_config.context_manager import ContextManager | ||
|
||
|
||
class BackButton(urwid.WidgetWrap): | ||
def __init__(self): | ||
super().__init__(self.build_ui()) | ||
|
||
def _on_pressed(self, button) -> None: | ||
ContextManager.pop_context() | ||
|
||
def build_ui(self) -> urwid.Widget: | ||
self.button: urwid.Button = Button( | ||
"Back", | ||
on_press=self._on_pressed, | ||
) | ||
return urwid.AttrMap(self.button, None, focus_map="reversed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters