Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 12-03-2014, 08:30 AM   #61
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 4,311
Karma: 14277313
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by turbulent View Post
In an output sigil plugin, is it possible to get the file name of the epub file currently opened by sigil? So it's convinient to name the generated file after the epub file.
If you have a Windows machine, you could use the win32gui library to find the Sigil title bar text. Here's a quick & dirty solution:

Code:
import win32gui
from win32gui import GetWindowText
class_name = 'Qt5QWindowIcon'
window_name = None
hwnd = win32gui.FindWindow(class_name, window_name)

if hwnd:
    print GetWindowText(hwnd)
    # returns 'untitled.epub - Sigil'
Note that this simple code will return the title bar text of the Qt app that was opened last. I.e. if you open multiple Sigil windows, you'll only get the title bar text of the last window and if you open Calibre (or any other Qt5 app) after Sigil, you'll get the Calibre title bar text.

For a more robust solution, you'll need to enumerate all windows using win32gui.EnumWindows.
Doitsu is offline   Reply With Quote
Old 12-03-2014, 10:11 AM   #62
KevinH
Wizard
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: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
Hi,
You can of course get the title from the opf or doctitle from the ncx. One of the routines in the libgui I posted will give you a valid filename from a title, and you can use that to initialize the fileSaveAs gui element and let the user easily specify the location and change the name for your output file.

The ePub3-itizer plugin uses that approach if you are looking for an example.

