View Full Version : Mobigen Mobigen return codes / error indications?


UniversalisPub
07-24-2009, 08:55 AM
We publish Universalis, an application that lets you read content directly and can also export it in ePub format. I'd like to extend this so that it exports Mobipocket format also.

I have tried everything by hand, and the workflow "1. Export lightly-seasoned ePub. 2. Run Mobigen on it" works perfectly.

Human beings, however, do not do command lines or directories or command-line utilities, so for them the workflow needs to be automated into a single menu choice, just as we have already done for the ePub format.

My question is: is there an easy way of telling whether a particular mobigen.exe run has succeeded or not, without forcing the user to read and understand all its messages?

For example, is it guaranteed that if an error occurs, a .mobi file will definitely not be created? In that case we could take non-existence of the output file as the error indicator, and if the output file indeed doesn't exist, we can tell the user to read the log to see what happened.

Or perhaps a return code indicates whether or not an error has occurred?

wallcraft
07-24-2009, 10:27 AM
If the MOBI is always DRM-free, then Calibre (http://www.mobileread.com/forums/forumdisplay.php?f=166) is better than mobigen at ePub to MOBI fomat shifting. With the 0.6 version you will also be able to convert to many other formats. If you get an error with mobigen your only realistic option is to change the input ePub to work around it, with Calibre you can report the bug and get is fixed quickly. I don't know how good Calibre's command line error reporting is though.

UniversalisPub
07-25-2009, 03:25 AM
Perhaps I didn't make the workflow clear.

No-one creates the intermediate ePub file. Our program creates it automatically, so it's easy for us to make sure that it's correct. If there's anything wrong with the workflow then we want to know about it so that we can update our program.

No-one runs mobigen. Our program does it automatically and the user never sees it happen.

No doubt a similar workflow could be set up with Calibre, but the same question would need to be asked: how do we know, programmatically, whether a given conversion has worked or not?

HarryT
07-25-2009, 05:10 AM
Presumably you're running Mobigen programmatically. Could you not simply pipe the output into a file and parse the results? Or have you checked the process exit code? Normally, programs return an exit code of "0" on success, and non-zero on failure.

UniversalisPub
07-25-2009, 12:36 PM
Thanks, Harry, I was hoping to get some sort of official answer, but I've experimented, and for anyone else who has the same question, the return code seems to be 0 for success, 1 for warnings, and 2 for errors.

HarryT
07-25-2009, 01:00 PM
That's useful information. Thank you for sharing it with us.

UniversalisPub
07-25-2009, 02:00 PM
The whole thing works brilliantly. The app has a "save to ePub" command, which works directly, and a "save to Mobipocket" command, which appears to work directly but actually creates a modified ePub file and runs it through mobigen.exe.

The user has to download mobigen.exe and copy it into our program folder because the Mobigen people won't let it be redistributed directly.

By the way, timings and file sizes on a 217KB ePub file were:

Mobigen (normal) - 8 seconds for a 394KB .mobi file.
Mobigen (high) - 25 seconds for a 142KB .mobi file.
Calibre - 100 seconds for a 527KB .mobi file.

JSWolf
07-25-2009, 11:43 PM
The whole thing works brilliantly. The app has a "save to ePub" command, which works directly, and a "save to Mobipocket" command, which appears to work directly but actually creates a modified ePub file and runs it through mobigen.exe.

The user has to download mobigen.exe and copy it into our program folder because the Mobigen people won't let it be redistributed directly.

By the way, timings and file sizes on a 700KB ePub file were:

Mobigen (normal) - 8 seconds for a 394KB .mobi file.
Mobigen (high) - 25 seconds for a 142KB .mobi file.
Calibre - 100 seconds for a 527KB .mobi file.
Which version Calibre? If it's not 0.6.0 then you need to specify the --compress option or the resulting file comes out uncompressed.

UniversalisPub
07-26-2009, 04:27 AM
It was 0.6.0, run from the GUI.

ePub file: 217KB
mobigen, high compression: 215KB
mobigen, normal compression: 452KB
Calibre, compression turned on: 1 min 41 sec, 526KB.
Calibre, compression turned off: 1 min 29 sec, 1395KB.

With larger files, mobigen.exe starts to perform a bit better relative to ePub. For example:

ePub file: 849KB
mobigen, high compression: 536KB
mobigen, normal compression: 1520KB
Calibre, compression turned on: 1950KB

ePub file: 9680KB
mobigen, high compression: 4640KB
mobigen, normal compression: 17900KB
Calibre, compression turned on: not tested