~tomasgroth/openlp/portable-path

« back to all changes in this revision

Viewing changes to openlp/plugins/bibles/lib/manager.py

  • Committer: Tomas Groth
  • Date: 2019-04-30 19:02:42 UTC
  • mfrom: (2829.2.32 openlp)
  • Revision ID: tomasgroth@yahoo.dk-20190430190242-6zwjk8724tyux70m
trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
###############################################################################
5
5
# OpenLP - Open Source Lyrics Projection                                      #
6
6
# --------------------------------------------------------------------------- #
7
 
# Copyright (c) 2008-2018 OpenLP Developers                                   #
 
7
# Copyright (c) 2008-2019 OpenLP Developers                                   #
8
8
# --------------------------------------------------------------------------- #
9
9
# This program is free software; you can redistribute it and/or modify it     #
10
10
# under the terms of the GNU General Public License as published by the Free  #
29
29
from openlp.core.common.settings import Settings
30
30
from openlp.plugins.bibles.lib import LanguageSelection, parse_reference
31
31
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
 
32
 
32
33
from .importers.csvbible import CSVBible
33
34
from .importers.http import HTTPBible
34
35
from .importers.opensong import OpenSongBible
36
37
from .importers.wordproject import WordProjectBible
37
38
from .importers.zefania import ZefaniaBible
38
39
 
 
40
 
39
41
try:
40
42
    from .importers.sword import SwordBible
41
 
except:
 
43
except ImportError:
42
44
    pass
43
45
 
44
46
log = logging.getLogger(__name__)
116
118
        self.web = 'Web'
117
119
        self.db_cache = None
118
120
        self.path = AppLocation.get_section_data_path(self.settings_section)
119
 
        self.proxy_name = Settings().value(self.settings_section + '/proxy name')
120
121
        self.suffix = '.sqlite'
121
122
        self.import_wizard = None
122
123
        self.reload_bibles()
149
150
            if self.db_cache[name].is_web_bible:
150
151
                source = self.db_cache[name].get_object(BibleMeta, 'download_source')
151
152
                download_name = self.db_cache[name].get_object(BibleMeta, 'download_name').value
152
 
                meta_proxy = self.db_cache[name].get_object(BibleMeta, 'proxy_server')
153
153
                web_bible = HTTPBible(self.parent, path=self.path, file=file_path, download_source=source.value,
154
154
                                      download_name=download_name)
155
 
                if meta_proxy:
156
 
                    web_bible.proxy_server = meta_proxy.value
157
155
                self.db_cache[name] = web_bible
158
156
        log.debug('Bibles reloaded')
159
157
 
189
187
        bible = self.db_cache[name]
190
188
        bible.session.close_all()
191
189
        bible.session = None
192
 
        return delete_file(Path(bible.path, bible.file))
 
190
        return delete_file(bible.path / '{name}{suffix}'.format(name=name, suffix=self.suffix))
193
191
 
194
192
    def get_bibles(self):
195
193
        """