Compare commits

..

No commits in common. "b0f634f1e86862b3f66d4787005f9a4c423d2ecd" and "81a5497a32a9a4f21adf1c9b4c87f33b9821d2e7" have entirely different histories.

10 changed files with 87 additions and 187 deletions

View File

@ -139,13 +139,13 @@ A valid `vban.toml` might look like this:
```toml
[connection-1]
kind = 'banana'
host = '192.168.1.2'
ip = '192.168.1.2'
streamname = 'worklaptop'
port = 6980
[connection-2]
kind = 'potato'
host = '192.168.1.3'
ip = '192.168.1.3'
streamname = 'streampc'
port = 6990
```

View File

@ -1,40 +0,0 @@
version: '3'
tasks:
build:
desc: Build Azure artifacts
deps: [rewrite]
cmds:
- defer: { task: restore }
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [azure-light, azure-dark]
cmd: poetry run pyinstaller --noconfirm --distpath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} spec/azure/{{.ITEM.THEME}}-{{.ITEM.KIND}}.spec
rewrite:
internal: true
desc: Run the source code rewriter
cmds:
- poetry run python tools/rewriter.py --rewrite --theme {{.THEME}}
restore:
internal: true
desc: Restore the backup files
cmds:
- poetry run python tools/rewriter.py --restore
compress:
desc: Compress Azure artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [azure-light, azure-dark]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} -DestinationPath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}}.zip -Force"'
clean:
desc: Clean build and dist directories
cmds:
- |
{{.SHELL}} -Command "Remove-Item -Path build/azure-*,dist/azure-* -Recurse -Force"

View File

@ -1,40 +0,0 @@
version: '3'
tasks:
build:
desc: Build Forest artifacts
deps: [rewrite]
cmds:
- defer: { task: restore }
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [forest-light, forest-dark]
cmd: poetry run pyinstaller --noconfirm --distpath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} spec/forest/{{.ITEM.THEME}}-{{.ITEM.KIND}}.spec
rewrite:
internal: true
desc: Run the source code rewriter
cmds:
- poetry run python tools/rewriter.py --rewrite --theme {{.THEME}}
restore:
internal: true
desc: Restore the backup files
cmds:
- poetry run python tools/rewriter.py --restore
compress:
desc: Compress Forest artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [forest-light, forest-dark]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} -DestinationPath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}}.zip -Force"'
clean:
desc: Clean build and dist directories
cmds:
- |
{{.SHELL}} -Command "Remove-Item -Path build/forest-*,dist/forest-* -Recurse -Force"

View File

@ -1,24 +0,0 @@
version: '3'
tasks:
build:
desc: Build Sunvalley artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: poetry run pyinstaller --noconfirm --distpath dist/sunvalley-{{.ITEM.KIND}} spec/sunvalley/sunvalley-{{.ITEM.KIND}}.spec
compress:
desc: Compress Sunvalley artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/sunvalley-{{.ITEM.KIND}} -DestinationPath dist/sunvalley-{{.ITEM.KIND}}.zip -Force"'
clean:
desc: Clean build and dist directories
cmds:
- |
{{.SHELL}} -Command "Remove-Item -Path build/sunvalley-*,dist/sunvalley-* -Recurse -Force"

View File

