当前位置: 首页>>代码示例>>Python>>正文


Python database.Database方法代码示例

本文整理汇总了Python中database.Database方法的典型用法代码示例。如果您正苦于以下问题:Python database.Database方法的具体用法?Python database.Database怎么用?Python database.Database使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database的用法示例。


在下文中一共展示了database.Database方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: musicvideos

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def musicvideos(self, library, dialog):

        ''' Process musicvideos from a single library.
        '''
        MusicVideos = self.library.media['MusicVideos']

        with self.library.database_lock:
            with Database() as videodb:
                with Database('emby') as embydb:
                    obj = MusicVideos(self.server, embydb, videodb, self.direct_path)

                    for items in server.get_items(library['Id'], "MusicVideo", False, self.sync['RestorePoint'].get('params')):

                        self._restore_point(items['RestorePoint'])
                        start_index = items['RestorePoint']['params']['StartIndex']

                        for index, mvideo in enumerate(items['Items']):

                            dialog.update(int((float(start_index + index) / float(items['TotalRecordCount']))*100),
                                          heading="%s: %s" % (_('addon_name'), library['Name']),
                                          message=mvideo['Name'])
                            obj.musicvideo(mvideo, library=library)

                    if self.update_library:
                        self.musicvideos_compare(library, obj, embydb) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:27,代码来源:sync.py

示例2: boxsets

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def boxsets(self, library_id=None, dialog=None):

        ''' Process all boxsets.
        '''
        Movies = self.library.media['Movies']

        with self.library.database_lock:
            with Database() as videodb:
                with Database('emby') as embydb:
                    obj = Movies(self.server, embydb, videodb, self.direct_path)

                    for items in server.get_items(library_id, "BoxSet", False, self.sync['RestorePoint'].get('params')):

                        self._restore_point(items['RestorePoint'])
                        start_index = items['RestorePoint']['params']['StartIndex']

                        for index, boxset in enumerate(items['Items']):

                            dialog.update(int((float(start_index + index) / float(items['TotalRecordCount']))*100),
                                          heading="%s: %s" % (_('addon_name'), _('boxsets')),
                                          message=boxset['Name'])
                            obj.boxset(boxset) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:24,代码来源:sync.py

示例3: patch_music

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def patch_music(self, notification=False):

        ''' Patch the music database to silence the rescan prompt.
        '''
        if kodi_version() < 18:
            LOG.info("version not supported for patching music db.")
            return

        with self.library.database_lock:
            with Database('music') as musicdb:
                self.library.kodi_media['Music'](musicdb.cursor).disable_rescan(musicdb.path.split('MyMusic')[1].split('.db')[0], 0)
        
        settings('MusicRescan.bool', True)

        if notification:
            dialog("notification", heading="{emby}", message=_('task_success'), icon="{emby}", time=1000, sound=False) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:18,代码来源:sync.py

示例4: check_version

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def check_version(self):

        ''' Check the database version to ensure we do not need to do a reset.
        '''
        with Database('emby') as embydb:

            version = emby_db.EmbyDatabase(embydb.cursor).get_version()
            LOG.info("---[ db/%s ]", version)

        if version and compare_version(version, "3.1.0") < 0:
            resp = dialog("yesno", heading=_('addon_name'), line1=_(33022))

            if not resp:

                LOG.warn("Database version is out of date! USER IGNORED!")
                dialog("ok", heading=_('addon_name'), line1=_(33023))

                raise Exception("User backed out of a required database reset")
            else:
                reset()

                raise Exception("Completed database reset") 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:24,代码来源:service.py

示例5: create_balance_object

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def create_balance_object(self, balance_item):
        """
        Creates a new balance object containing only the relevant values and the BTC value of the coin's balance

        :param balance_item: The Bittrex user balance object for a coin
        :type balance_item: dict
        """
        btc_price = 1
        is_tracked = False
        if balance_item["Currency"] != "BTC":
            coin_pair = "BTC-" + balance_item["Currency"]
            is_tracked = coin_pair in self.Database.trades["trackedCoinPairs"]
            btc_price = self.get_current_price(coin_pair, "bid")

        try:
            btc_value = round(btc_price * balance_item["Balance"], 8)
        except TypeError as exception:
            logger.exception(exception)
            btc_value = 0

        return py_.assign(
            py_.pick(balance_item, "Currency", "Balance"),
            {"BtcValue": btc_value, "IsTracked": is_tracked}
        ) 
开发者ID:JPStrydom,项目名称:Crypto-Trading-Bot,代码行数:26,代码来源:trader.py

示例6: __init__

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def __init__(self):
        self.search = ElasticSearchEngine(config.ES_URL, config.ES_INDEX)
        self.db = database.Database(config.DB_CONN_STR)
        self.tracker = TaskTrackerApi(config.TT_API)

        self.bucket = WsBucketApi(config.WSB_API, config.WSB_SECRET)
        self._indexer_threads = list()

        self.worker = Worker.from_file(self.tracker)
        if not self.worker:
            self.worker = self.tracker.make_worker("$oddb_master")
            if not self.worker:
                print("Could not create worker: %s" % traceback.format_exc())
                return
            self.worker.dump_to_file()
            self.worker.request_access(config.TT_CRAWL_PROJECT, False, True)
            self.worker.request_access(config.TT_INDEX_PROJECT, True, False) 
开发者ID:simon987,项目名称:od-database,代码行数:19,代码来源:tasks.py

