MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   epubcheck plugin for Sigil (https://www.mobileread.com/forums/showthread.php?t=248186)

Doitsu 11-10-2015 08:39 AM

Quote:

Originally Posted by DiapDealer (Post 3203305)
Not to counter your claim that it's working for you with v0.9.0, Doitsu, but... doesn't your plugin use the system PATH to locate the java executable?

You're correct in that it'll only work if the Java executable path has been defined via the Windows PATH environment variable. I.e., if you open a Windows command line prompt and enter, for example, java -version, it should display the version number.
(The actual epubcheck.jar file is in the same folder as plugin.py and is located via Sigil Plugin Launcher functions.)

Whatever the Calibre Open With code does, it doesn't seem to affect the execution of the epubcheck plugin, at least on 64bit Windows 10 machines.

DNSB 11-10-2015 12:31 PM

Quote:

Originally Posted by Doitsu (Post 3203275)
@DNSB: Could you please provide the following information:

OS:
Sigil version:
Installed Python version(s):

Also please indicate whether you've installed the 32bit or 64bit versions of Sigil and Python.

OS: Windows 10 x64 build 10240
Calibre: 2.4.3 x64, multiple plugins
Sigil: 0.9.0 x64
Installed Python: 2.7 32 bit and 3.4.3 64 bit

The 32 bit version is needed when I use a 3D printer.

To do some testing, I booted up an Insider Preview Windows 10 VM.

OS: Windows 10 x64 build 10576 running under VMWare Workstation
Calibre: 2.4.3 x64 with Open With and Kobo Utilities plugins
Sigil: 0.9.0 x64
Installed Python: None

Result: Flightcrew works either way, epubcheck works from Sigil when launched from command line but does not work when using the Open With plugin to launch.

Code:

Status: failed

Traceback (most recent call last):
  File "C:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 135, in launch
    self.exitcode = target_script.run(container)
  File "C:\Users\David\AppData\Local\sigil-ebook\sigil\plugins\EpubCheck\plugin.py", line 32, in run
    result = jarWrapper(*args)
  File "C:\Users\David\AppData\Local\sigil-ebook\sigil\plugins\EpubCheck\plugin.py", line 9, in jarWrapper
    process = Popen(list(args), stdout=PIPE, stderr=PIPE)
  File "subprocess.py", line 859, in __init__
  File "subprocess.py", line 1112, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
Error: [WinError 2] The system cannot find the file specified


Doitsu 11-10-2015 01:15 PM

Thanks for the detailed information. I believe you're getting this error message because the plugin can't find the Java executable.

Did you follow the instructions at the bottom of the very first post about adding a path to the Java executable to the Windows PATH environment variable and do you see the version number, if you enter java -version in a command prompt window?

If not, this might be the cause of the problem, because the plugin assumes that the java executable can be found via PATH (or other environment variables).

(I've added the path to the PATH environment variable and have no problems running the epubcheck plugin via Calibre.)

Quote:

Originally Posted by DNSB (Post 3203447)
Result: Flightcrew works either way, epubcheck works from Sigil when launched from command line but does not work when using the Open With plugin to launch.

FlightCrew will always work, because because the FlightCrew binary is in a pre-defined, known location, while the Java binary might be in any number of directories.

Maybe a Calibre plugin developer could develop a Calibre epubcheck plugin for you?

DNSB 11-10-2015 09:38 PM

Quote:

Originally Posted by Doitsu (Post 3203478)
Thanks for the detailed information. I believe you're getting this error message because the plugin can't find the Java executable.

Did you follow the instructions at the bottom of the very first post about adding a path to the Java executable to the Windows PATH environment variable and do you see the version number, if you enter java -version in a command prompt window?

If not, this might be the cause of the problem, because the plugin assumes that the java executable can be found via PATH (or other environment variables).

(I've added the path to the PATH environment variable and have no problems running the epubcheck plugin via Calibre.)

When I ran java -version, it displayed the version. However, this was using Oracle's symlink path. When epubcheck didn't work, I added the direct path to the x64 java as the first item in the PATH variable.

Code:

Original:
Path=C:\ProgramData\Oracle\Java\javapath;

Modified:
Path=C:\Program Files\Java\jre1.8.0_65\bin;C:\ProgramData\Oracle\Java\javapath;

Quote:

Originally Posted by Doitsu (Post 3203478)
FlightCrew will always work, because because the FlightCrew binary is in a pre-defined, known location, while the Java binary might be in any number of directories.

Maybe a Calibre plugin developer could develop a Calibre epubcheck plugin for you?

I've been using a batch file to check epubs so will just continue using that when I need/want to use epubcheck.

DNSB 11-10-2015 10:24 PM

Further on...

I edited the plugin.py file to add the java path to the 'java' item in line 29 and the plugin works when spawning Sigil using Calibre's Open With plugin. So it would appear that the Open With plugin is not passing the path properly.

Code:

args = ['C:\\Program Files\\Java\\jre1.8.0_65\\bin\\java.exe', '-jar', epc_path, temp_dir, '-mode', 'exp']
Admittedly this is not an answer since I don't want to edit plugin.py every couple of weeks.

eschwartz 11-11-2015 11:54 AM

Find the basename of java.exe : https://stackoverflow.com/questions/...s-command-line


Tell Open With to insert the value of that^^ into clean_env['PATH']

DNSB 11-11-2015 01:07 PM

Quote:

Originally Posted by eschwartz (Post 3204036)
Find the basename of java.exe : https://stackoverflow.com/questions/...s-command-line


Tell Open With to insert the value of that^^ into clean_env['PATH']

Unfortunately since the path changes with every Java update, it's going to be the same issue as my adding the path to the .py file—update every Java update.

DNSB 11-11-2015 01:13 PM

Disabling the path removal before launching Sigil from the Open With plugin corrects the issue. So far in opening, editing and validating 10 epubs, I haven't had an issue with Sigil so looks as if that code is not needed for Sigil 0.9.0.

One note is that I am—probably—one of the few people who drag Calibre's Book Detail pane into non-existence so right clicking on the format in that pane to launch Sigil is not an option without adding what I consider to be a waste of precious screen space back into view. As usual, YMMV.

PeterT 11-11-2015 01:14 PM

There has to exist a Windows API (or maybe direct registry queries) to replicate these commands:
Code:

assoc .jar
.jar=jarfile

ftype jarfile
jarfile="C:\Program Files\Java\jre1.8.0_31\bin\javaw.exe" -jar "%1" %*


eschwartz 11-11-2015 02:36 PM

Quote:

Originally Posted by DNSB (Post 3204084)
Unfortunately since the path changes with every Java update, it's going to be the same issue as my adding the path to the .py file—update every Java update.

Perhaps you didn't fully understand what I suggested?

That link provides a way to search the current PATH, and determine what
Code:

C:\> java.exe
resolves to.

There would be no need to manually update either Doitsu's epubcheck plugin OR the calibre Open With plugin, because the calibre plugin is saving the java path before clearing everything else away.


Trust me, :cool: I wasn't suggesting Yet Another Way to manually update it every time, I have no patience for manual updating myself.

...

That being said, using calibre to open a book in Sigil is slightly roundabout, considering calibre has its own builtin Editor...

I'd also like to know why, oh why, does Java feel the need to make highly unpredictable paths, and why has Microsoft never figured out how to provide a decent CLI, but that is getting waaaaaaaaaaaay offtopic.
java is always /usr/bin/java on MY computer. :D

DNSB 11-11-2015 04:43 PM

:D
Quote:

Originally Posted by eschwartz (Post 3204132)
Perhaps you didn't fully understand what I suggested?

That link provides a way to search the current PATH, and determine what
Code:

C:\> java.exe
resolves to.

There would be no need to manually update either Doitsu's epubcheck plugin OR the calibre Open With plugin, because the calibre plugin is saving the java path before clearing everything else away.

Okay, I see what you mean. Unfortunately, I'm not able to modify the Open With Python code to be able to extract the returned path from running a Windows CLI tool. My current solution of removing the path clear from Open With works for now and given the rate of updates to Open With, my only worry is forgetting what the bleep I did to fix the issue before a new version comes out.


Quote:

Originally Posted by eschwartz (Post 3204132)
Trust me, :cool: I wasn't suggesting Yet Another Way to manually update it every time, I have no patience for manual updating myself.

That's what a computer is for -- to do those repetitive tasks.

...

Quote:

Originally Posted by eschwartz (Post 3204132)
That being said, using calibre to open a book in Sigil is slightly roundabout, considering calibre has its own builtin Editor...

Again personal preferences. I've used the Calibre editor and prefer Sigil.

Quote:

Originally Posted by eschwartz (Post 3204132)
I'd also like to know why, oh why, does Java feel the need to make highly unpredictable paths, and why has Microsoft never figured out how to provide a decent CLI, but that is getting waaaaaaaaaaaay offtopic.
java is always /usr/bin/java on MY computer. :D

On my Windows box, it's always C:\ProgramData\Oracle\Java\javapath\ for the latest version. A few versions back Oracle added that symlink which is updated when Java is installed.

As for the unpredictable paths? There are quite a few programs that require a specific version of Java. Some install the Java files within their own directory, other's expect to find the version where the Sun/Oracle installer would place it. I supported Java 1.4.2 for quite a few years after 1.5 and 1.6 were released for that reason.

Anyhow, time to let this thread die since we need the Hubbell to see the topic. :D

BetterRed 11-11-2015 04:43 PM

Quote:

Originally Posted by DNSB (Post 3204086)
One note is that I am—probably—one of the few people who drag Calibre's Book Detail pane into non-existence so right clicking on the format in that pane to launch Sigil is not an option without adding what I consider to be a waste of precious screen space back into view. As usual, YMMV.

@DNSB - You could set a calibre keyboard shortcut for Open With... Sigil, I use Shift 'S' (had it with the Open With PI, now the built-in Open With has it).

BR

eschwartz 11-11-2015 07:39 PM

Quote:

Originally Posted by DNSB (Post 3204203)
On my Windows box, it's always C:\ProgramData\Oracle\Java\javapath\ for the latest version. A few versions back Oracle added that symlink which is updated when Java is installed.

Glory be.
I've had one of those for a long time now...

Quote:

As for the unpredictable paths? There are quite a few programs that require a specific version of Java. Some install the Java files within their own directory, other's expect to find the version where the Sun/Oracle installer would place it. I supported Java 1.4.2 for quite a few years after 1.5 and 1.6 were released for that reason.
Yes, there is always bundling it :rolleyes: of course, old versions are evil. ;)

Quote:

Anyhow, time to let this thread die since we need the Hubbell to see the topic. :D
Very good point.

kovidgoyal 11-11-2015 11:22 PM

Quote:

Originally Posted by BetterRed (Post 3204204)
@DNSB - You could set a calibre keyboard shortcut for Open With... Sigil, I use Shift 'S' (had it with the Open With PI, now the built-in Open With has it).

BR

You can also access the builtin open with functionality by right clicking the view button and choosing view specific format (or right clicking a book entry and choosing that).

davidfor 11-11-2015 11:33 PM

Quote:

Originally Posted by DNSB (Post 3204086)
Disabling the path removal before launching Sigil from the Open With plugin corrects the issue. So far in opening, editing and validating 10 epubs, I haven't had an issue with Sigil so looks as if that code is not needed for Sigil 0.9.0.

Did you just remove the path change, or also change it so that Sigil was opened in the same way as other Windows apps? The other differences were probably about making the PATH removal work, so it will probably work that way.

I'll do a little testing and talk to kiwidude about updating the plugin.


All times are GMT -4. The time now is 06:06 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.