refs #464 several fixes and improvements

- fix OG icon in windows system tray
- change a log.info into log.debug to avoid a crash (!)
- migrate update.sh to python so it can be run from windows/macos too
  - manage windows/VERSION in this script too
  - remove call to pyrcc--it's not required!
- remove stray windows scripts
- add a forgotten setup.bat
windows-fixes
Natalia Serrano 2024-06-28 16:02:27 +02:00
parent d7a7a1f0bf
commit 10fab7839e
15 changed files with 100 additions and 79 deletions

2
.gitignore vendored
View File

@ -19,7 +19,7 @@ OGAgentSetup-*.exe
bin
src/about_dialog_ui.py
src/message_dialog_ui.py
src/OGAgent_rc.py
src/dist
src/build
windows/VERSION
windows/VC_redist.x64.exe

View File

@ -39,7 +39,6 @@ install-ogagent:
cp $(SOURCEDIR)/OGAgentUser.py $(LIBDIR)
# QT Dialogs & resources
cp $(SOURCEDIR)/*_ui.py $(LIBDIR)
cp $(SOURCEDIR)/OGAgent_rc.py $(LIBDIR)
# Version file
cp $(SOURCEDIR)/VERSION $(LIBDIR)

View File

@ -1,3 +1,11 @@
ogagent (1.3.1-1) stable; urgency=medium
* Migrate the update script from shell to python
* pyinstaller: include the 'img' subdir
* take icons from 'img'
-- OpenGnsys developers <info@opengnsys.es> Wed, 26 Jun 2024 15:16:57 +0200
ogagent (1.3.0-2) stable; urgency=medium
* Add missing dependency on zenity

0
linux/desktop/OGAgentTool.desktop 100755 → 100644
View File

View File

@ -7,6 +7,7 @@ ogausr_a = Analysis(
binaries=[],
datas=[
# ('cfg', 'cfg'), ## add the entire directory
('img', 'img'), ## add the entire directory
],
hiddenimports=['win32timezone', 'socketserver', 'http.server', 'urllib'],
hookspath=[],

View File

@ -34,6 +34,7 @@ import base64
import json
import sys
import time
import os
from PyQt6 import QtCore, QtGui, QtWidgets
from about_dialog_ui import Ui_OGAAboutDialog
@ -159,7 +160,8 @@ class OGASystemTray(QtWidgets.QSystemTrayIcon):
self.ipcport = int(cfg.get('ipc_port', IPC_PORT))
icon = QtGui.QIcon(':/images/img/oga.png')
QtCore.QDir.addSearchPath('images', os.path.join(os.path.dirname(__file__), 'img'))
icon = QtGui.QIcon('images:oga.png')
QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
self.menu = QtWidgets.QMenu(parent)

View File

@ -1 +1 @@
1.3.0
1.3.1

View File

@ -118,7 +118,7 @@ class HTTPServerHandler(BaseHTTPRequestHandler):
logger.error('HTTP ' + fmt % args)
def log_message(self, fmt, *args):
logger.info('HTTP ' + fmt % args)
logger.debug('HTTP ' + fmt % args)
class HTTPThreadingServer(ThreadingMixIn, HTTPServer):

View File

@ -43,7 +43,7 @@ OTHER, DEBUG, INFO, WARN, ERROR, FATAL = (10000 * (x + 1) for x in range(6))
class LocalLogger(object):
def __init__(self):
# tempdir is different for "user application" and "service"
# service wil get c:\windows\temp, while user will get c:\users\XXX\temp
# service wil get c:\windows\temp, while user will get c:\users\XXX\appdata\local\temp
logging.basicConfig(
filename=os.path.join(tempfile.gettempdir(), 'opengnsys.log'),
filemode='a',

40
src/update.py 100755
View File

@ -0,0 +1,40 @@
#!/usr/bin/python3
import os
import re
import sys
import subprocess
import fileinput
def update_version():
if os.path.isfile ('VERSION'):
with open ('VERSION', 'r') as version_file:
version = version_file.read().strip()
pattern = r'[0-9]*\.[0-9]*\.[0-9]*'
matches = re.findall (pattern, version)
win_version = matches[0]
with fileinput.FileInput ('about-dialog.ui', inplace=True) as file:
for line in file:
print (line.replace ('Version [^<]*', f'Version {version}'), end='')
with fileinput.FileInput ('opengnsys/__init__.py', inplace=True) as file:
for line in file:
print(line.replace ('VERSION=.*', f"VERSION='{version}'"), end='')
with open ('../windows/VERSION', 'w') as outfile:
outfile.write (win_version + '\n')
else:
print ('VERSION: No such file or directory')
sys.exit (1)
def process_ui():
subprocess.run (['pyuic6', 'about-dialog.ui', '-o', 'about_dialog_ui.py', '-x'])
subprocess.run (['pyuic6', 'message-dialog.ui', '-o', 'message_dialog_ui.py', '-x'])
if __name__ == "__main__":
os.chdir (os.path.dirname (os.path.abspath (__file__)))
update_version()
process_ui()

View File

@ -1,58 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2014 Virtual Cable S.L.
# Copyright (c) 2024 Qindel Formación y Servicios S.L.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
function update_version {
if [[ -r VERSION ]]; then
V="$(cat VERSION)"
sed -i "s/Version [^<]*/Version $V/" about-dialog.ui
sed -i "s/^VERSION='.*'$/VERSION='$V'/" opengnsys/__init__.py
else
echo 'src/VERSION: No such file or directory'
exit 1
fi
}
function process_ui {
pyuic6 about-dialog.ui -o about_dialog_ui.py -x
pyuic6 message-dialog.ui -o message_dialog_ui.py -x
}
function process_resources {
## requires a virtualenv with pyside6
## you can create it by doing 'mkvirtualenv -p python3 ogpyside6'
## this will obviously go away in the future, but we need to merge the py3/qt6 change now
~/.virtualenvs/ogpyside6/bin/pyside6-rcc -o OGAgent_rc.py OGAgent.qrc
sed -i -e '/^from PySide6 import QtCore/s/PySide6/PyQt6/' OGAgent_rc.py
}
cd $(dirname "$0")
update_version
process_ui
process_resources

