Thread: ePUB Optimizer
View Single Post
Old 11-20-2015, 09:58 AM   #69
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,816
Karma: 6000000
Join Date: Nov 2009
Device: many
Hi Toxaris,

I tried your plugin with the Bundled Python 3.4 on Mac OS X and received the following error:

Code:
Status: failed

Traceback (most recent call last):
  File "/Users/kbhend/repo/build/bin/Sigil.app/Contents/plugin_launchers/python/launcher.py", line 135, in launch
    self.exitcode = target_script.run(container)
  File "/Users/kbhend/Library/Application Support/sigil-ebook/sigil/plugins/ePUBOptimizer/plugin.py", line 62, in run
    os.chmod("./osx/gifsicle",0o777)
FileNotFoundError: [Errno 2] No such file or directory: './osx/gifsicle'
Error: [Errno 2] No such file or directory: './osx/gifsicle'
So it appears under Python 3, the cwd is not automatically set to the plugin's location making the relative path used in os.chmod fail.

Here is the very slight change I made and your plugin ran successfully on Mac OS X after this change.

Code:
--- plugin.py.orig	2015-11-20 09:47:07.000000000 -0500
+++ plugin.py	2015-11-20 09:52:59.000000000 -0500
@@ -59,9 +59,9 @@
 
     # ensure excution rights OSX
     if isosx:
-        os.chmod("./osx/gifsicle",0o777)
-        os.chmod("./osx/optipng",0o777)
-        os.chmod("./osx/jpegtran",0o777)
+        os.chmod(os.path.join(SCRIPT_DIR,"osx","gifsicle"),0o744)
+        os.chmod(os.path.join(SCRIPT_DIR,"osx","optipng"),0o744)
+        os.chmod(os.path.join(SCRIPT_DIR,"osx","jpegtran"),0o744)
         
     # create temp folder
     temp_dir = tempfile.mkdtemp()
So when you do your next update, would you please include this change.

Thank you!

KevinH
KevinH is offline   Reply With Quote