def InitClientFilesManager(self): self.client_files_manager = ClientCaches.ClientFilesManager(self) missing_locations = self.client_files_manager.GetMissing() while len(missing_locations) > 0: with ClientGUITopLevelWindows.DialogManage( None, 'repair file system') as dlg: panel = ClientGUIScrolledPanelsManagement.RepairFileSystemPanel( dlg, missing_locations) dlg.SetPanel(panel) if dlg.ShowModal() == wx.ID_OK: self.client_files_manager = ClientCaches.ClientFilesManager( self) missing_locations = self.client_files_manager.GetMissing() else: raise HydrusExceptions.PermissionException( 'File system failed, user chose to quit.')
def wx_code(): self._caches['images'] = ClientCaches.RenderedImageCache(self) self._caches['thumbnail'] = ClientCaches.ThumbnailCache(self) self.bitmap_manager = ClientCaches.BitmapManager(self) CC.GlobalBMPs.STATICInitialise()
def wx_code(): self._caches['fullscreen'] = ClientCaches.RenderedImageCache( self, 'fullscreen') self._caches['preview'] = ClientCaches.RenderedImageCache( self, 'preview') self._caches['thumbnail'] = ClientCaches.ThumbnailCache(self) CC.GlobalBMPs.STATICInitialise()
def InitModel(self): self.pub('splash_set_title_text', u'booting db\u2026') self._http = ClientNetworking.HTTPConnectionManager() HydrusController.HydrusController.InitModel(self) self._options = self.Read('options') self._new_options = self.Read( 'serialisable', HydrusSerialisable.SERIALISABLE_TYPE_CLIENT_OPTIONS) HC.options = self._options if self._new_options.GetBoolean('use_system_ffmpeg'): if HydrusVideoHandling.FFMPEG_PATH.startswith(HC.BIN_DIR): HydrusVideoHandling.FFMPEG_PATH = os.path.basename( HydrusVideoHandling.FFMPEG_PATH) self._services_manager = ClientCaches.ServicesManager(self) self._client_files_manager = ClientCaches.ClientFilesManager(self) self._client_session_manager = ClientCaches.HydrusSessionManager(self) self._managers['local_booru'] = ClientCaches.LocalBooruCache(self) self._managers['tag_censorship'] = ClientCaches.TagCensorshipManager( self) self._managers['tag_siblings'] = ClientCaches.TagSiblingsManager(self) self._managers['tag_parents'] = ClientCaches.TagParentsManager(self) self._managers['undo'] = ClientCaches.UndoManager(self) self._managers['web_sessions'] = ClientCaches.WebSessionManagerClient( self) if HC.options['proxy'] is not None: (proxytype, host, port, username, password) = HC.options['proxy'] ClientNetworking.SetProxy(proxytype, host, port, username, password) def wx_code(): self._caches['images'] = ClientCaches.RenderedImageCache(self) self._caches['thumbnail'] = ClientCaches.ThumbnailCache(self) CC.GlobalBMPs.STATICInitialise() self.CallBlockingToWx(wx_code) self.sub(self, 'Clipboard', 'clipboard') self.sub(self, 'RestartBooru', 'restart_booru')
def InitModel(self): self.pub('splash_set_title_text', 'booting db...') self._http = ClientNetworking.HTTPConnectionManager() HydrusController.HydrusController.InitModel(self) self._options = self.Read('options') self._new_options = self.Read( 'serialisable', HydrusSerialisable.SERIALISABLE_TYPE_CLIENT_OPTIONS) HC.options = self._options self._services_manager = ClientCaches.ServicesManager(self) self._client_files_manager = ClientCaches.ClientFilesManager(self) self._client_session_manager = ClientCaches.HydrusSessionManager(self) self._managers['local_booru'] = ClientCaches.LocalBooruCache(self) self._managers['tag_censorship'] = ClientCaches.TagCensorshipManager( self) self._managers['tag_siblings'] = ClientCaches.TagSiblingsManager(self) self._managers['tag_parents'] = ClientCaches.TagParentsManager(self) self._managers['undo'] = ClientCaches.UndoManager(self) self._managers['web_sessions'] = ClientCaches.WebSessionManagerClient( self) if HC.options['proxy'] is not None: (proxytype, host, port, username, password) = HC.options['proxy'] ClientNetworking.SetProxy(proxytype, host, port, username, password) def wx_code(): self._caches['fullscreen'] = ClientCaches.RenderedImageCache( self, 'fullscreen') self._caches['preview'] = ClientCaches.RenderedImageCache( self, 'preview') self._caches['thumbnail'] = ClientCaches.ThumbnailCache(self) CC.GlobalBMPs.STATICInitialise() self.CallBlockingToWx(wx_code) self.sub(self, 'Clipboard', 'clipboard') self.sub(self, 'RestartServer', 'restart_server') self.sub(self, 'RestartBooru', 'restart_booru')
def test_services(self): def test_service(service, key, service_type, name, info): self.assertEqual(service.GetServiceKey(), key) self.assertEqual(service.GetServiceType(), service_type) self.assertEqual(service.GetName(), name) self.assertEqual(service.GetInfo(), info) repo_key = HydrusData.GenerateKey() repo_type = HC.TAG_REPOSITORY repo_name = 'test tag repo' repo_info = {'blah': 5} repo = ClientData.GenerateService(repo_key, repo_type, repo_name, repo_info) other_key = HydrusData.GenerateKey() other = ClientData.GenerateService(other_key, HC.LOCAL_BOORU, 'booru', {}) services = [] services.append(repo) services.append(other) HydrusGlobals.test_controller.SetRead('services', services) services_manager = ClientCaches.ServicesManager( HydrusGlobals.client_controller) # service = services_manager.GetService(repo_key) test_service(service, repo_key, repo_type, repo_name, repo_info) service = services_manager.GetService(other_key) # services = services_manager.GetServices((HC.TAG_REPOSITORY, )) self.assertEqual(len(services), 1) self.assertEqual(services[0].GetServiceKey(), repo_key) # services = [] services.append(repo) HydrusGlobals.test_controller.SetRead('services', services) services_manager.RefreshServices() self.assertRaises(Exception, services_manager.GetService, other_key)
def test_undo(self): hash_1 = HydrusData.GenerateKey() hash_2 = HydrusData.GenerateKey() hash_3 = HydrusData.GenerateKey() command_1 = { CC.COMBINED_LOCAL_FILE_SERVICE_KEY: [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_ARCHIVE, {hash_1}) ] } command_2 = { CC.COMBINED_LOCAL_FILE_SERVICE_KEY: [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_INBOX, {hash_2}) ] } command_3 = { CC.COMBINED_LOCAL_FILE_SERVICE_KEY: [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_ARCHIVE, {hash_1, hash_3}) ] } command_1_inverted = { CC.COMBINED_LOCAL_FILE_SERVICE_KEY: [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_INBOX, {hash_1}) ] } command_2_inverted = { CC.COMBINED_LOCAL_FILE_SERVICE_KEY: [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_ARCHIVE, {hash_2}) ] } undo_manager = ClientCaches.UndoManager(HG.client_controller) # undo_manager.AddCommand('content_updates', command_1) self.assertEqual((u'undo archive 1 files', None), undo_manager.GetUndoRedoStrings()) undo_manager.AddCommand('content_updates', command_2) self.assertEqual((u'undo inbox 1 files', None), undo_manager.GetUndoRedoStrings()) undo_manager.Undo() self.assertEqual((u'undo archive 1 files', u'redo inbox 1 files'), undo_manager.GetUndoRedoStrings()) self.assertEqual(HG.test_controller.GetWrite('content_updates'), [((command_2_inverted, ), {})]) undo_manager.Redo() self.assertEqual(HG.test_controller.GetWrite('content_updates'), [((command_2, ), {})]) self.assertEqual((u'undo inbox 1 files', None), undo_manager.GetUndoRedoStrings()) undo_manager.Undo() self.assertEqual(HG.test_controller.GetWrite('content_updates'), [((command_2_inverted, ), {})]) undo_manager.Undo() self.assertEqual(HG.test_controller.GetWrite('content_updates'), [((command_1_inverted, ), {})]) self.assertEqual((None, u'redo archive 1 files'), undo_manager.GetUndoRedoStrings()) undo_manager.AddCommand('content_updates', command_3) self.assertEqual((u'undo archive 2 files', None), undo_manager.GetUndoRedoStrings())
def InitModel( self ): self.pub( 'splash_set_title_text', u'booting db\u2026' ) HydrusController.HydrusController.InitModel( self ) self.pub( 'splash_set_status_text', u'initialising managers' ) self.pub( 'splash_set_status_subtext', u'services' ) self.services_manager = ClientCaches.ServicesManager( self ) self.pub( 'splash_set_status_subtext', u'options' ) self.options = self.Read( 'options' ) self.new_options = self.Read( 'serialisable', HydrusSerialisable.SERIALISABLE_TYPE_CLIENT_OPTIONS ) HC.options = self.options if self.new_options.GetBoolean( 'use_system_ffmpeg' ): if HydrusVideoHandling.FFMPEG_PATH.startswith( HC.BIN_DIR ): HydrusVideoHandling.FFMPEG_PATH = os.path.basename( HydrusVideoHandling.FFMPEG_PATH ) self.pub( 'splash_set_status_subtext', u'client files' ) self.InitClientFilesManager() # self.pub( 'splash_set_status_subtext', u'network' ) bandwidth_manager = self.Read( 'serialisable', HydrusSerialisable.SERIALISABLE_TYPE_NETWORK_BANDWIDTH_MANAGER ) if bandwidth_manager is None: bandwidth_manager = ClientNetworking.NetworkBandwidthManager() ClientDefaults.SetDefaultBandwidthManagerRules( bandwidth_manager ) bandwidth_manager._dirty = True wx.MessageBox( 'Your bandwidth manager was missing on boot! I have recreated a new empty one with default rules. Please check that your hard drive and client are ok and let the hydrus dev know the details if there is a mystery.' ) session_manager = self.Read( 'serialisable', HydrusSerialisable.SERIALISABLE_TYPE_NETWORK_SESSION_MANAGER ) if session_manager is None: session_manager = ClientNetworking.NetworkSessionManager() session_manager._dirty = True wx.MessageBox( 'Your session manager was missing on boot! I have recreated a new empty one. Please check that your hard drive and client are ok and let the hydrus dev know the details if there is a mystery.' ) domain_manager = self.Read( 'serialisable', HydrusSerialisable.SERIALISABLE_TYPE_NETWORK_DOMAIN_MANAGER ) if domain_manager is None: domain_manager = ClientNetworkingDomain.NetworkDomainManager() ClientDefaults.SetDefaultDomainManagerData( domain_manager ) domain_manager._dirty = True wx.MessageBox( 'Your domain manager was missing on boot! I have recreated a new empty one. Please check that your hard drive and client are ok and let the hydrus dev know the details if there is a mystery.' ) domain_manager.Initialise() login_manager = ClientNetworkingLogin.NetworkLoginManager() self.network_engine = ClientNetworking.NetworkEngine( self, bandwidth_manager, session_manager, domain_manager, login_manager ) self.CallToThreadLongRunning( self.network_engine.MainLoop ) # self._shortcuts_manager = ClientCaches.ShortcutsManager( self ) self.local_booru_manager = ClientCaches.LocalBooruCache( self ) self.pub( 'splash_set_status_subtext', u'tag censorship' ) self._managers[ 'tag_censorship' ] = ClientCaches.TagCensorshipManager( self ) self.pub( 'splash_set_status_subtext', u'tag siblings' ) self._managers[ 'tag_siblings' ] = ClientCaches.TagSiblingsManager( self ) self.pub( 'splash_set_status_subtext', u'tag parents' ) self._managers[ 'tag_parents' ] = ClientCaches.TagParentsManager( self ) self._managers[ 'undo' ] = ClientCaches.UndoManager( self ) def wx_code(): self._caches[ 'images' ] = ClientCaches.RenderedImageCache( self ) self._caches[ 'thumbnail' ] = ClientCaches.ThumbnailCache( self ) CC.GlobalBMPs.STATICInitialise() self.pub( 'splash_set_status_subtext', u'image caches' ) self.CallBlockingToWx( wx_code ) self.sub( self, 'ToClipboard', 'clipboard' ) self.sub( self, 'RestartBooru', 'restart_booru' )