epson_print_conf/epson_print_conf.spec

120 lines
3.1 KiB
RPMSpec
Raw Normal View History

2024-07-29 05:13:15 -04:00
# -*- mode: python ; coding: utf-8 -*-
import argparse
2024-08-13 12:01:12 -04:00
import os
import os.path
from PIL import Image, ImageDraw, ImageFont
def create_image(png_file, text):
img = Image.new('RGB', (800, 150), color='black')
fnt = ImageFont.truetype('arialbd.ttf', 30)
d = ImageDraw.Draw(img)
shadow_offset = 2
bbox = d.textbbox((0, 0), text, font=fnt)
x, y = (800-bbox[2])/2, (150-bbox[3])/2
d.text((x+shadow_offset, y+shadow_offset), text, font=fnt, fill='gray')
d.text((x, y), text, font=fnt, fill='#baf8f8')
img.save(png_file, 'PNG')
2024-07-29 05:13:15 -04:00
parser = argparse.ArgumentParser()
parser.add_argument("--default", action="store_true")
options = parser.parse_args()
PROGRAM = [ 'gui.py' ]
2024-08-13 12:01:12 -04:00
BASENAME = 'epson_print_conf'
DATAS = [(BASENAME + '.pickle', '.')]
SPLASH_IMAGE = BASENAME + '.png'
create_image(
SPLASH_IMAGE, 'Epson Printer Configuration tool loading...'
)
if not options.default and not os.path.isfile(DATAS[0][0]):
print("\nMissing file", DATAS[0][0], "without using the default option.")
quit()
gui_wrapper = """import pyi_splash
import pickle
from ui import EpsonPrinterUI
from os import path
path_to_pickle = path.abspath(
path.join(path.dirname(__file__), '""" + DATAS[0][0] + """')
)
with open(path_to_pickle, 'rb') as fp:
conf_dict = pickle.load(fp)
app = EpsonPrinterUI(conf_dict=conf_dict, replace_conf=False)
pyi_splash.close()
app.mainloop()
"""
2024-07-29 05:13:15 -04:00
if options.default:
DATAS = []
2024-08-13 12:01:12 -04:00
gui_wrapper = """import pyi_splash
import pickle
from ui import main
from os import path
app = main()
pyi_splash.close()
app.mainloop()
"""
with open(PROGRAM[0], 'w') as file:
file.write(gui_wrapper)
2024-07-29 05:13:15 -04:00
a = Analysis(
PROGRAM,
pathex=[],
binaries=[],
datas=DATAS,
hiddenimports=['babel.numbers'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
2024-08-13 12:01:12 -04:00
splash = Splash(
SPLASH_IMAGE,
binaries=a.binaries,
datas=a.datas,
text_pos=None,
text_size=12,
minify_script=True,
always_on_top=True,
)
2024-07-29 05:13:15 -04:00
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
2024-08-13 12:01:12 -04:00
splash,
splash.binaries,
2024-07-29 05:13:15 -04:00
[],
2024-08-13 12:01:12 -04:00
name=BASENAME,
2024-07-30 02:17:43 -04:00
debug=False, # Setting to True gives you progress messages from the executable (for console=False there will be annoying MessageBoxes on Windows).
2024-07-29 05:13:15 -04:00
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
2024-08-13 12:01:12 -04:00
console=options.default, # On Windows or Mac OS governs whether to use the console executable or the windowed executable. Always True on Linux/Unix (always console executable - it does not matter there).
2024-07-30 02:17:43 -04:00
disable_windowed_traceback=False, # Disable traceback dump of unhandled exception in windowed (noconsole) mode (Windows and macOS only)
2024-08-13 12:01:12 -04:00
hide_console='hide-early', # Windows only. In console-enabled executable, hide or minimize the console window ('hide-early', 'minimize-early', 'hide-late', 'minimize-late')
2024-07-29 05:13:15 -04:00
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
2024-08-13 12:01:12 -04:00
os.remove(SPLASH_IMAGE)
os.remove(PROGRAM[0])