mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
Call the startup and shutdown methods for the device plugins in ebook-device
This commit is contained in:
parent
6d9a72022d
commit
5904626f3c
@ -503,14 +503,16 @@ class DevicePlugin(Plugin):
|
|||||||
Called when calibre is is starting the device. Do any initialization
|
Called when calibre is is starting the device. Do any initialization
|
||||||
required. Note that multiple instances of the class can be instantiated,
|
required. Note that multiple instances of the class can be instantiated,
|
||||||
and thus __init__ can be called multiple times, but only one instance
|
and thus __init__ can be called multiple times, but only one instance
|
||||||
will have this method called.
|
will have this method called. This method is called on the device
|
||||||
|
thread, not the GUI thread.
|
||||||
'''
|
'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
'''
|
'''
|
||||||
Called when calibre is shutting down, either for good or in preparation
|
Called when calibre is shutting down, either for good or in preparation
|
||||||
to restart. Do any cleanup required.
|
to restart. Do any cleanup required. This method is called on the
|
||||||
|
device thread, not the GUI thread.
|
||||||
'''
|
'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -174,6 +174,13 @@ def ls(dev, path, term, recurse=False, color=False, human_readable_size=False, l
|
|||||||
output.close()
|
output.close()
|
||||||
return listing
|
return listing
|
||||||
|
|
||||||
|
def shutdown_plugins():
|
||||||
|
for d in device_plugins():
|
||||||
|
try:
|
||||||
|
d.shutdown()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
term = TerminalController()
|
term = TerminalController()
|
||||||
cols = term.COLS
|
cols = term.COLS
|
||||||
@ -201,6 +208,10 @@ def main():
|
|||||||
scanner.scan()
|
scanner.scan()
|
||||||
connected_devices = []
|
connected_devices = []
|
||||||
for d in device_plugins():
|
for d in device_plugins():
|
||||||
|
try:
|
||||||
|
d.startup()
|
||||||
|
except:
|
||||||
|
print ('Startup failed for device plugin: %s'%d)
|
||||||
ok, det = scanner.is_device_connected(d)
|
ok, det = scanner.is_device_connected(d)
|
||||||
if ok:
|
if ok:
|
||||||
dev = d
|
dev = d
|
||||||
@ -209,6 +220,7 @@ def main():
|
|||||||
|
|
||||||
if dev is None:
|
if dev is None:
|
||||||
print >>sys.stderr, 'Unable to find a connected ebook reader.'
|
print >>sys.stderr, 'Unable to find a connected ebook reader.'
|
||||||
|
shutdown_plugins()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for det, d in connected_devices:
|
for det, d in connected_devices:
|
||||||
@ -358,6 +370,9 @@ def main():
|
|||||||
except (ArgumentError, DeviceError) as e:
|
except (ArgumentError, DeviceError) as e:
|
||||||
print >>sys.stderr, e
|
print >>sys.stderr, e
|
||||||
return 1
|
return 1
|
||||||
|
finally:
|
||||||
|
shutdown_plugins()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user