@ -1,19 +1,5 @@
version: '3'
includes:
sunvalley:
taskfile: ./Taskfile.sunvalley.yml
vars:
THEME: sunvalley
forest:
taskfile: ./Taskfile.forest.yml
vars:
THEME: forest
azure:
taskfile: ./Taskfile.azure.yml
vars:
THEME: azure
vars:
SHELL: pwsh
@ -33,23 +19,63 @@ tasks:
build:
desc: Build all artifacts
cmds:
- for:
matrix:
THEME: [sunvalley, forest, azure]
task: '{{.ITEM.THEME}}:build'
- task: build-sunvalley
- echo "Sunvalley build complete"
- task: build-forest
- echo "Forest build complete"
compress:
desc: Compress all artifacts
build-sunvalley:
desc: Build Sunvalley artifacts
cmds:
- for:
matrix:
THEME: [sunvalley, forest, azure]
task: '{{.ITEM.THEME}}:compress'
KIND: [basic, banana, potato]
cmd: poetry run pyinstaller --noconfirm --distpath dist/sunvalley-{{.ITEM.KIND}} spec/sunvalley-{{.ITEM.KIND}}.spec
build-forest:
desc: Build Forest artifacts
deps: [rewrite]
cmds:
- defer: { task: restore }
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [light, dark]
cmd: poetry run pyinstaller --noconfirm --distpath dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}} spec/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}}.spec
rewrite:
internal: true
desc: Run the source code rewriter
cmds:
- poetry run python tools/rewriter.py --rewrite
restore:
internal: true
desc: Restore the backup files
cmds:
- poetry run python tools/rewriter.py --restore
compress:
deps: [compress-sunvalley, compress-forest]
compress-sunvalley:
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/sunvalley-{{.ITEM.KIND}} -DestinationPath dist/sunvalley-{{.ITEM.KIND}}.zip -Force"'
compress-forest:
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [light, dark]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}} -DestinationPath dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}}.zip -Force"'
clean:
desc: Clean up build and dist directories
cmds:
- for:
matrix:
THEME: [sunvalley, forest, azure]
task: '{{.ITEM.THEME}}:clean'
- |
{{.SHELL}} -Command "
Remove-Item -Path build/forest-*,build/sunvalley-*,dist/forest-*,dist/sunvalley-* -Recurse -Force"

View File

@ -1,9 +1,10 @@
# load a specific profile on start (file name without .toml ext)
# [configs]
# config="example"
# load with themes enabled?
# load with themes enabled? set the default mode
[theme]
enabled = true
mode = "light"
# load in extended mode? if so which orientation
[extends]
extended = true
@ -21,4 +22,4 @@ size = 3
default = 0
# show the navigation frame?
[navigation]
show = false
show = true

View File

@ -2,12 +2,12 @@
### set the ip then uncomment
# [connection-1]
# kind = 'banana'
# ip = 'localhost'
# ip = '<ip address 1>'
# streamname = 'Command1'
# port = 6980
# [connection-2]
# kind = 'potato'
# ip = 'gamepc.local'
# ip = '<ip address 2>'
# streamname = 'Command1'
# port = 6980

View File