示例7: test_record_post

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def test_record_post(self, mock_dt):
        mock_dt.now.return_value = _FIXED_DATETIME

        db = database.Database()
        record = db.record_post(
            source_url='https://i.imgur.com/source.jpg',
            uploaded_url='https://i.imgur.com/upload.jpg'
        )

        self.assertEqual(
            record,
            database.Record(
                source_url='https://i.imgur.com/source.jpg',
                uploaded_url='https://i.imgur.com/upload.jpg',
                success=True,
                date=_FIXED_DATETIME
            )
        ) 
开发者ID:revan,项目名称:gabenizer,代码行数:20,代码来源:database_test.py

示例8: add_library

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def add_library(self, view):

        ''' Add entry to view table in emby database.
        '''
        with Database('emby') as embydb:
            emby_db.EmbyDatabase(embydb.cursor).add_view(view['Id'], view['Name'], view['Media']) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:8,代码来源:views.py

示例9: remove_library

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def remove_library(self, view_id):

        ''' Remove entry from view table in emby database.
        '''
        with Database('emby') as embydb:
            emby_db.EmbyDatabase(embydb.cursor).remove_view(view_id)

        self.delete_playlist_by_id(view_id)
        self.delete_node_by_id(view_id) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:11,代码来源:views.py

示例10: __init__

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def __init__(self, queue, library, database, lock):

        self.queue = queue
        self.notify_output = library.notify_output
        self.notify = settings('newContent.bool')
        self.lock = lock
        self.database = Database(database)
        self.library = library
        library.set_progress_dialog()
        threading.Thread.__init__(self)
        self.start() 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:13,代码来源:library.py

示例11: run

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def run(self):

        with self.lock:
            with self.database as kodidb:
                with Database('emby') as embydb:

                    while True:

                        try:
                            item = self.queue.get(timeout=1)
                        except Queue.Empty:
                            break

                        obj = MEDIA[item['Type']](self.library.server, embydb, kodidb, self.library.direct_path)[item['Type']]
                        self.library.update_progress_dialog(api.API(item).get_naming())

                        try:
                            if obj(item) and self.notify:
                                self.notify_output.put((item['Type'], api.API(item).get_naming()))
                        except LibraryException as error:

                            if error.status in ('StopCalled', 'StopWriteCalled'):
                                self.queue.put(item)

                                break
                        except Exception as error:
                            LOG.exception(error)

                        self.queue.task_done()

                        if window('emby_should_stop.bool'):
                            break

        LOG.info("--<[ q:updated/%s ]", id(self))
        self.is_done = True 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:37,代码来源:library.py

示例12: get_libraries

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def get_libraries(self, library_id=None):

        with Database('emby') as embydb:
            if library_id is None:
                return emby_db.EmbyDatabase(embydb.cursor).get_views()
            else:
                return emby_db.EmbyDatabase(embydb.cursor).get_view(library_id) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:9,代码来源:sync.py

示例13: movies

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def movies(self, library, dialog):

        ''' Process movies from a single library.
        '''
        Movies = self.library.media['Movies']

        with self.library.database_lock:
            with Database() as videodb:
                with Database('emby') as embydb:

                    obj = Movies(self.server, embydb, videodb, self.direct_path, True)

                    for items in server.get_items(library['Id'], "Movie", False, self.sync['RestorePoint'].get('params')):
                        
                        self._restore_point(items['RestorePoint'])
                        start_index = items['RestorePoint']['params']['StartIndex']

                        for index, movie in enumerate(items['Items']):

                            dialog.update(int((float(start_index + index) / float(items['TotalRecordCount']))*100),
                                          heading="%s: %s" % (_('addon_name'), library['Name']),
                                          message=movie['Name'])
                            obj.movie(movie, library=library)

                    if self.update_library:
                        self.movies_compare(library, obj, embydb) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:28,代码来源:sync.py

示例14: tvshows

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def tvshows(self, library, dialog):

        ''' Process tvshows and episodes from a single library.
        '''
        TVShows = self.library.media['TVShows']

        with self.library.database_lock:
            with Database() as videodb:
                with Database('emby') as embydb:
                    obj = TVShows(self.server, embydb, videodb, self.direct_path, True)

                    for items in server.get_items(library['Id'], "Series", False, self.sync['RestorePoint'].get('params')):

                        self._restore_point(items['RestorePoint'])
                        start_index = items['RestorePoint']['params']['StartIndex']

                        for index, show in enumerate(items['Items']):

                            percent = int((float(start_index + index) / float(items['TotalRecordCount']))*100)
                            message = show['Name']
                            dialog.update(percent, heading="%s: %s" % (_('addon_name'), library['Name']), message=message)

                            if obj.tvshow(show, library=library) != False:

                                for episodes in server.get_episode_by_show(show['Id']):
                                    for episode in episodes['Items']:

                                        dialog.update(percent, message="%s/%s" % (message, episode['Name'][:10]))
                                        obj.episode(episode)

                    if self.update_library:
                        self.tvshows_compare(library, obj, embydb) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:34,代码来源:sync.py

示例15: refresh_boxsets

# 需要导入模块: import database [as 别名]
# 或者: from database import Database [as 别名]
def refresh_boxsets(self):

        ''' Delete all exisitng boxsets and re-add.
        '''
        Movies = self.library.media['Movies']

        with self.library.database_lock:
            with Database() as videodb:
                with Database('emby') as embydb:

                    obj = Movies(self.server, embydb, videodb, self.direct_path)
                    obj.boxsets_reset()

        self.boxsets(None) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:16,代码来源:sync.py


注:本文中的database.Database方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。