Skip to content

Commit

Permalink
Powershell test
Browse files Browse the repository at this point in the history
  • Loading branch information
mediocreatmybest committed Aug 28, 2023
1 parent 7faf5c8 commit 0ff46c6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
4 changes: 2 additions & 2 deletions start_ui.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
if exist .\venv\Scripts\activate.bat (
call .\venv\Scripts\activate.bat
echo Using venv...
streamlit run webui.py
streamlit run --server.address localhost webui.py
) else (
echo Virtual environment not found, trying to launch anyway...
streamlit run webui.py
streamlit run --server.address localhost webui.py
)
4 changes: 2 additions & 2 deletions start_ui.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
$venv_path = ".\venv\Scripts\Activate"
if (Test-Path -Path $venv_path) {
& $venv_path
streamlit run webui.py
streamlit run --server.address localhost webui.py
} else {
Write-Output "Virtual environment not found, trying to launch anyway..."
streamlit run webui.py
streamlit run --server.address localhost webui.py
}
4 changes: 2 additions & 2 deletions start_ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ venv_path="./venv/bin/activate"

if [ -f "$venv_path" ]; then
source $venv_path
streamlit run webui.py
streamlit run --server.address localhost webui.py
else
echo "Virtual environment not found, trying to launch anyway..."
streamlit run webui.py
streamlit run --server.address localhost webui.py
fi
23 changes: 16 additions & 7 deletions webui.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
import re
import streamlit as st
import subprocess
from pathlib import Path

import streamlit as st

# Global dictionary for accepted script types and their interpreters
script_types = {
'Python': {
Expand All @@ -17,10 +19,10 @@
'extensions': ['.bat', '.cmd'],
'interpreter': 'cmd /c'
},
# 'PowerShell': {
# 'extensions': ['.ps1'],
# 'interpreter': 'powershell'
# }
'PowerShell': {
'extensions': ['.ps1'],
'interpreter': 'powershell'
}
}

def extract_arguments(script_content, script_type=None):
Expand Down Expand Up @@ -288,8 +290,15 @@ def run_script(script_path, inputs, arguments, script_type, positional_args_orde

# PowerShell script execution
elif script_type == "PowerShell":
# build later
pass
# Execute with additional commands / Using Input as we haven't looked at args yet.
# This is a dict
if 'Input' in inputs:
cmd_line_args = inputs['Input'].split(' ')
# set execution with powershell to list and append
powershell_args = ['-ExecutionPolicy', 'Bypass', '-File']
cmd_args.append(powershell_args)
# Build final command
cmd_args = script_types[script_type]['interpreter'].split() + [str(script_path)] + cmd_line_args

# Final fallback for generic input
# not sure this is working as intended yet as most other scripts don't have args
Expand Down

0 comments on commit 0ff46c6

Please sign in to comment.