Skip to content

Commit

Permalink
Merge pull request #2 from dabecart/dev
Browse files Browse the repository at this point in the history
Fixed linux fatal error (dev to main)
  • Loading branch information
dabecart authored Aug 12, 2024
2 parents 981a8bf + 9a880e9 commit d5391e9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,30 @@ This project uses the following libraries:
- To export test cases to `.xlsl` files I use [openpyxl](https://openpyxl.readthedocs.io/en/stable/), version 3.1.5.
- To bundle the program as an executable file: [PyInstaller](https://pyinstaller.org/en/stable/), version 6.10.0.

You can use this command to install everything:

```
$ python3 -m pip install PyQt6 pyqtdarktheme openpyxl pyinstaller
```

The project was built and tested on Python 3.10.8 64-bits.

# To bundle as an executable

Run the following:

```
pyinstaller --onefile -w -i res/Logo.ico -n VVT src/Main.py
pyinstaller --onefile -w -i res/Logo.ico -n VVT src/Main.py --exclude PySide6
```

The last exclude is optional, it's in case you also have installed PySide6 on your environment.

# Developing on Linux

To run the Python program in Linux (WSL), I had to install the following packages:

```
$ apt-get install ffmpeg libsm6 libxext6 libgl1-mesa-dev
```

*This is a work in progress.*
*This project is a work in progress.*
2 changes: 2 additions & 0 deletions src/BuildWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ def onException(e: Exception):
for arg in e.cmd:
detailMessage += str(arg) + " "
detailMessage += f'\nReturn code: {e.returncode}\nError output: {e.stderr.decode("utf-8")}'
else:
detailMessage += str(e)

QMessageBox.critical(self, 'Fatal error while running test',
f'A fatal error occurred. {detailMessage}')
Expand Down
31 changes: 21 additions & 10 deletions src/DataFields.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from time import perf_counter
from ast import literal_eval
from re import sub
import os

from datetime import datetime

Expand Down Expand Up @@ -279,20 +280,30 @@ def test(self):
# May throw a CalledProcessError exception in case the command is not OK.
def _execute(self, resultOutputSave):
commandArgs = shlex.split(self.runcode)
# So that the windowed application doesn't open a terminal to run the code.
# So that the windowed application doesn't open a terminal to run the code on Windows (nt).
# Taken from here:
# https://code.activestate.com/recipes/409002-launching-a-subprocess-without-a-console-window/
startupInfo = subprocess.STARTUPINFO()
startupInfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
if os.name == 'nt':
startupInfo = subprocess.STARTUPINFO()
startupInfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

for _ in range(self.repetitions):
tOfExec = datetime.now().strftime("%d/%m/%Y %H:%M:%S.%f")
startTime = perf_counter()
runResult = subprocess.run(commandArgs,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
cwd = Item.runningDirectory,
startupinfo = startupInfo)
executionTime = perf_counter() - startTime
if os.name == 'nt':
startTime = perf_counter()
runResult = subprocess.run(commandArgs,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
cwd = Item.runningDirectory,
startupinfo = startupInfo)
executionTime = perf_counter() - startTime
else:
startTime = perf_counter()
runResult = subprocess.run(commandArgs,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
cwd = Item.runningDirectory)
executionTime = perf_counter() - startTime

# Taken from here:
# https://stackoverflow.com/questions/24849998/how-to-catch-exception-output-from-python-subprocess-check-output
Expand Down
4 changes: 3 additions & 1 deletion src/TestWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ def onException(e: Exception):
for arg in e.cmd:
detailMessage += str(arg) + " "
detailMessage += f'\nReturn code: {e.returncode}\nError output: {e.stderr.decode("utf-8")}'

else:
detailMessage += str(e)

QMessageBox.critical(self, 'Fatal error while running test',
f'A fatal error occurred. {detailMessage}')

Expand Down

0 comments on commit d5391e9

Please sign in to comment.