Add a window with pywebview and an application shortcut

This commit is contained in:
Torsten Grote 2017-09-20 15:23:04 -03:00
parent 914b6d33cb
commit e2f05268c9
No known key found for this signature in database
GPG Key ID: 3E5F77D92CF891FF
13 changed files with 122 additions and 15 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ debian/debhelper-build-stamp
debian/files
debian/repomaker*
!debian/repomaker.links
!debian/repomaker.install
node_modules/

4
debian/changelog vendored
View File

@ -1,5 +1,5 @@
repomaker (0.0.2a) unstable; urgency=low
repomaker (0.0.4) unstable; urgency=low
* Initial public release
-- Torsten Grote <t at grobox.de> Fri, 28 Jul 2017 18:00:00 +0000
-- Torsten Grote <t at grobox.de> Thu, 21 Sep 2017 12:00:00 +0000

2
debian/control vendored
View File

@ -6,7 +6,7 @@ Standards-Version: 4.0.0
Build-Depends: debhelper (>= 9), python3, python3-dev, dh-virtualenv (>= 1.0)
Package: repomaker
Depends: python3-bleach, python3-cryptography (>= 1.4.0), python3-django, python3-django-compressor, python3-qrcode, python3-six (>= 1.9), aapt, apksigner, libmagic1, openjdk-8-jdk, git (>= 2.3.0), rsync
Depends: python3-bleach, python3-cryptography (>= 1.4.0), python3-django, python3-django-compressor, python3-qrcode, python3-six (>= 1.9), python3-magic, python3-pyqt5.qtwebengine, python3-pyqt5.qtwebkit, aapt, apksigner, libmagic1, openjdk-8-jdk, git (>= 2.3.0), rsync
Section: python
Architecture: all
Description: Create F-Droid repositories with ease

8
debian/data/repomaker.desktop vendored Normal file
View File

@ -0,0 +1,8 @@
[Desktop Entry]
Name=Repomaker
Comment=Create F-Droid repositories with ease
Exec=repomaker
Terminal=false
Type=Application
Icon=repomaker.png
Categories=Development;Utility;

BIN
debian/data/repomaker.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

2
debian/repomaker.install vendored Normal file
View File

@ -0,0 +1,2 @@
debian/data/repomaker.desktop usr/share/applications/
debian/data/repomaker.png usr/share/pixmaps/

View File

@ -1,2 +1,3 @@
/opt/venvs/repomaker/bin/repomaker /usr/bin/repomaker
/opt/venvs/repomaker/bin/repomaker-server /usr/bin/repomaker-server
/opt/venvs/repomaker/bin/repomaker-tasks /usr/bin/repomaker-tasks

11
debian/requirements.txt vendored Normal file
View File

@ -0,0 +1,11 @@
# These requirements are not yet in Debian
fdroidserver==0.8
#git+https://gitlab.com/grote/fdroidserver.git@686c7423623035fc37dff26ff51e8aeccea9ba27#egg=fdroidserver
django-background-tasks>=1.1.9
django-sass-processor
django-allauth
django-hvad>=1.8.0
django-tinymce
django-js-reverse
apache-libcloud>=2.0.0
pywebview

4
debian/rules vendored
View File

@ -4,4 +4,6 @@
dh $@ --with python-virtualenv
override_dh_virtualenv:
LC_ALL=C.UTF-8 dh_virtualenv --python /usr/bin/python3 --use-system-packages --upgrade-pip
LC_ALL=C.UTF-8 dh_virtualenv --python /usr/bin/python3 --use-system-packages --upgrade-pip \
--extra-pip-arg "--cache-dir=/tmp" \
--requirements debian/requirements.txt

84
repomaker/gui.py Normal file
View File

@ -0,0 +1,84 @@
import logging
import subprocess
import time
from threading import Thread
import repomaker
import requests
import webview
URL = 'http://127.0.0.1:8000/'
WAIT_BEFORE_TASKS = 30 # number of seconds to wait before starting background tasks
logger = logging.getLogger(__name__)
# multi-thread access
task_process = None
terminate = False
def main():
global task_process # pylint: disable=global-statement
# create window
t_window = Thread(target=create_window)
t_window.start()
# show loading screen
webview.load_html(get_loading_screen())
double_instance = server_started()
if not double_instance:
# start web server
logger.debug("Starting server")
t = Thread(target=repomaker.runserver)
t.daemon = True
t.start()
# wait for server to start
while not server_started():
if not t.is_alive():
logging.error('Repomaker webserver could not be started.')
return
time.sleep(0.1)
# load repomaker into webview
webview.load_url(URL)
if not double_instance:
# wait and then start the background tasks
for i in range(0, WAIT_BEFORE_TASKS):
if terminate:
return
time.sleep(1)
if not terminate:
# this needs to run as its own process
task_process = subprocess.Popen(['repomaker-tasks'])
def create_window():
global terminate # pylint: disable=global-statement
try:
webview.config["USE_QT"] = True # use Qt instead of Gtk for webview
webview.create_window("Repomaker", confirm_quit=True)
terminate = True
finally:
# halt background tasks
if task_process is not None:
task_process.terminate()
def get_loading_screen():
return """
<body>
<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;">
<h1 style="font-size:500%;font-family:Roboto;">Loading...</h1>
</div>
</body>
"""
def server_started():
try:
return requests.head(URL).status_code == requests.codes.OK
except Exception:
return False

2
requirements-gui.txt Normal file
View File

@ -0,0 +1,2 @@
-r requirements.txt
pywebview[qt5]

View File

@ -1,16 +1,7 @@
fdroidserver>=0.8
#git+https://gitlab.com/grote/fdroidserver.git@686c7423623035fc37dff26ff51e8aeccea9ba27#egg=fdroidserver
django
django-background-tasks>=1.1.9
-r debian/requirements.txt
django-compressor
django-sass-processor
django-allauth
django-hvad>=1.8.0
django-tinymce
django-js-reverse
qrcode
six>=1.9 # until bleach depends on html5lib>=1.0
bleach
python-magic
apache-libcloud>=2.0.0rc2
cryptography>=1.4.0

View File

@ -41,6 +41,9 @@ setup(
# You can install these using the following syntax, for example:
# $ pip install -e .[dev,test]
extras_require={
'gui': [
'pywebview[qt5]',
],
'test': [
'pep8',
'coverage',
@ -59,6 +62,8 @@ setup(
'repomaker-server = repomaker:runserver',
'repomaker-tasks = repomaker:process_tasks',
],
# TODO 'gui_scripts': []
'gui_scripts': [
'repomaker = repomaker.gui:main',
],
},
)