Kevin
KevinH is offline   Reply With Quote
Advert
Old 12-03-2014, 10:45 AM   #63
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 4,311
Karma: 14277313
Join Date: Dec 2010
Device: Kindle PW2
@KevinH: I also think that the book title would make for a better file name and I use it as the file name in my Kindlegen wrapper. My file name generation method is not as elegant as your method, though, but it works.
I merely mentioned the the win32gui library, because the OP specifically asked for a method of getting the file name.
(Since this method cannot be easily ported to Linux/OSX and all Sigil plugins should ideally work on all three platforms, I wouldn't use it for plugins uploaded to MR.)
Doitsu is offline   Reply With Quote
Old 12-03-2014, 05:52 PM   #64
KevinH
Wizard
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: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
Hi All,

I have updated the first two posts with links to a new pre-release version of the launcher code for Sigil that will support Preferences. All thanks to DiapDealer for designing and implementing these new launcher features!

He has nicely created Plugin examples that illustrate their use. I have included a launcher_updater python program that will install the updates for you. This updater should only be run with stock Sigil 0.8.2.

If you have any questions just ask.

As new features are added to the launcher code, we will periodically making these pre-releases so that plugin developers can more easily test things out before the next Sigil Release is made.

Take care,

KevinH
KevinH is offline   Reply With Quote
Old 12-03-2014, 07:00 PM   #65
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 4,311
Karma: 14277313
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
He has nicely created Plugin examples that illustrate their use. I have included a launcher_updater python program that will install the updates for you. This updater should only be run with stock Sigil 0.8.2.
I've just tested the launcher updater with DiapDealer's inofficial 0.8.2 Linux build and the official 64bit Windows 0.8.2 version. I got a 'Sigil launcher code updated successfully' message, but the Python files in /usr/local/share/sigil/plugin_launchers/python and C:\Program Files\Sigil\plugin_launchers\python weren't updated.
Doitsu is offline   Reply With Quote
Advert
Old 12-03-2014, 07:08 PM   #66
KevinH
Wizard
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: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
Hi Doitsu,

Well that's not good. It works on my Mac OS X build.

On Mac it looks here:

_DIRS_TO_SEARCH.append("/Applications/Sigil.app/Contents/plugin_launchers/python")

On linux it will look in the following locations and can overide via an environment var:

_DIRS_TO_SEARCH.append("/usr/share/sigil/plugin_launchers/python")
_DIRS_TO_SEARCH.append("/usr/local/share/sigil/plugin_launchers/python")
_DIRS_TO_SEARCH.append("/opt/share/sigil/plugin_launchers/python")

On Windows it looks here:
Code:
    programfiles = os.environ.get("ProgramFiles")
    programfilesx86 = os.environ.get("ProgramFiles(x86)")
    if programfiles is not None:
        _DIRS_TO_SEARCH.append(os.path.join(programfiles,"Sigil","plugin_launchers","python"))
    if programfilesx86 is not None:
        _DIRS_TO_SEARCH.append(os.path.join(programfilesx86,"Sigil","plugin_launchers","python"))
Do you need to be admin/root to write to those locations on your machine? If so perhaps the python shutil.copy was simply ignored.

You might try an sudo on Linux to see if that fixes things or being Admin on Linux.

If that doesn't help, your best bet until I figure this out is manually copy the files. Don't forget the completely new file preferences.py.

Kevin


Quote:
Originally Posted by Doitsu View Post
I've just tested the launcher updater with DiapDealer's inofficial 0.8.2 Linux build and the official 64bit Windows 0.8.2 version. I got a 'Sigil launcher code updated successfully' message, but the Python files in /usr/local/share/sigil/plugin_launchers/python and C:\Program Files\Sigil\plugin_launchers\python weren't updated.

Last edited by KevinH; 12-03-2014 at 07:19 PM.
KevinH is offline   Reply With Quote
Old 12-03-2014, 07:14 PM   #67
Doitsu
Wizard
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 4,311
Karma: 14277313
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
Do you need to be admin/root to write to those locations?
Yes on both counts. I even tried to execute Python as a root, but it didn't make a difference.
Doitsu is offline   Reply With Quote
Old 12-03-2014, 07:20 PM   #68
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: 19,199
Karma: 99356142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
@KevinH:

Yeah, it's not copying any files on Windows either.
It's only succeeding because technically ... nothing went wrong.

I've got it narrowed down to the call to unipath.walk("./payload") in __main__.py. It's returning an empty list instead of the files in the payload folder. Is it possible that something's different with accessing a folder "relatively" (./payload) inside a zipfile on Windows/Linux?
DiapDealer is online now   Reply With Quote
Old 12-03-2014, 07:31 PM   #69
KevinH
Wizard
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: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
Hi DiapDealer,

Forget about it. I just tried again and now it doesn't work on Macs either. I bet I ran it once from inside the directory and then tried it after zipping it up and it said successful and I looked and the files were there.

I don't think this is ever going to work the way I want it to.

So can you please try one thing:

Unzip the launcher_updater_20141204.zip but do not cd into it. Then try doing the following:

python launcher_updater_20141204

And yes we are just passing the folder name into python, but that is supposed to work as well. This does work on my Mac.

Kevin

Quote:
Originally Posted by DiapDealer View Post
@KevinH:

Yeah, it's not copying any files on Windows either.
It's only succeeding because technically ... nothing went wrong.

I've got it narrowed down to the call to unipath.walk("./payload") in __main__.py. It's returning an empty list instead of the files in the payload folder. Is it possible that something's different with accessing a folder "relatively" (./payload) inside a zipfile on Windows/Linux?

Last edited by KevinH; 12-03-2014 at 08:13 PM.
KevinH is offline   Reply With Quote
Old 12-03-2014, 08:28 PM   #70
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: 19,199
Karma: 99356142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
So can you please try one thing:

Unzip the launcher_updater_20141204.zip but do not cd into it. Then try doing the following:

python launcher_updater_20141204

And yes we are just passing the folder name into python, but that is supposed to work as well. This does work on my Mac.
Same thing.
It SAYS everything went OK, but nothing gets copied and flist is empty.
DiapDealer is online now   Reply With Quote
Old 12-03-2014, 08:35 PM   #71
KevinH
Wizard
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: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
Hi DiapDealer,

Okay I tried one more time and put up a new version that uses full paths instead of relative paths.

This one now feeds back as it is copying files as well.

So unzip it
then try running:

python launcher_updater_20141204

So please give the new version a try (there is a new md5 sum as well).

If that doesn't work then I am going back to the drawing board!


Quote:
Originally Posted by DiapDealer View Post
Same thing.
It SAYS everything went OK, but nothing gets copied and flist is empty.
KevinH is offline   Reply With Quote
Old 12-03-2014, 10:11 PM   #72
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: 19,199
Karma: 99356142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
That worked!

Permission denied errors on Windows, but that's not surprising. Opening a command-prompt as Administrator takes care of that problem. I imagine Linux users would need to use sudo as well.
DiapDealer is online now   Reply With Quote
Old 12-03-2014, 10:43 PM   #73
KevinH
Wizard
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: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
Hi DiapDaler,

Whew! I am glad this one worked. I would rather it worked from the zip but that seems impossible. I will add info on the need to open a command prompt as Administrator on Windows, and use sudo on Linux.

Thanks so much for testing it and tracking down the error!

KevinH

Quote:
Originally Posted by DiapDealer View Post
That worked!

Permission denied errors on Windows, but that's not surprising. Opening a command-prompt as Administrator takes care of that problem. I imagine Linux users would need to use sudo as well.
KevinH is offline   Reply With Quote
Old 12-04-2014, 12:42 AM   #74
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,247
Karma: 83049305
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
What about something like these, at least for linux?

https://codereview.stackexchange.com...ot-from-python
https://gist.github.com/davejamesmiller/1965559

Or at least do an euid check and error out with an appropriate message.

Last edited by eschwartz; 12-04-2014 at 12:54 AM.
eschwartz is offline   Reply With Quote
Old 12-04-2014, 07:59 AM   #75
KevinH
Wizard
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: 3,101
Karma: 1931746
Join Date: Nov 2009
Device: many
Hi eschwartz,

I guess I could use it, but they only would work for unix/linux and not Windows. I'll think about it for the next time.

Thanks,

Kevin

Quote:
Originally Posted by eschwartz View Post
What about something like these, at least for linux?

https://codereview.stackexchange.com...ot-from-python
https://gist.github.com/davejamesmiller/1965559

Or at least do an euid check and error out with an appropriate message.
KevinH is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Plugin in development Sladd Development 6 06-17-2014 07:57 PM
Question for plugin development gurus DiapDealer Plugins 2 02-05-2012 12:33 AM
DR800 Plugin development for DR800/DR1000 yuri_b iRex Developer's Corner 0 09-18-2010 10:46 AM
Device plugin development reader42 Plugins 10 03-29-2010 01:39 PM
Calibre plugin development - Newbie problems minstrel Plugins 5 04-12-2009 01:44 PM


All times are GMT -4. The time now is 10:13 AM.


MobileRead.com is a privately owned, operated and funded community.