diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5df9179 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +dist/ \ No newline at end of file diff --git a/appmanager/Projects Manager.spec b/appmanager/Projects Manager.spec new file mode 100644 index 0000000..6c5d6c1 --- /dev/null +++ b/appmanager/Projects Manager.spec @@ -0,0 +1,37 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['projects.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='Projects Manager', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) diff --git a/appmanager/projects.py b/appmanager/projects.py new file mode 100644 index 0000000..1b17f8b --- /dev/null +++ b/appmanager/projects.py @@ -0,0 +1,98 @@ +import PySimpleGUI as sg +import http.client + +import json +import webbrowser + +terminal_colors = { + "RESET": "\033[0m", + "RED": "\033[1;31;40m", + "GREEN": "\033[1;32;40m", + "YELLOW": "\033[1;33;40m", + "BLUE": "\033[1;34;40m", +} +terminal_status = { + "ERROR": "RED", + "SUCCESS": "GREEN", + "WARNING": "YELLOW", + "INFO": "BLUE", +} + +def customPrint(text, status): + print_start = f"{terminal_colors[terminal_status[status]]}{status}{terminal_colors['RESET']}: " + print_end = f"{terminal_colors['RESET']}" + print(f"{print_start}{text}{print_end}") + +print("Launching") + +customPrint("Fetching projects", "INFO") +ismpety = False +# GITEA API +repo_name = "alexveebee/py_projects" + +conn = http.client.HTTPSConnection("git.alexveebee.nl") +payload = '' +headers = {} +try: + conn.request("GET", "/api/v1/repos/"+repo_name, payload, headers) + res = conn.getresponse() + data = res.read() + project_list = json.loads(data.decode("utf-8")) + # print(project_list) + customPrint("Fetched projects", "SUCCESS") + # is empty + if project_list["empty"]: + customPrint("No projects found", "WARNING") + ismpety = True +except Exception as e: + customPrint("Unexpected error", "ERROR") + print("Error: ") + print(e) + +def main(): + + # define the window layout + layout = [ + [sg.Text("Project Manager"), sg.Text("Located in: "+repo_name, key="-REPO-", click_submits=True)], + [sg.Text("Select a project to open:")], + # list + [sg.Listbox(values=(), size=(30, 6), key="-PROJECTS-", expand_x=True, expand_y=True)], + [sg.Button("OK", key="-OK-"), sg.Button("Cancel", key="-CANCEL-")], + ] + + # create the window + window = sg.Window("Alex's Projects", layout, size=(300, 500)) + + # create an event loop + while True: + event, values = window.read() + # end program if user closes window or + # presses the OK button + if event == sg.WIN_CLOSED: + break + + if event == "-OK-": + if ismpety: + customPrint("No project found", "WARNING") + else: + customPrint("Opening project", "INFO") + print(values["-PROJECTS-"]) + webbrowser.open_new_tab("https://git.alexveebee.nl/"+repo_name+"/src/branch/master/"+values["-PROJECTS-"][0]) + + if event == "-CANCEL-": + break + + if event == "-REPO-": + webbrowser.open_new_tab("https://git.alexveebee.nl/"+repo_name) + + window.close() + +if __name__ == '__main__': + try: + main() + print("Close") + except Exception as e: + print('Error: ', end='') + print(e) + print() + input('Press Enter to continue...') \ No newline at end of file diff --git a/buildapp.bat b/buildapp.bat new file mode 100644 index 0000000..a1e8576 --- /dev/null +++ b/buildapp.bat @@ -0,0 +1,21 @@ +@echo off +setlocal EnableDelayedExpansion + +set "RESET=" +set "BLUE=" +set "GREEN=" +set "RED=" +set "YELLOW=" +set "WHITE=" + +echo %BLUE%Buiding app%RESET% + +cd ./appmanager/ + +pyinstaller --onefile projects.py --name "Projects Manager" + +cd .. + +echo %GREEN%App built%RESET% + +pause \ No newline at end of file diff --git a/files/GetRequirements.bat b/files/GetRequirements.bat new file mode 100644 index 0000000..ca247d9 --- /dev/null +++ b/files/GetRequirements.bat @@ -0,0 +1,44 @@ +@echo off +setlocal EnableDelayedExpansion + +set "RESET=" +set "BLUE=" +set "GREEN=" +set "RED=" +set "YELLOW=" +set "WHITE=" + +echo %BLUE%Get Requirements%RESET% + +@REM is python installed? +python --version >nul 2>&1 +if %errorlevel% neq 0 ( + echo "python not installed" + winget install -e --id Python.Python + echo %RED%Try launching this script again%RESET% + pause + exit /b 1 +) +echo %GREEN%Python installed%RESET% + +@REM is pip installed? +pip --version >nul 2>&1 +if %errorlevel% neq 0 ( + echo "pip not installed" + + + exit /b 1 +) +echo %GREEN%Pip installed%RESET% + +@REM check if requirements.txt exists +if not exist "requirements.txt" ( + echo "requirements.txt not found" + exit /b 1 +) + +set "file=requirements.txt" + +pip install -r %file% + +pause \ No newline at end of file diff --git a/projects.spec b/projects.spec new file mode 100644 index 0000000..c5a1cf7 --- /dev/null +++ b/projects.spec @@ -0,0 +1,37 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['appmanager\\projects.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='projects', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +)