mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove old db migration code from calibre-debug
This commit is contained in:
parent
d00e92d16a
commit
76ff4b6230
@ -37,9 +37,6 @@ Run an embedded python interpreter.
|
|||||||
help='Run the ebook viewer',)
|
help='Run the ebook viewer',)
|
||||||
parser.add_option('--paths', default=False, action='store_true',
|
parser.add_option('--paths', default=False, action='store_true',
|
||||||
help='Output the paths necessary to setup the calibre environment')
|
help='Output the paths necessary to setup the calibre environment')
|
||||||
parser.add_option('--migrate', action='store_true', default=False,
|
|
||||||
help='Migrate old database. Needs two arguments. Path '
|
|
||||||
'to library1.db and path to new library folder.')
|
|
||||||
parser.add_option('--add-simple-plugin', default=None,
|
parser.add_option('--add-simple-plugin', default=None,
|
||||||
help='Add a simple plugin (i.e. a plugin that consists of only a '
|
help='Add a simple plugin (i.e. a plugin that consists of only a '
|
||||||
'.py file), by specifying the path to the py file containing the '
|
'.py file), by specifying the path to the py file containing the '
|
||||||
@ -118,28 +115,6 @@ def reinit_db(dbpath, callback=None, sql_dump=None):
|
|||||||
os.remove(dest)
|
os.remove(dest)
|
||||||
prints('Database successfully re-initialized')
|
prints('Database successfully re-initialized')
|
||||||
|
|
||||||
def migrate(old, new):
|
|
||||||
from calibre.utils.config import prefs
|
|
||||||
from calibre.library.database import LibraryDatabase
|
|
||||||
from calibre.library.database2 import LibraryDatabase2
|
|
||||||
from calibre.utils.terminfo import ProgressBar
|
|
||||||
from calibre.constants import terminal_controller
|
|
||||||
class Dummy(ProgressBar):
|
|
||||||
def setLabelText(self, x): pass
|
|
||||||
def setAutoReset(self, y): pass
|
|
||||||
def reset(self): pass
|
|
||||||
def setRange(self, min, max):
|
|
||||||
self.min = min
|
|
||||||
self.max = max
|
|
||||||
def setValue(self, val):
|
|
||||||
self.update(float(val)/getattr(self, 'max', 1))
|
|
||||||
|
|
||||||
db = LibraryDatabase(old)
|
|
||||||
db2 = LibraryDatabase2(new)
|
|
||||||
db2.migrate_old(db, Dummy(terminal_controller(), 'Migrating database...'))
|
|
||||||
prefs['library_path'] = os.path.abspath(new)
|
|
||||||
print 'Database migrated to', os.path.abspath(new)
|
|
||||||
|
|
||||||
def debug_device_driver():
|
def debug_device_driver():
|
||||||
from calibre.devices import debug
|
from calibre.devices import debug
|
||||||
debug(ioreg_to_tmp=True, buf=sys.stdout)
|
debug(ioreg_to_tmp=True, buf=sys.stdout)
|
||||||
@ -249,11 +224,6 @@ def main(args=sys.argv):
|
|||||||
exec opts.command
|
exec opts.command
|
||||||
elif opts.debug_device_driver:
|
elif opts.debug_device_driver:
|
||||||
debug_device_driver()
|
debug_device_driver()
|
||||||
elif opts.migrate:
|
|
||||||
if len(args) < 3:
|
|
||||||
print 'You must specify the path to library1.db and the path to the new library folder'
|
|
||||||
return 1
|
|
||||||
migrate(args[1], args[2])
|
|
||||||
elif opts.add_simple_plugin is not None:
|
elif opts.add_simple_plugin is not None:
|
||||||
add_simple_plugin(opts.add_simple_plugin)
|
add_simple_plugin(opts.add_simple_plugin)
|
||||||
elif opts.paths:
|
elif opts.paths:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user