1

Removed UPX for faster loading. Fixed non existing region value interpretation. Fixed crash on Windows lock. Fixed race condition on number interpretation.

This commit is contained in:
Ventilaar 2024-01-19 00:44:15 +01:00
parent dfd7dfa5f0
commit 2af98808e0
No known key found for this signature in database
3 changed files with 77 additions and 51 deletions

Binary file not shown.

@ -1,5 +1,5 @@
@echo off
pyinstaller --clean --splash logo_s.png --onefile --upx-dir=c:\tools\upx-4.2.2-win64 .\makkelijk_rapport.py
pyinstaller --clean --splash logo_s.png --onefile .\makkelijk_rapport.py
rd /S /Q build
del /F /Q makkelijk_rapport.spec
pause

@ -1,5 +1,7 @@
import pyperclip
import pyi_splash
from time import sleep
from sys import exit
gebied = ['FUS', 'BLK', 'DBP', 'DKW', 'KKP', 'PAL'] # positioning matters for excel sheet!
@ -11,13 +13,13 @@ def check_correct_copy(clip):
# check if copied correctly
if clip[0:3] == '000':
return True
print('!!! You copied the menu incorrectly. See https://git.ventilaar.nl/ventilaar/random-scripts/src/branch/master/makkelijk_uurlijks_rapport/kopie_voorbeeld.png for an example !!!')
print('!!! Incorrect copy, please start at 000 and finish at PAL colli !!!')
return False
def nested_list_from_bare_copy(clip):
# create nested list with values based on position
cliplines = []
try:
for x in clip.split('\r\n'): # voor elke nieuwe regel
line = [] # lege regel aanmaken
@ -34,6 +36,9 @@ def nested_list_from_bare_copy(clip):
cliplines.append(line) # regel is compleet toevoegen aan geneste lijst
return cliplines # geneste lijst teruggeven
except IndexError:
print('!!! Incorrect copy, please start at 000 and finish at PAL colli !!!')
return False
def nested_list_to_dict(clip):
# create dictionary based on gebied for a better overview of the data
@ -41,6 +46,7 @@ def nested_list_to_dict(clip):
data['totaal_colli'] = 0
colli = 0
try:
for x in clip: # voor elke gebied
if x[2] in gebied: # als gebied van ons is
if len(x) != 8: # totaal aantal colomen kloppen niet iets is fout gegeaan in nested_list_from_bare_copy()
@ -54,38 +60,58 @@ def nested_list_to_dict(clip):
return data
except IndexError:
print('!!! Incorrect copy, please start at 000 and finish at PAL colli !!!')
return False
def generate_clipboard(data):
# generate clipboard
copyhand = '' # start met een leeg hand
for x in gebied: # voor elk gebied
if x not in data and x == 'PAL': # Pallet gebied komt vandaag (nog) niet voor
copyhand = f"{copyhand}0\t0\t" # Zet hand bij pallet gebied op 0
if x not in data: # Gebied komt morgen (nog) niet voor
copyhand = f"{copyhand}0\t0\t" # Zet hand bij (nog) niet voorkomend gebied op 0
else:
copyhand = f"{copyhand}{data[x]['gedaan']}\t{data[x]['tedoen']}\t" # voeg de juiste data toe in de hand
return f"{copyhand}{data['totaal_colli']}" # compleet ingevuld regel
return f"{copyhand}{data['totaal_colli']}" # hand afsluiten met totaal colli
if __name__ == '__main__':
print('Listening for new clipboard updates. When you hear a bell you copied correctly, the resulting conversion has replaced your clipboard')
pyi_splash.close()
while True:
def main():
try:
paste = pyperclip.waitForNewPaste()
if not check_correct_copy(paste):
continue
return
copyhand = generate_clipboard(nested_list_to_dict(nested_list_from_bare_copy(paste)))
nested_list = nested_list_from_bare_copy(paste)
if not nested_list:
return
nested_dict = nested_list_to_dict(nested_list)
if not nested_dict:
return
copyhand = generate_clipboard(nested_dict)
print(copyhand)
pyperclip.copy(copyhand)
ring_the_bell()
except KeyboardInterrupt:
print('Exiting')
exit(0)
if __name__ == '__main__':
print('Welcome to the easy copy tool version 2.1!')
print('Listening for copy events, when you copy correctly a bell will ring.')
print('')
print('Copy example: https://git.ventilaar.nl/ventilaar/random-scripts/src/branch/master/makkelijk_uurlijks_rapport/kopie_voorbeeld.png')
print('Source code: https://git.ventilaar.nl/ventilaar/random-scripts/src/branch/master/makkelijk_uurlijks_rapport')
print('-'*79)
pyi_splash.close()
while True:
try:
main()
except pyperclip.PyperclipWindowsException:
print('Windows is locked, retrying clipboard monitoring in 6 seconds')
sleep(6)