mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
DRYer
This commit is contained in:
parent
133a073ef7
commit
a5953fd68d
@ -280,8 +280,20 @@ libraries that the main calibre program knows about will be used.
|
|||||||
option_parser = create_option_parser
|
option_parser = create_option_parser
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_single_instance():
|
||||||
|
if b'CALIBRE_NO_SI_DANGER_DANGER' not in os.environ and not singleinstance('db'):
|
||||||
|
ext = '.exe' if iswindows else ''
|
||||||
|
raise SystemExit(_(
|
||||||
|
'Another calibre program such as another instance of {} or the main'
|
||||||
|
' calibre program is running. Having multiple programs that can make'
|
||||||
|
' changes to a calibre library running at the same time is not supported.'
|
||||||
|
).format('calibre-server' + ext)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main(args=sys.argv):
|
def main(args=sys.argv):
|
||||||
opts, args=create_option_parser().parse_args(args)
|
opts, args=create_option_parser().parse_args(args)
|
||||||
|
ensure_single_instance()
|
||||||
if opts.manage_users:
|
if opts.manage_users:
|
||||||
try:
|
try:
|
||||||
manage_users(opts.userdb)
|
manage_users(opts.userdb)
|
||||||
@ -299,15 +311,6 @@ def main(args=sys.argv):
|
|||||||
raise SystemExit(_('You must specify at least one calibre library'))
|
raise SystemExit(_('You must specify at least one calibre library'))
|
||||||
libraries=[prefs['library_path']]
|
libraries=[prefs['library_path']]
|
||||||
|
|
||||||
if b'CALIBRE_NO_SI_DANGER_DANGER' not in os.environ and not singleinstance('db'):
|
|
||||||
ext = '.exe' if iswindows else ''
|
|
||||||
raise SystemExit(_(
|
|
||||||
'Another calibre program such as another instance of {} or the main'
|
|
||||||
' calibre program is running. Having multiple programs that can make'
|
|
||||||
' changes to a calibre library running at the same time is not supported.'
|
|
||||||
).format('calibre-server' + ext)
|
|
||||||
)
|
|
||||||
|
|
||||||
if opts.auto_reload:
|
if opts.auto_reload:
|
||||||
if opts.daemonize:
|
if opts.daemonize:
|
||||||
raise SystemExit('Cannot specify --auto-reload and --daemonize at the same time')
|
raise SystemExit('Cannot specify --auto-reload and --daemonize at the same time')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user