mirror of
https://github.com/Leseratte10/acsm-calibre-plugin
synced 2024-11-15 19:48:29 +01:00
Bunch of fixes
Fix #48 Fix SingleInstance in Calibre 4 Make plugin run in Calibre 3.48
This commit is contained in:
parent
6a53617fde
commit
f5e19f4391
5 changed files with 46 additions and 10 deletions
|
@ -85,8 +85,10 @@ See the "LICENSE" file for a full copy of the GNU GPL v3.
|
|||
# Print useful warning if LicenseServiceCertificate download fails,
|
||||
# fix error with the loan list not being updated when importing multiple ACSMs at once,
|
||||
# fix bug with the GUI extension in non-English environments,
|
||||
# add setting to choose between simultaneous (faster) or sequencial (more ADE-like)
|
||||
# import of multiple ACSM files
|
||||
# fix softlock when importing a large number of ACSM files at once,
|
||||
# fix "account folder not found" error message on some clean installations,
|
||||
# add experimental support for Calibre 3.48.
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -99,7 +101,12 @@ __version__ = PLUGIN_VERSION = ".".join([str(x)for x in PLUGIN_VERSION_TUPLE])
|
|||
|
||||
|
||||
from calibre.utils.config import config_dir # type: ignore
|
||||
from calibre.utils.lock import SingleInstance, singleinstance # type: ignore
|
||||
from calibre.utils.lock import singleinstance # type: ignore
|
||||
|
||||
try:
|
||||
from calibre.utils.lock import SingleInstance # type: ignore
|
||||
except:
|
||||
from calibre_plugins.deacsm.singleinstance_helper import SingleInstance
|
||||
|
||||
import os, shutil, traceback, sys, time, io, random
|
||||
import zipfile
|
||||
|
@ -113,7 +120,7 @@ class ACSMInput(FileTypePlugin):
|
|||
supported_platforms = ['linux', 'osx', 'windows']
|
||||
author = "Leseratte10"
|
||||
version = PLUGIN_VERSION_TUPLE
|
||||
minimum_calibre_version = (4, 0, 0)
|
||||
minimum_calibre_version = (3, 48, 0)
|
||||
file_types = set(['acsm'])
|
||||
on_import = True
|
||||
on_preprocess = True
|
||||
|
|
|
@ -70,7 +70,12 @@ def create_menu_action_unique(ia, parent_menu, menu_text, image=None, tooltip=No
|
|||
class ActualACSMInputGUIExtension(InterfaceAction):
|
||||
name = "ACSM Input Plugin GUI Extension"
|
||||
|
||||
popup_type = QToolButton.ToolButtonPopupMode.InstantPopup
|
||||
try:
|
||||
popup_type = QToolButton.ToolButtonPopupMode.InstantPopup
|
||||
except AttributeError:
|
||||
# Needed for Calibre 3
|
||||
popup_type = 2
|
||||
|
||||
action_type = 'global'
|
||||
action_spec = ("ACSM Input", None, "ACSM Input Plugin by Leseratte10", None)
|
||||
# Text, icon, tooltip, keyboard shortcut
|
||||
|
|
|
@ -15,7 +15,6 @@ import os
|
|||
import traceback
|
||||
|
||||
from calibre.utils.config import JSONConfig, config_dir # type: ignore
|
||||
from calibre.constants import iswindows # type: ignore
|
||||
|
||||
|
||||
class ACSMInput_Prefs():
|
||||
|
@ -54,8 +53,18 @@ class ACSMInput_Prefs():
|
|||
success = True
|
||||
break
|
||||
|
||||
|
||||
if not success:
|
||||
# We did not find an account folder. See if we can create one ...
|
||||
for f in ["DeACSM", "ACSMInput"]:
|
||||
self.__maindir = os.path.join(self.__pluginsdir, f)
|
||||
self.__accountdir = os.path.join(self.__maindir,"account")
|
||||
if os.path.exists(self.__maindir):
|
||||
os.mkdir(self.__accountdir)
|
||||
self.deacsmprefs.defaults['path_to_account_data'] = self.__accountdir
|
||||
success = True
|
||||
break
|
||||
|
||||
if not success:
|
||||
raise Exception("Why does the account folder not exist?")
|
||||
|
||||
|
||||
|
|
17
calibre-plugin/singleinstance_helper.py
Normal file
17
calibre-plugin/singleinstance_helper.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from calibre.utils.lock import create_single_instance_mutex
|
||||
|
||||
class SingleInstance:
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.release_mutex = None
|
||||
|
||||
def __enter__(self):
|
||||
self.release_mutex = create_single_instance_mutex(self.name)
|
||||
return self.release_mutex is not None
|
||||
|
||||
def __exit__(self, *a):
|
||||
if self.release_mutex is not None:
|
||||
self.release_mutex()
|
||||
self.release_mutex = None
|
||||
|
|
@ -28,11 +28,9 @@ class DeACSMMigrationPlugin(InterfaceActionBase):
|
|||
version = (0, 0, 20)
|
||||
|
||||
can_be_disabled = False
|
||||
# This plugin will be auto-loaded from the ACSM Input plugin. It doesn't make sense for the user
|
||||
# to disable it. If necessary, the menu bar button can be removed through the Calibre settings.
|
||||
|
||||
type = "File type"
|
||||
# Just so that the GUI extension shows up at the same place as the actual ACSM Input plugin.
|
||||
# Just so that the migration extension shows up at the same place as the actual ACSM Input plugin.
|
||||
|
||||
try:
|
||||
from calibre.customize import PluginInstallationType
|
||||
|
|
Loading…
Reference in a new issue