Add Rest
This commit is contained in:
parent
f60ad9b9ad
commit
90b1b125c0
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build/
|
||||
dist/
|
37
appmanager/Projects Manager.spec
Normal file
37
appmanager/Projects Manager.spec
Normal file
@ -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,
|
||||
)
|
98
appmanager/projects.py
Normal file
98
appmanager/projects.py
Normal file
@ -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...')
|
21
buildapp.bat
Normal file
21
buildapp.bat
Normal file
@ -0,0 +1,21 @@
|
||||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
set "RESET=[0m"
|
||||
set "BLUE=[1;34m"
|
||||
set "GREEN=[1;32m"
|
||||
set "RED=[1;31m"
|
||||
set "YELLOW=[1;33m"
|
||||
set "WHITE=[1;37m"
|
||||
|
||||
echo %BLUE%Buiding app%RESET%
|
||||
|
||||
cd ./appmanager/
|
||||
|
||||
pyinstaller --onefile projects.py --name "Projects Manager"
|
||||
|
||||
cd ..
|
||||
|
||||
echo %GREEN%App built%RESET%
|
||||
|
||||
pause
|
44
files/GetRequirements.bat
Normal file
44
files/GetRequirements.bat
Normal file
@ -0,0 +1,44 @@
|
||||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
set "RESET=[0m"
|
||||
set "BLUE=[1;34m"
|
||||
set "GREEN=[1;32m"
|
||||
set "RED=[1;31m"
|
||||
set "YELLOW=[1;33m"
|
||||
set "WHITE=[1;37m"
|
||||
|
||||
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
|
37
projects.spec
Normal file
37
projects.spec
Normal file
@ -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,
|
||||
)
|
Loading…
Reference in New Issue
Block a user