View File

@ -1,7 +0,0 @@
#!/bin/bash
cd "$(dirname "$0")"
export WINEARCH=win32
export WINEPREFIX=$PWD/wine
grep -o "[0-9]*\.[0-9]*\.[0-9]*" ../src/VERSION > VERSION
wine cmd /c c:\\ogagent\\build.bat
chmod -x ../OGAgentSetup*.exe

View File

@ -1,7 +0,0 @@
C:
CD \ogagent\src
python setup.py
CD ..
RENAME bin\OGAgentUser-qt4.exe OGAgentUser.exe
"C:\Program Files\NSIS\makensis.exe" ogagent.nsi

View File

@ -89,7 +89,7 @@ Section -Main SEC0000
SetOutPath $INSTDIR
SetOverwrite on
File /r src\dist\OGAgent\*.*
File windows\setup\VC_redist.x64.exe
File windows\VC_redist.x64.exe
File src\VERSION
WriteRegStr HKLM "${REGKEY}\Components" Main 1
SectionEnd

43
windows/setup.bat 100644
View File

@ -0,0 +1,43 @@
C:
cd \Users\Docker\Downloads
mkdir setup
rem creamos directorio setup, nos bajamos cosas y mas tarde lo borramos
rem pero el VC_redist hace falta para el empaquetado, asi que lo descargamos fuera de setup para no borrarlo
curl https://www.python.org/ftp/python/3.12.3/amd64/core.msi --output setup\core.msi
curl https://www.python.org/ftp/python/3.12.3/amd64/dev.msi --output setup\dev.msi
curl https://www.python.org/ftp/python/3.12.3/amd64/exe.msi --output setup\exe.msi
curl https://www.python.org/ftp/python/3.12.3/amd64/lib.msi --output setup\lib.msi
curl https://www.python.org/ftp/python/3.12.3/amd64/path.msi --output setup\path.msi
curl https://www.python.org/ftp/python/3.12.3/amd64/pip.msi --output setup\pip.msi
curl https://aka.ms/vs/17/release/vc_redist.x64.exe --location --output VC_redist.x64.exe
curl https://prdownloads.sourceforge.net/nsis/nsis-3.05-setup.exe?download --location --output setup\nsis-install.exe
curl http://nsis.sourceforge.net/mediawiki/images/d/d7/NSIS_Simple_Firewall_Plugin_1.20.zip --location --output setup\NSIS_Simple_Firewall_Plugin_1.20.zip
cd setup
msiexec /i core.msi TARGETDIR=C:\Python312
msiexec /i dev.msi TARGETDIR=C:\Python312
msiexec /i exe.msi TARGETDIR=C:\Python312
msiexec /i lib.msi TARGETDIR=C:\Python312
msiexec /i path.msi TARGETDIR=C:\Python312
msiexec /i pip.msi TARGETDIR=C:\Python312
cd ..
VC_redist.x64.exe /install /quiet /passive /norestart
ftype PythonScript=C:\Python312\python.exe "%1" %*
assoc .py=PythonScript
PATH=C:\Python312;C:\Python312\Scripts;%PATH%
setx PATH "C:\Python312;C:\Python312\Scripts;%PATH%"
python -m pip install --upgrade wheel pip
pip install -r F:\src\requirements.txt
setup\nsis-install.exe
powershell -command "Expand-Archive setup\NSIS_Simple_Firewall_Plugin_1.20.zip nsis-fp"
copy nsis-fp\SimpleFC.dll "C:\Program Files (x86)\NSIS\Plugins\x86-ansi\"
copy nsis-fp\SimpleFC.dll "C:\Program Files (x86)\NSIS\Plugins\x86-unicode\"
rmdir nsis-fp /s /q
rmdir setup /s /q