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:
parent
dfd7dfa5f0
commit
2af98808e0
makkelijk_uurlijks_rapport
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
@echo off
|
@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
|
rd /S /Q build
|
||||||
del /F /Q makkelijk_rapport.spec
|
del /F /Q makkelijk_rapport.spec
|
||||||
pause
|
pause
|
@ -1,5 +1,7 @@
|
|||||||
import pyperclip
|
import pyperclip
|
||||||
import pyi_splash
|
import pyi_splash
|
||||||
|
from time import sleep
|
||||||
|
from sys import exit
|
||||||
|
|
||||||
gebied = ['FUS', 'BLK', 'DBP', 'DKW', 'KKP', 'PAL'] # positioning matters for excel sheet!
|
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
|
# check if copied correctly
|
||||||
if clip[0:3] == '000':
|
if clip[0:3] == '000':
|
||||||
return True
|
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
|
return False
|
||||||
|
|
||||||
def nested_list_from_bare_copy(clip):
|
def nested_list_from_bare_copy(clip):
|
||||||
# create nested list with values based on position
|
# create nested list with values based on position
|
||||||
cliplines = []
|
cliplines = []
|
||||||
|
try:
|
||||||
for x in clip.split('\r\n'): # voor elke nieuwe regel
|
for x in clip.split('\r\n'): # voor elke nieuwe regel
|
||||||
line = [] # lege regel aanmaken
|
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
|
cliplines.append(line) # regel is compleet toevoegen aan geneste lijst
|
||||||
|
|
||||||
return cliplines # geneste lijst teruggeven
|
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):
|
def nested_list_to_dict(clip):
|
||||||
# create dictionary based on gebied for a better overview of the data
|
# 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
|
data['totaal_colli'] = 0
|
||||||
colli = 0
|
colli = 0
|
||||||
|
|
||||||
|
try:
|
||||||
for x in clip: # voor elke gebied
|
for x in clip: # voor elke gebied
|
||||||
if x[2] in gebied: # als gebied van ons is
|
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()
|
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
|
return data
|
||||||
|
|
||||||
|
except IndexError:
|
||||||
|
print('!!! Incorrect copy, please start at 000 and finish at PAL colli !!!')
|
||||||
|
return False
|
||||||
|
|
||||||
def generate_clipboard(data):
|
def generate_clipboard(data):
|
||||||
# generate clipboard
|
# generate clipboard
|
||||||
copyhand = '' # start met een leeg hand
|
copyhand = '' # start met een leeg hand
|
||||||
|
|
||||||
for x in gebied: # voor elk gebied
|
for x in gebied: # voor elk gebied
|
||||||
if x not in data and x == 'PAL': # Pallet gebied komt vandaag (nog) niet voor
|
if x not in data: # Gebied komt morgen (nog) niet voor
|
||||||
copyhand = f"{copyhand}0\t0\t" # Zet hand bij pallet gebied op 0
|
copyhand = f"{copyhand}0\t0\t" # Zet hand bij (nog) niet voorkomend gebied op 0
|
||||||
else:
|
else:
|
||||||
copyhand = f"{copyhand}{data[x]['gedaan']}\t{data[x]['tedoen']}\t" # voeg de juiste data toe in de hand
|
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
|
||||||
|
|
||||||
|
def main():
|
||||||
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:
|
|
||||||
try:
|
try:
|
||||||
paste = pyperclip.waitForNewPaste()
|
paste = pyperclip.waitForNewPaste()
|
||||||
if not check_correct_copy(paste):
|
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)
|
print(copyhand)
|
||||||
pyperclip.copy(copyhand)
|
pyperclip.copy(copyhand)
|
||||||
ring_the_bell()
|
ring_the_bell()
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('Exiting')
|
print('Exiting')
|
||||||
exit(0)
|
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)
|
Loading…
x
Reference in New Issue
Block a user