mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Delete mount dir after eject on linux if it is in /media. Also add eject command to ebook-device
This commit is contained in:
parent
1323f26b83
commit
c941abc652
@ -180,7 +180,8 @@ def main():
|
|||||||
if not cols: # On windows terminal width is unknown
|
if not cols: # On windows terminal width is unknown
|
||||||
cols = 80
|
cols = 80
|
||||||
|
|
||||||
parser = OptionParser(usage="usage: %prog [options] command args\n\ncommand is one of: info, books, df, ls, cp, mkdir, touch, cat, rm\n\n"+
|
parser = OptionParser(usage="usage: %prog [options] command args\n\ncommand "+
|
||||||
|
"is one of: info, books, df, ls, cp, mkdir, touch, cat, rm, eject\n\n"+
|
||||||
"For help on a particular command: %prog command", version=__appname__+" version: " + __version__)
|
"For help on a particular command: %prog command", version=__appname__+" version: " + __version__)
|
||||||
parser.add_option("--log-packets", help="print out packet stream to stdout. "+\
|
parser.add_option("--log-packets", help="print out packet stream to stdout. "+\
|
||||||
"The numbers in the left column are byte offsets that allow the packet size to be read off easily.",
|
"The numbers in the left column are byte offsets that allow the packet size to be read off easily.",
|
||||||
@ -222,6 +223,8 @@ def main():
|
|||||||
for i in range(3):
|
for i in range(3):
|
||||||
print "%-10s\t%s\t%s\t%s\t%s"%(where[i], human_readable(total[i]), human_readable(total[i]-free[i]), human_readable(free[i]),\
|
print "%-10s\t%s\t%s\t%s\t%s"%(where[i], human_readable(total[i]), human_readable(total[i]-free[i]), human_readable(free[i]),\
|
||||||
str(0 if total[i]==0 else int(100*(total[i]-free[i])/(total[i]*1.)))+"%")
|
str(0 if total[i]==0 else int(100*(total[i]-free[i])/(total[i]*1.)))+"%")
|
||||||
|
elif command == 'eject':
|
||||||
|
dev.eject()
|
||||||
elif command == "books":
|
elif command == "books":
|
||||||
print "Books in main memory:"
|
print "Books in main memory:"
|
||||||
for book in dev.books():
|
for book in dev.books():
|
||||||
|
@ -7,7 +7,7 @@ intended to be subclassed with the relevant parts implemented for a particular
|
|||||||
device. This class handles device detection.
|
device. This class handles device detection.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os, subprocess, time, re, sys, glob
|
import os, subprocess, time, re, sys, glob, shutil
|
||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
|
|
||||||
from calibre.devices.interface import DevicePlugin
|
from calibre.devices.interface import DevicePlugin
|
||||||
@ -548,13 +548,23 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
drives = self.find_device_nodes()
|
drives = self.find_device_nodes()
|
||||||
for drive in drives:
|
for drive in drives:
|
||||||
if drive:
|
if drive:
|
||||||
cmd = ['pumount']
|
cmd = ['pumount', '-l']
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(cmd + [drive])
|
p = subprocess.Popen(cmd + [drive])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
while p.poll() is None:
|
while p.poll() is None:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
if p.returncode == 0:
|
||||||
|
for x in ('_main_prefix', '_card_a_prefix', '_card_b_prefix'):
|
||||||
|
x = getattr(self, x, None)
|
||||||
|
if x is not None:
|
||||||
|
if x.startswith('/media/') and os.path.exists(x):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(x)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def eject(self):
|
def eject(self):
|
||||||
if islinux:
|
if islinux:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user