@ -16,7 +16,7 @@ def write_outs(output, outs: tuple):
output.write(out)
def rewrite_app(theme):
def rewrite_app():
app_logger = logger.getChild('app')
app_logger.info('rewriting app.py')
infile = Path(SRC_DIR) / 'app.bk'
@ -34,28 +34,24 @@ def rewrite_app(theme):
(
' self._vmr = vmr\n',
' self._theme = theme\n',
' self._theme_name = theme.split("-")[0]\n',
' self._theme_type = theme.split("-")[-1]\n',
' tcldir = Path.cwd() / "theme"\n',
' if not tcldir.is_dir():\n',
' tcldir = Path.cwd() / "_internal" / "theme"\n',
' match self._theme_name:\n',
' case "forest":\n',
' self.tk.call("source", tcldir.resolve() / f"{self._theme}.tcl")\n',
' case "azure":\n',
' self.tk.call("source", tcldir.resolve() / f"{self._theme_name}.tcl")\n',
' self.tk.call("source", tcldir.resolve() / f"forest-{self._theme}.tcl")\n',
),
)
# def connect()
case 'def connect(kind_id: str, vmr) -> App:\n':
output.write('def connect(kind_id: str, vmr, theme) -> App:\n')
output.write(
'def connect(kind_id: str, vmr, theme="light") -> App:\n'
)
case ' return VMMIN_cls(vmr)\n':
output.write(' return VMMIN_cls(vmr, theme)\n')
case _:
output.write(line)
def rewrite_builders(theme):
def rewrite_builders():
builders_logger = logger.getChild('builders')
builders_logger.info('rewriting builders.py')
infile = Path(SRC_DIR) / 'builders.bk'
@ -75,24 +71,13 @@ def rewrite_builders(theme):
case 'import sv_ttk\n':
output.write('#import sv_ttk\n')
case ' self.app.resizable(False, False)\n':
if theme.startswith('forest'):
write_outs(
output,
(
' self.app.resizable(False, False)\n'
' if _configuration.themes_enabled:\n',
' ttk.Style().theme_use(self.app._theme)\n',
' self.logger.info(f"{self.app._theme} Theme applied")\n',
),
)
elif theme.startswith('azure'):
write_outs(
output,
(
' self.app.resizable(False, False)\n'
' if _configuration.themes_enabled:\n',
' self.app.tk.call("set_theme", self.app._theme_type)\n',
' self.logger.info(f"Azure {self.app._theme_type} Theme applied")\n',
' ttk.Style().theme_use(f"forest-{self.app._theme}")\n',
' self.logger.info(f"Forest Theme applied")\n',
),
)
ignore_next_lines = 6
@ -186,21 +171,12 @@ def rewrite_builders(theme):
)
case _:
if 'Toggle.TButton' in line:
if theme.startswith('forest'):
output.write(
line.replace('Toggle.TButton', 'ToggleButton')
)
elif theme.startswith('azure'):
output.write(
line.replace(
'Toggle.TButton', 'Switch.TCheckbutton'
)
)
output.write(line.replace('Toggle.TButton', 'ToggleButton'))
else:
output.write(line)
def rewrite_menu(theme):
def rewrite_menu():
menu_logger = logger.getChild('menu')
menu_logger.info('rewriting menu.py')
infile = Path(SRC_DIR) / 'menu.bk'
@ -223,7 +199,7 @@ def rewrite_menu(theme):
output.write(line)
def prepare_for_build(theme):
def prepare_for_build():
################# MOVE FILES FROM PACKAGE DIR INTO SRC DIR #########################
for file in (
PACKAGE_DIR / 'app.py',
@ -235,8 +211,12 @@ def prepare_for_build(theme):
file.rename(SRC_DIR / f'{file.stem}.bk')
###################### RUN THE FILE REWRITER FOR EACH *.BK #########################
for step in (rewrite_app, rewrite_builders, rewrite_menu):
step(theme)
steps = (
rewrite_app,
rewrite_builders,
rewrite_menu,
)
[step() for step in steps]
def cleanup():
@ -259,13 +239,12 @@ def cleanup():
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--rewrite', action='store_true')
parser.add_argument('--theme', type=str, default='forest')
parser.add_argument('--restore', action='store_true')
args = parser.parse_args()
if args.rewrite:
logger.info('preparing files for build')
prepare_for_build(args.theme)
prepare_for_build()
elif args.restore:
logger.info('cleaning up files')
cleanup()

View File

@ -60,7 +60,7 @@ _defaults = {
'submixes': {
'default': 0,
},
'navigation': {'show': False},
'navigation': {'show': True},
}

View File

@ -357,17 +357,15 @@ class Menus(tk.Menu):
opts = {}
opts |= self.vban_config[f'connection-{i + 1}']
kind_id = opts.pop('kind')
if 'ip' in opts:
opts['host'] = opts.pop('ip')
self.vban = vban_cmd.api(kind_id, **opts)
# login to vban interface
try:
self.logger.info(f'Attempting vban connection to {opts.get("host")}')
self.logger.info(f'Attempting vban connection to {opts.get("ip")}')
self.vban.login()
except VBANCMDConnectionError as e:
self.vban.logout()
msg = (
f'Timeout attempting to establish connection to {opts.get("host")}',
f'Timeout attempting to establish connection to {opts.get("ip")}',
'Please check your connection settings',
)
messagebox.showerror('Connection Error', '\n'.join(msg))