Thread: ImageOptimizer
View Single Post
Old 02-03-2016, 07:57 AM   #12
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,664
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Why not allow the user to override paths to external programs via the prefs json?

Code:
prefs = bk.get_prefs()
#Default to none
if 'jpegtrans_path' not in prefs
    prefs['jpegtran_path'] = None
# Default to false
if 'use_wine' not in prefs
    prefs['use_wine'] = False
Then somewhere in your platform logic:
Code:
islinux = sys.platform.startswith('linux')

if islinux and prefs['jpegtran_path'] is not None:
    exe_path = prefs['jpegtran_path']
else:
    exe_path = 'jpegtran'
if islinux and prefs['use_wine']:
    args = ['wine', path_to_included_windows_exe]
else:
    args = [exe_path]

''' Plugin processing '''

# Need a call to savePrefs so the json file gets created after first run
bk.savePrefs(prefs)
Or something similar. I've not actually looked at the plugin code.

That way the user can just modify the json prefs file to 1) point to a newer version of jpegtran (which I'm betting calibre's is); or 2) use wine to run the included Windows version.

Last edited by DiapDealer; 02-03-2016 at 08:36 AM.
DiapDealer is offline   Reply With Quote