def SetDuplicatePair( self, canvas_key, shown_media, comparison_media ): if canvas_key == self._canvas_key: ( statements, score ) = ClientMedia.GetDuplicateComparisonStatements( shown_media, comparison_media ) self._additional_info_text.SetLabelText( os.linesep.join( statements ) ) self._ResetText() self._ResetButtons()
def _test_local_booru(self, host, port): # connection = httplib.HTTPConnection(host, port, timeout=10) # with open(os.path.join(HC.STATIC_DIR, 'local_booru_style.css'), 'rb') as f: css = f.read() connection.request('GET', '/style.css') response = connection.getresponse() data = response.read() self.assertEqual(data, css) # share_key = HydrusData.GenerateKey() hashes = [HydrusData.GenerateKey() for i in range(5)] client_files_default = os.path.join(TestConstants.DB_DIR, 'client_files') hash_encoded = hashes[0].encode('hex') prefix = hash_encoded[:2] file_path = os.path.join(client_files_default, 'f' + prefix, hash_encoded + '.jpg') thumbnail_path = os.path.join(client_files_default, 't' + prefix, hash_encoded + '.thumbnail') with open(file_path, 'wb') as f: f.write(EXAMPLE_FILE) with open(thumbnail_path, 'wb') as f: f.write(EXAMPLE_THUMBNAIL) local_booru_manager = HG.client_controller.local_booru_manager # self._test_local_booru_requests(connection, share_key, hashes[0], 404) # info = {} info['name'] = 'name' info['text'] = 'text' info['timeout'] = 0 info['hashes'] = hashes file_info_manager = ClientMedia.FileInfoManager( hashes[0], 500, HC.IMAGE_JPEG, 640, 480) media_results = [ ClientMedia.MediaResult( file_info_manager, ClientMedia.TagsManager({}), ClientMedia.LocationsManager(set(), set(), set(), set()), ClientRatings.RatingsManager({})) for hash in hashes ] HG.test_controller.SetRead('local_booru_share_keys', [share_key]) HG.test_controller.SetRead('local_booru_share', info) HG.test_controller.SetRead('media_results', media_results) local_booru_manager.RefreshShares() # self._test_local_booru_requests(connection, share_key, hashes[0], 403) # info['timeout'] = None HG.test_controller.SetRead('local_booru_share', info) local_booru_manager.RefreshShares() # self._test_local_booru_requests(connection, share_key, hashes[0], 200) # HG.test_controller.SetRead('local_booru_share_keys', []) local_booru_manager.RefreshShares() # self._test_local_booru_requests(connection, share_key, hashes[0], 404)
def test_SERIALISABLE_TYPE_DUPLICATE_ACTION_OPTIONS(self): def test(obj, dupe_obj): self.assertEqual(obj.ToTuple(), dupe_obj.ToTuple()) duplicate_action_options_delete_and_move = ClientDuplicates.DuplicateActionOptions( [(CC.LOCAL_TAG_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_MOVE, ClientTags.TagFilter())], [(TC.LOCAL_RATING_LIKE_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_MOVE), (TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_MOVE)], True) duplicate_action_options_copy = ClientDuplicates.DuplicateActionOptions( [(CC.LOCAL_TAG_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_COPY, ClientTags.TagFilter())], [(TC.LOCAL_RATING_LIKE_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_COPY), (TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_COPY)], False) duplicate_action_options_merge = ClientDuplicates.DuplicateActionOptions( [(CC.LOCAL_TAG_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_TWO_WAY_MERGE, ClientTags.TagFilter())], [(TC.LOCAL_RATING_LIKE_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_TWO_WAY_MERGE), (TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_TWO_WAY_MERGE)], False) inbox = True size = 40960 mime = HC.IMAGE_JPEG width = 640 height = 480 duration = None num_frames = None num_words = None local_locations_manager = ClientMedia.LocationsManager( {CC.LOCAL_FILE_SERVICE_KEY, CC.COMBINED_LOCAL_FILE_SERVICE_KEY}, set(), set(), set(), inbox) trash_locations_manager = ClientMedia.LocationsManager( {CC.TRASH_SERVICE_KEY, CC.COMBINED_LOCAL_FILE_SERVICE_KEY}, set(), set(), set(), inbox) deleted_locations_manager = ClientMedia.LocationsManager( set(), {CC.COMBINED_LOCAL_FILE_SERVICE_KEY}, set(), set(), inbox) # duplicate to generate proper dicts one_tags_manager = ClientMedia.TagsManager({ CC.LOCAL_TAG_SERVICE_KEY: { HC.CONTENT_STATUS_CURRENT: {'one'} } }).Duplicate() two_tags_manager = ClientMedia.TagsManager({ CC.LOCAL_TAG_SERVICE_KEY: { HC.CONTENT_STATUS_CURRENT: {'two'} } }).Duplicate() substantial_tags_manager = ClientMedia.TagsManager({ CC.LOCAL_TAG_SERVICE_KEY: { HC.CONTENT_STATUS_CURRENT: {'test tag', 'series:namespaced test tag'} } }).Duplicate() empty_tags_manager = ClientMedia.TagsManager({}).Duplicate() one_ratings_manager = ClientRatings.RatingsManager({ TC.LOCAL_RATING_LIKE_SERVICE_KEY: 1.0, TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY: 0.8 }) two_ratings_manager = ClientRatings.RatingsManager({ TC.LOCAL_RATING_LIKE_SERVICE_KEY: 0.0, TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY: 0.6 }) substantial_ratings_manager = ClientRatings.RatingsManager({ TC.LOCAL_RATING_LIKE_SERVICE_KEY: 1.0, TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY: 0.8 }) empty_ratings_manager = ClientRatings.RatingsManager({}) # local_hash_has_values = HydrusData.GenerateKey() file_info_manager = ClientMedia.FileInfoManager( local_hash_has_values, size, mime, width, height, duration, num_frames, num_words) media_result = ClientMedia.MediaResult(file_info_manager, substantial_tags_manager, local_locations_manager, substantial_ratings_manager) local_media_has_values = ClientMedia.MediaSingleton(media_result) # other_local_hash_has_values = HydrusData.GenerateKey() file_info_manager = ClientMedia.FileInfoManager( other_local_hash_has_values, size, mime, width, height, duration, num_frames, num_words) media_result = ClientMedia.MediaResult(file_info_manager, substantial_tags_manager, local_locations_manager, substantial_ratings_manager) other_local_media_has_values = ClientMedia.MediaSingleton(media_result) # local_hash_empty = HydrusData.GenerateKey() file_info_manager = ClientMedia.FileInfoManager( local_hash_empty, size, mime, width, height, duration, num_frames, num_words) media_result = ClientMedia.MediaResult(file_info_manager, empty_tags_manager, local_locations_manager, empty_ratings_manager) local_media_empty = ClientMedia.MediaSingleton(media_result) # trashed_hash_empty = HydrusData.GenerateKey() file_info_manager = ClientMedia.FileInfoManager( trashed_hash_empty, size, mime, width, height, duration, num_frames, num_words) media_result = ClientMedia.MediaResult(file_info_manager, empty_tags_manager, trash_locations_manager, empty_ratings_manager) trashed_media_empty = ClientMedia.MediaSingleton(media_result) # deleted_hash_empty = HydrusData.GenerateKey() file_info_manager = ClientMedia.FileInfoManager( deleted_hash_empty, size, mime, width, height, duration, num_frames, num_words) media_result = ClientMedia.MediaResult(file_info_manager, empty_tags_manager, deleted_locations_manager, empty_ratings_manager) deleted_media_empty = ClientMedia.MediaSingleton(media_result) # one_hash = HydrusData.GenerateKey() file_info_manager = ClientMedia.FileInfoManager( one_hash, size, mime, width, height, duration, num_frames, num_words) media_result = ClientMedia.MediaResult(file_info_manager, one_tags_manager, local_locations_manager, one_ratings_manager) one_media = ClientMedia.MediaSingleton(media_result) # two_hash = HydrusData.GenerateKey() file_info_manager = ClientMedia.FileInfoManager( two_hash, size, mime, width, height, duration, num_frames, num_words) media_result = ClientMedia.MediaResult(file_info_manager, two_tags_manager, local_locations_manager, two_ratings_manager) two_media = ClientMedia.MediaSingleton(media_result) # self._dump_and_load_and_test(duplicate_action_options_delete_and_move, test) self._dump_and_load_and_test(duplicate_action_options_copy, test) self._dump_and_load_and_test(duplicate_action_options_merge, test) # def assertSCUEqual(one, two): self.assertEqual( TC.ConvertServiceKeysToContentUpdatesToComparable(one), TC.ConvertServiceKeysToContentUpdatesToComparable(two)) # result = duplicate_action_options_delete_and_move.ProcessPairIntoContentUpdates( local_media_has_values, local_media_empty) scu = {} scu[CC.LOCAL_FILE_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_DELETE, {local_hash_empty}) ] assertSCUEqual(result[0], scu) # result = duplicate_action_options_delete_and_move.ProcessPairIntoContentUpdates( local_media_has_values, trashed_media_empty) scu = {} scu[CC.TRASH_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_DELETE, {trashed_hash_empty}) ] assertSCUEqual(result[0], scu) # result = duplicate_action_options_delete_and_move.ProcessPairIntoContentUpdates( local_media_has_values, deleted_media_empty) self.assertEqual(result, []) # result = duplicate_action_options_delete_and_move.ProcessPairIntoContentUpdates( local_media_has_values, other_local_media_has_values) scu = {} scu[CC.LOCAL_TAG_SERVICE_KEY] = [ HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_DELETE, ('test tag', {other_local_hash_has_values})), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_DELETE, ('series:namespaced test tag', {other_local_hash_has_values})) ] scu[TC.LOCAL_RATING_LIKE_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (None, {other_local_hash_has_values})) ] scu[TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (None, {other_local_hash_has_values})) ] assertSCUEqual(result[0], scu) scu = {} scu[CC.LOCAL_FILE_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_DELETE, {other_local_hash_has_values}) ] assertSCUEqual(result[1], scu) # result = duplicate_action_options_delete_and_move.ProcessPairIntoContentUpdates( local_media_empty, other_local_media_has_values) scu = {} scu[CC.LOCAL_TAG_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('test tag', {local_hash_empty})), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('series:namespaced test tag', {local_hash_empty})), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_DELETE, ('test tag', {other_local_hash_has_values})), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_DELETE, ('series:namespaced test tag', {other_local_hash_has_values})) ] scu[TC.LOCAL_RATING_LIKE_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (1.0, {local_hash_empty})), HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (None, {other_local_hash_has_values})) ] scu[TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (0.8, {local_hash_empty})), HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (None, {other_local_hash_has_values})) ] assertSCUEqual(result[0], scu) scu = {} scu[CC.LOCAL_FILE_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_DELETE, {other_local_hash_has_values}) ] assertSCUEqual(result[1], scu) # # result = duplicate_action_options_copy.ProcessPairIntoContentUpdates( local_media_has_values, local_media_empty) self.assertEqual(result, []) # result = duplicate_action_options_copy.ProcessPairIntoContentUpdates( local_media_empty, other_local_media_has_values) scu = {} scu[CC.LOCAL_TAG_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('test tag', {local_hash_empty})), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('series:namespaced test tag', {local_hash_empty})) ] scu[TC.LOCAL_RATING_LIKE_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (1.0, {local_hash_empty})) ] scu[TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (0.8, {local_hash_empty})) ] assertSCUEqual(result[0], scu) # # result = duplicate_action_options_merge.ProcessPairIntoContentUpdates( local_media_has_values, local_media_empty) scu = {} scu[CC.LOCAL_TAG_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('test tag', {local_hash_empty})), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('series:namespaced test tag', {local_hash_empty})) ] scu[TC.LOCAL_RATING_LIKE_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (1.0, {local_hash_empty})) ] scu[TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (0.8, {local_hash_empty})) ] assertSCUEqual(result[0], scu) # result = duplicate_action_options_merge.ProcessPairIntoContentUpdates( local_media_empty, other_local_media_has_values) scu = {} scu[CC.LOCAL_TAG_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('test tag', {local_hash_empty})), HydrusData.ContentUpdate( HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('series:namespaced test tag', {local_hash_empty})) ] scu[TC.LOCAL_RATING_LIKE_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (1.0, {local_hash_empty})) ] scu[TC.LOCAL_RATING_NUMERICAL_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_RATINGS, HC.CONTENT_UPDATE_ADD, (0.8, {local_hash_empty})) ] assertSCUEqual(result[0], scu) # result = duplicate_action_options_merge.ProcessPairIntoContentUpdates( one_media, two_media) scu = {} scu[CC.LOCAL_TAG_SERVICE_KEY] = [ HydrusData.ContentUpdate(HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('one', {two_hash})), HydrusData.ContentUpdate(HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_ADD, ('two', {one_hash})) ] assertSCUEqual(result[0], scu)
def _test_local_booru(self, host, port): # connection = httplib.HTTPConnection(host, port, timeout=10) # with open(os.path.join(HC.STATIC_DIR, 'local_booru_style.css'), 'rb') as f: css = f.read() connection.request('GET', '/style.css') response = connection.getresponse() data = response.read() self.assertEqual(data, css) # share_key = HydrusData.GenerateKey() hashes = [HydrusData.GenerateKey() for i in range(5)] client_files_default = os.path.join(HC.DB_DIR, 'client_files') hash_encoded = hashes[0].encode('hex') prefix = hash_encoded[:2] file_path = os.path.join(client_files_default, 'f' + prefix, hash_encoded + '.jpg') thumbnail_path = os.path.join(client_files_default, 't' + prefix, hash_encoded + '.thumbnail') with open(file_path, 'wb') as f: f.write('file') with open(thumbnail_path, 'wb') as f: f.write('thumbnail') local_booru_manager = HydrusGlobals.test_controller.GetManager( 'local_booru') # self._test_local_booru_requests(connection, share_key, hashes[0], 404) # info = {} info['name'] = 'name' info['text'] = 'text' info['timeout'] = 0 info['hashes'] = hashes # hash, inbox, size, mime, width, height, duration, num_frames, num_words, tags_manager, locations_manager, ratings_manager media_results = [ ClientMedia.MediaResult((hash, True, 500, HC.IMAGE_JPEG, 640, 480, None, None, None, None, None, None)) for hash in hashes ] HydrusGlobals.test_controller.SetRead('local_booru_share_keys', [share_key]) HydrusGlobals.test_controller.SetRead('local_booru_share', info) HydrusGlobals.test_controller.SetRead('media_results', media_results) local_booru_manager.RefreshShares() # self._test_local_booru_requests(connection, share_key, hashes[0], 403) # info['timeout'] = None HydrusGlobals.test_controller.SetRead('local_booru_share', info) local_booru_manager.RefreshShares() # self._test_local_booru_requests(connection, share_key, hashes[0], 200) # HydrusGlobals.test_controller.SetRead('local_booru_share_keys', []) local_booru_manager.RefreshShares() # self._test_local_booru_requests(connection, share_key, hashes[0], 404)
def _InitialiseDefaults( self, db_dir ): self._dictionary[ 'booleans' ] = {} self._dictionary[ 'booleans' ][ 'advanced_mode' ] = False self._dictionary[ 'booleans' ][ 'always_show_hover_windows' ] = False self._dictionary[ 'booleans' ][ 'apply_all_parents_to_all_services' ] = False self._dictionary[ 'booleans' ][ 'apply_all_siblings_to_all_services' ] = False self._dictionary[ 'booleans' ][ 'filter_inbox_and_archive_predicates' ] = False self._dictionary[ 'booleans' ][ 'discord_dnd_fix' ] = False self._dictionary[ 'booleans' ][ 'disable_cv_for_gifs' ] = False self._dictionary[ 'booleans' ][ 'add_parents_on_manage_tags' ] = True self._dictionary[ 'booleans' ][ 'replace_siblings_on_manage_tags' ] = True self._dictionary[ 'booleans' ][ 'show_related_tags' ] = False self._dictionary[ 'booleans' ][ 'show_file_lookup_script_tags' ] = False self._dictionary[ 'booleans' ][ 'hide_message_manager_on_gui_iconise' ] = HC.PLATFORM_OSX self._dictionary[ 'booleans' ][ 'hide_message_manager_on_gui_deactive' ] = False self._dictionary[ 'booleans' ][ 'load_images_with_pil' ] = False self._dictionary[ 'booleans' ][ 'use_system_ffmpeg' ] = False self._dictionary[ 'booleans' ][ 'maintain_similar_files_duplicate_pairs_during_idle' ] = False self._dictionary[ 'booleans' ][ 'show_namespaces' ] = True self._dictionary[ 'booleans' ][ 'verify_regular_https' ] = True self._dictionary[ 'booleans' ][ 'reverse_page_shift_drag_behaviour' ] = False self._dictionary[ 'booleans' ][ 'anchor_and_hide_canvas_drags' ] = HC.PLATFORM_WINDOWS self._dictionary[ 'booleans' ][ 'thumbnail_fill' ] = False self._dictionary[ 'booleans' ][ 'import_page_progress_display' ] = True self._dictionary[ 'booleans' ][ 'process_subs_in_random_order' ] = True self._dictionary[ 'booleans' ][ 'ac_select_first_with_count' ] = False self._dictionary[ 'booleans' ][ 'saving_sash_positions_on_exit' ] = True self._dictionary[ 'booleans' ][ 'pause_all_new_network_traffic' ] = False self._dictionary[ 'booleans' ][ 'notebook_tabs_on_left' ] = False self._dictionary[ 'booleans' ][ 'popup_message_force_min_width' ] = False self._dictionary[ 'booleans' ][ 'always_show_iso_time' ] = False self._dictionary[ 'booleans' ][ 'show_deleted_on_file_seed_short_summary' ] = False self._dictionary[ 'booleans' ][ 'only_save_last_session_during_idle' ] = False self._dictionary[ 'booleans' ][ 'do_human_sort_on_hdd_file_import_paths' ] = True self._dictionary[ 'booleans' ][ 'highlight_new_watcher' ] = False self._dictionary[ 'booleans' ][ 'highlight_new_query' ] = False # self._dictionary[ 'colours' ] = HydrusSerialisable.SerialisableDictionary() self._dictionary[ 'colours' ][ 'default' ] = HydrusSerialisable.SerialisableDictionary() self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_THUMB_BACKGROUND ] = ( 255, 255, 255 ) self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_THUMB_BACKGROUND_SELECTED ] = ( 217, 242, 255 ) # light blue self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_THUMB_BACKGROUND_REMOTE ] = ( 32, 32, 36 ) # 50% Payne's Gray self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_THUMB_BACKGROUND_REMOTE_SELECTED ] = ( 64, 64, 72 ) # Payne's Gray self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_THUMB_BORDER ] = ( 223, 227, 230 ) # light grey self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_THUMB_BORDER_SELECTED ] = ( 1, 17, 26 ) # dark grey self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_THUMB_BORDER_REMOTE ] = ( 248, 208, 204 ) # 25% Vermillion, 75% White self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_THUMB_BORDER_REMOTE_SELECTED ] = ( 227, 66, 52 ) # Vermillion, lol self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_THUMBGRID_BACKGROUND ] = ( 255, 255, 255 ) self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_AUTOCOMPLETE_BACKGROUND ] = ( 235, 248, 255 ) # very light blue self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_MEDIA_BACKGROUND ] = ( 255, 255, 255 ) self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_MEDIA_TEXT ] = ( 0, 0, 0 ) self._dictionary[ 'colours' ][ 'default' ][ CC.COLOUR_TAGS_BOX ] = ( 255, 255, 255 ) self._dictionary[ 'colours' ][ 'darkmode' ] = HydrusSerialisable.SerialisableDictionary() self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_THUMB_BACKGROUND ] = ( 64, 64, 72 ) # Payne's Gray self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_THUMB_BACKGROUND_SELECTED ] = ( 112, 128, 144 ) # Slate Gray self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_THUMB_BACKGROUND_REMOTE ] = ( 64, 13, 2 ) # Black Bean self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_THUMB_BACKGROUND_REMOTE_SELECTED ] = ( 171, 39, 79 ) # Amaranth Purple self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_THUMB_BORDER ] = ( 145, 163, 176 ) # Cadet Grey self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_THUMB_BORDER_SELECTED ] = ( 223, 227, 230 ) # light grey self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_THUMB_BORDER_REMOTE ] = ( 248, 208, 204 ) # 25% Vermillion, 75% White self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_THUMB_BORDER_REMOTE_SELECTED ] = ( 227, 66, 52 ) # Vermillion, lol self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_THUMBGRID_BACKGROUND ] = ( 0, 0, 0 ) self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_AUTOCOMPLETE_BACKGROUND ] = ( 83, 98, 103 ) # Gunmetal self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_MEDIA_BACKGROUND ] = ( 0, 0, 0 ) self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_MEDIA_TEXT ] = ( 112, 128, 144 ) # Slate Gray self._dictionary[ 'colours' ][ 'darkmode' ][ CC.COLOUR_TAGS_BOX ] = ( 0, 0, 0 ) # self._dictionary[ 'duplicate_action_options' ] = HydrusSerialisable.SerialisableDictionary() import ClientTags self._dictionary[ 'duplicate_action_options' ][ HC.DUPLICATE_BETTER ] = ClientDuplicates.DuplicateActionOptions( [ ( CC.LOCAL_TAG_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_MOVE, ClientTags.TagFilter() ) ], [], True, True, sync_urls_action = HC.CONTENT_MERGE_ACTION_COPY ) self._dictionary[ 'duplicate_action_options' ][ HC.DUPLICATE_SAME_QUALITY ] = ClientDuplicates.DuplicateActionOptions( [ ( CC.LOCAL_TAG_SERVICE_KEY, HC.CONTENT_MERGE_ACTION_TWO_WAY_MERGE, ClientTags.TagFilter() ) ], [], False, True, sync_urls_action = HC.CONTENT_MERGE_ACTION_TWO_WAY_MERGE ) self._dictionary[ 'duplicate_action_options' ][ HC.DUPLICATE_ALTERNATE ] = ClientDuplicates.DuplicateActionOptions( [], [], False ) self._dictionary[ 'duplicate_action_options' ][ HC.DUPLICATE_NOT_DUPLICATE ] = ClientDuplicates.DuplicateActionOptions( [], [], False ) # self._dictionary[ 'integers' ] = {} self._dictionary[ 'integers' ][ 'video_buffer_size_mb' ] = 96 self._dictionary[ 'integers' ][ 'related_tags_search_1_duration_ms' ] = 250 self._dictionary[ 'integers' ][ 'related_tags_search_2_duration_ms' ] = 2000 self._dictionary[ 'integers' ][ 'related_tags_search_3_duration_ms' ] = 6000 self._dictionary[ 'integers' ][ 'suggested_tags_width' ] = 300 self._dictionary[ 'integers' ][ 'similar_files_duplicate_pairs_search_distance' ] = 0 self._dictionary[ 'integers' ][ 'default_new_page_goes' ] = CC.NEW_PAGE_GOES_FAR_RIGHT self._dictionary[ 'integers' ][ 'max_page_name_chars' ] = 20 self._dictionary[ 'integers' ][ 'page_file_count_display' ] = CC.PAGE_FILE_COUNT_DISPLAY_ALL self._dictionary[ 'integers' ][ 'network_timeout' ] = 10 self._dictionary[ 'integers' ][ 'thumbnail_visibility_scroll_percent' ] = 75 self._dictionary[ 'integers' ][ 'total_pages_warning' ] = 165 self._dictionary[ 'integers' ][ 'last_session_save_period_minutes' ] = 5 self._dictionary[ 'integers' ][ 'max_simultaneous_subscriptions' ] = 1 self._dictionary[ 'integers' ][ 'gallery_page_wait_period_pages' ] = 15 self._dictionary[ 'integers' ][ 'gallery_page_wait_period_subscriptions' ] = 5 self._dictionary[ 'integers' ][ 'popup_message_character_width' ] = 56 self._dictionary[ 'integers' ][ 'video_thumbnail_percentage_in' ] = 35 self._dictionary[ 'integers' ][ 'duplicate_comparison_score_higher_filesize' ] = 20 self._dictionary[ 'integers' ][ 'duplicate_comparison_score_much_higher_filesize' ] = 10 self._dictionary[ 'integers' ][ 'duplicate_comparison_score_higher_resolution' ] = 20 self._dictionary[ 'integers' ][ 'duplicate_comparison_score_much_higher_resolution' ] = 5 self._dictionary[ 'integers' ][ 'duplicate_comparison_score_more_tags' ] = 8 self._dictionary[ 'integers' ][ 'duplicate_comparison_score_older' ] = 5 self._dictionary[ 'integers' ][ 'thumbnail_cache_timeout' ] = 86400 self._dictionary[ 'integers' ][ 'image_cache_timeout' ] = 600 # self._dictionary[ 'keys' ] = {} self._dictionary[ 'keys' ][ 'default_tag_service_search_page' ] = CC.COMBINED_TAG_SERVICE_KEY.encode( 'hex' ) self._dictionary[ 'key_list' ] = {} self._dictionary[ 'key_list' ][ 'default_neighbouring_txt_tag_service_keys' ] = [] # self._dictionary[ 'noneable_integers' ] = {} self._dictionary[ 'noneable_integers' ][ 'forced_search_limit' ] = None self._dictionary[ 'noneable_integers' ][ 'disk_cache_maintenance_mb' ] = 256 self._dictionary[ 'noneable_integers' ][ 'disk_cache_init_period' ] = 4 self._dictionary[ 'noneable_integers' ][ 'num_recent_tags' ] = 20 self._dictionary[ 'noneable_integers' ][ 'maintenance_vacuum_period_days' ] = 30 self._dictionary[ 'noneable_integers' ][ 'duplicate_background_switch_intensity' ] = 3 self._dictionary[ 'noneable_integers' ][ 'last_review_bandwidth_search_distance' ] = 7 * 86400 # self._dictionary[ 'simple_downloader_formulae' ] = HydrusSerialisable.SerialisableList() # self._dictionary[ 'noneable_strings' ] = {} self._dictionary[ 'noneable_strings' ][ 'favourite_file_lookup_script' ] = 'gelbooru md5' self._dictionary[ 'noneable_strings' ][ 'suggested_tags_layout' ] = 'notebook' self._dictionary[ 'noneable_strings' ][ 'backup_path' ] = None self._dictionary[ 'noneable_strings' ][ 'temp_path_override' ] = None self._dictionary[ 'noneable_strings' ][ 'web_browser_path' ] = None self._dictionary[ 'noneable_strings' ][ 'last_png_export_dir' ] = None self._dictionary[ 'strings' ] = {} self._dictionary[ 'strings' ][ 'main_gui_title' ] = 'hydrus client' self._dictionary[ 'strings' ][ 'namespace_connector' ] = ':' self._dictionary[ 'strings' ][ 'export_phrase' ] = '{hash}' self._dictionary[ 'strings' ][ 'current_colourset' ] = 'default' self._dictionary[ 'strings' ][ 'favourite_simple_downloader_formula' ] = 'all files linked by images in page' self._dictionary[ 'strings' ][ 'thumbnail_scroll_rate' ] = '1.0' self._dictionary[ 'string_list' ] = {} self._dictionary[ 'string_list' ][ 'default_media_viewer_custom_shortcuts' ] = [] self._dictionary[ 'string_list' ][ 'favourite_tags' ] = [] # self._dictionary[ 'tag_summary_generators' ] = HydrusSerialisable.SerialisableDictionary() namespace_info = [] namespace_info.append( ( 'creator', '', ', ' ) ) namespace_info.append( ( 'series', '', ', ' ) ) namespace_info.append( ( 'title', '', ', ' ) ) separator = ' - ' # the cleantags here converts to unicode, which is important! example_tags = HydrusTags.CleanTags( [ 'creator:creator', 'series:series', 'title:title' ] ) import ClientGUITags tsg = ClientGUITags.TagSummaryGenerator( namespace_info = namespace_info, separator = separator, example_tags = example_tags ) self._dictionary[ 'tag_summary_generators' ][ 'thumbnail_top' ] = tsg namespace_info = [] namespace_info.append( ( 'volume', 'v', '-' ) ) namespace_info.append( ( 'chapter', 'c', '-' ) ) namespace_info.append( ( 'page', 'p', '-' ) ) separator = '-' example_tags = HydrusTags.CleanTags( [ 'volume:3', 'chapter:10', 'page:330', 'page:331' ] ) tsg = ClientGUITags.TagSummaryGenerator( namespace_info = namespace_info, separator = separator, example_tags = example_tags ) self._dictionary[ 'tag_summary_generators' ][ 'thumbnail_bottom_right' ] = tsg namespace_info = [] namespace_info.append( ( 'creator', '', ', ' ) ) namespace_info.append( ( 'series', '', ', ' ) ) namespace_info.append( ( 'title', '', ', ' ) ) namespace_info.append( ( 'volume', 'v', '-' ) ) namespace_info.append( ( 'chapter', 'c', '-' ) ) namespace_info.append( ( 'page', 'p', '-' ) ) separator = ' - ' example_tags = HydrusTags.CleanTags( [ 'creator:creator', 'series:series', 'title:title', 'volume:1', 'chapter:1', 'page:1' ] ) tsg = ClientGUITags.TagSummaryGenerator( namespace_info = namespace_info, separator = separator, example_tags = example_tags ) self._dictionary[ 'tag_summary_generators' ][ 'media_viewer_top' ] = tsg # client_files_default = os.path.join( db_dir, 'client_files' ) self._dictionary[ 'client_files_locations_ideal_weights' ] = [ ( HydrusPaths.ConvertAbsPathToPortablePath( client_files_default ), 1.0 ) ] self._dictionary[ 'client_files_locations_resized_thumbnail_override' ] = None self._dictionary[ 'client_files_locations_full_size_thumbnail_override' ] = None # self._dictionary[ 'default_file_import_options' ] = HydrusSerialisable.SerialisableDictionary() exclude_deleted = True allow_decompression_bombs = False min_size = None max_size = None max_gif_size = 32 * 1048576 min_resolution = None max_resolution = None automatic_archive = False present_new_files = True present_already_in_inbox_files = False present_already_in_archive_files = False import ClientImportOptions quiet_file_import_options = ClientImportOptions.FileImportOptions() quiet_file_import_options.SetPreImportOptions( exclude_deleted, allow_decompression_bombs, min_size, max_size, max_gif_size, min_resolution, max_resolution ) quiet_file_import_options.SetPostImportOptions( automatic_archive ) quiet_file_import_options.SetPresentationOptions( present_new_files, present_already_in_inbox_files, present_already_in_archive_files ) self._dictionary[ 'default_file_import_options' ][ 'quiet' ] = quiet_file_import_options present_new_files = True present_already_in_inbox_files = True present_already_in_archive_files = True loud_file_import_options = ClientImportOptions.FileImportOptions() loud_file_import_options.SetPreImportOptions( exclude_deleted, allow_decompression_bombs, min_size, max_size, max_gif_size, min_resolution, max_resolution ) loud_file_import_options.SetPostImportOptions( automatic_archive ) loud_file_import_options.SetPresentationOptions( present_new_files, present_already_in_inbox_files, present_already_in_archive_files ) self._dictionary[ 'default_file_import_options' ][ 'loud' ] = loud_file_import_options # self._dictionary[ 'frame_locations' ] = {} # remember size, remember position, last_size, last_pos, default gravity, default position, maximised, fullscreen self._dictionary[ 'frame_locations' ][ 'file_import_status' ] = ( True, True, None, None, ( -1, -1 ), 'topleft', False, False ) self._dictionary[ 'frame_locations' ][ 'gallery_import_log' ] = ( True, True, None, None, ( -1, -1 ), 'topleft', False, False ) self._dictionary[ 'frame_locations' ][ 'local_import_filename_tagging' ] = ( True, False, None, None, ( -1, -1 ), 'topleft', False, False ) self._dictionary[ 'frame_locations' ][ 'main_gui' ] = ( True, True, ( 800, 600 ), ( 20, 20 ), ( -1, -1 ), 'topleft', True, False ) self._dictionary[ 'frame_locations' ][ 'manage_options_dialog' ] = ( False, False, None, None, ( -1, -1 ), 'topleft', False, False ) self._dictionary[ 'frame_locations' ][ 'manage_subscriptions_dialog' ] = ( True, True, None, None, ( 1, -1 ), 'topleft', False, False ) self._dictionary[ 'frame_locations' ][ 'manage_tags_dialog' ] = ( False, False, None, None, ( -1, 1 ), 'topleft', False, False ) self._dictionary[ 'frame_locations' ][ 'manage_tags_frame' ] = ( False, False, None, None, ( -1, 1 ), 'topleft', False, False ) self._dictionary[ 'frame_locations' ][ 'media_viewer' ] = ( True, True, ( 640, 480 ), ( 70, 70 ), ( -1, -1 ), 'topleft', True, True ) self._dictionary[ 'frame_locations' ][ 'regular_dialog' ] = ( False, False, None, None, ( -1, -1 ), 'topleft', False, False ) self._dictionary[ 'frame_locations' ][ 'review_services' ] = ( False, True, None, None, ( -1, -1 ), 'topleft', False, False ) self._dictionary[ 'frame_locations' ][ 'deeply_nested_dialog' ] = ( False, False, None, None, ( -1, -1 ), 'topleft', False, False ) # self._dictionary[ 'media_launch' ] = HydrusSerialisable.SerialisableDictionary() # integer keys, so got to be cleverer dict for mime in HC.SEARCHABLE_MIMES: self._dictionary[ 'media_launch' ][ mime ] = None # self._dictionary[ 'media_view' ] = HydrusSerialisable.SerialisableDictionary() # integer keys, so got to be cleverer dict # media_show_action, preview_show_action, ( media_scale_up, media_scale_down, preview_scale_up, preview_scale_down, exact_zooms_only, scale_up_quality, scale_down_quality ) ) image_zoom_info = ( CC.MEDIA_VIEWER_SCALE_TO_CANVAS, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, False, CC.ZOOM_LANCZOS4, CC.ZOOM_AREA ) gif_zoom_info = ( CC.MEDIA_VIEWER_SCALE_MAX_REGULAR, CC.MEDIA_VIEWER_SCALE_MAX_REGULAR, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, True, CC.ZOOM_LANCZOS4, CC.ZOOM_AREA ) flash_zoom_info = ( CC.MEDIA_VIEWER_SCALE_TO_CANVAS, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, False, CC.ZOOM_LINEAR, CC.ZOOM_LINEAR ) video_zoom_info = ( CC.MEDIA_VIEWER_SCALE_100, CC.MEDIA_VIEWER_SCALE_MAX_REGULAR, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, CC.MEDIA_VIEWER_SCALE_TO_CANVAS, True, CC.ZOOM_LANCZOS4, CC.ZOOM_AREA ) null_zoom_info = ( CC.MEDIA_VIEWER_SCALE_100, CC.MEDIA_VIEWER_SCALE_100, CC.MEDIA_VIEWER_SCALE_100, CC.MEDIA_VIEWER_SCALE_100, False, CC.ZOOM_LINEAR, CC.ZOOM_LINEAR ) self._dictionary[ 'media_view' ][ HC.IMAGE_JPEG ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, image_zoom_info ) self._dictionary[ 'media_view' ][ HC.IMAGE_PNG ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, image_zoom_info ) self._dictionary[ 'media_view' ][ HC.IMAGE_APNG ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, gif_zoom_info ) self._dictionary[ 'media_view' ][ HC.IMAGE_GIF ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, gif_zoom_info ) if HC.PLATFORM_WINDOWS: self._dictionary[ 'media_view' ][ HC.APPLICATION_FLASH ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_BEHIND_EMBED, CC.MEDIA_VIEWER_ACTION_SHOW_BEHIND_EMBED, flash_zoom_info ) else: self._dictionary[ 'media_view' ][ HC.APPLICATION_FLASH ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.APPLICATION_PDF ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.APPLICATION_ZIP ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.APPLICATION_7Z ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.APPLICATION_RAR ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.APPLICATION_HYDRUS_UPDATE_CONTENT ] = ( CC.MEDIA_VIEWER_ACTION_DO_NOT_SHOW, CC.MEDIA_VIEWER_ACTION_DO_NOT_SHOW, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.APPLICATION_HYDRUS_UPDATE_DEFINITIONS ] = ( CC.MEDIA_VIEWER_ACTION_DO_NOT_SHOW, CC.MEDIA_VIEWER_ACTION_DO_NOT_SHOW, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.VIDEO_AVI ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, video_zoom_info ) self._dictionary[ 'media_view' ][ HC.VIDEO_FLV ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, video_zoom_info ) self._dictionary[ 'media_view' ][ HC.VIDEO_MOV ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, video_zoom_info ) self._dictionary[ 'media_view' ][ HC.VIDEO_MP4 ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, video_zoom_info ) self._dictionary[ 'media_view' ][ HC.VIDEO_MPEG ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, video_zoom_info ) self._dictionary[ 'media_view' ][ HC.VIDEO_MKV ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, video_zoom_info ) self._dictionary[ 'media_view' ][ HC.VIDEO_WEBM ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, video_zoom_info ) self._dictionary[ 'media_view' ][ HC.VIDEO_WMV ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, CC.MEDIA_VIEWER_ACTION_SHOW_AS_NORMAL, video_zoom_info ) self._dictionary[ 'media_view' ][ HC.AUDIO_MP3 ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.AUDIO_OGG ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.AUDIO_FLAC ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, null_zoom_info ) self._dictionary[ 'media_view' ][ HC.AUDIO_WMA ] = ( CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, CC.MEDIA_VIEWER_ACTION_SHOW_OPEN_EXTERNALLY_BUTTON, null_zoom_info ) self._dictionary[ 'media_zooms' ] = [ 0.01, 0.05, 0.1, 0.15, 0.2, 0.3, 0.5, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.5, 2.0, 3.0, 5.0, 10.0, 20.0 ] # self._dictionary[ 'misc' ] = HydrusSerialisable.SerialisableDictionary() self._dictionary[ 'misc' ][ 'default_thread_watcher_options' ] = ClientDefaults.GetDefaultCheckerOptions( 'thread' ) self._dictionary[ 'misc' ][ 'default_subscription_checker_options' ] = ClientDefaults.GetDefaultCheckerOptions( 'artist subscription' ) # self._dictionary[ 'suggested_tags' ] = HydrusSerialisable.SerialisableDictionary() self._dictionary[ 'suggested_tags' ][ 'favourites' ] = {} # import ClientMedia self._dictionary[ 'default_sort' ] = ClientMedia.MediaSort( ( 'system', CC.SORT_FILES_BY_FILESIZE ), CC.SORT_ASC ) self._dictionary[ 'fallback_sort' ] = ClientMedia.MediaSort( ( 'system', CC.SORT_FILES_BY_IMPORT_TIME ), CC.SORT_ASC )
def _test_local_booru(self, host, port): # connection = httplib.HTTPConnection(host, port, timeout=10) # with open(os.path.join(HC.STATIC_DIR, 'local_booru_style.css'), 'rb') as f: css = f.read() connection.request('GET', '/style.css') response = connection.getresponse() data = response.read() self.assertEqual(data, css) # share_key = HydrusData.GenerateKey() hashes = [HydrusData.GenerateKey() for i in range(5)] with open( ClientFiles.GetExpectedFilePath(HC.CLIENT_FILES_DIR, hashes[0], HC.IMAGE_JPEG), 'wb') as f: f.write('file') with open(ClientFiles.GetExpectedThumbnailPath(hashes[0], False), 'wb') as f: f.write('thumbnail') local_booru_manager = HydrusGlobals.test_controller.GetManager( 'local_booru') # self._test_local_booru_requests(connection, share_key, hashes[0], 404) # info = {} info['name'] = 'name' info['text'] = 'text' info['timeout'] = 0 info['hashes'] = hashes # hash, inbox, size, mime, width, height, duration, num_frames, num_words, tags_manager, locations_manager, local_ratings, remote_ratings media_results = [ ClientMedia.MediaResult((hash, True, 500, HC.IMAGE_JPEG, 640, 480, None, None, None, None, None, None, None)) for hash in hashes ] HydrusGlobals.test_controller.SetRead('local_booru_share_keys', [share_key]) HydrusGlobals.test_controller.SetRead('local_booru_share', info) HydrusGlobals.test_controller.SetRead('media_results', media_results) local_booru_manager.RefreshShares() # self._test_local_booru_requests(connection, share_key, hashes[0], 403) # info['timeout'] = None HydrusGlobals.test_controller.SetRead('local_booru_share', info) local_booru_manager.RefreshShares() # self._test_local_booru_requests(connection, share_key, hashes[0], 200) # HydrusGlobals.test_controller.SetRead('local_booru_share_keys', []) local_booru_manager.RefreshShares() # self._test_local_booru_requests(connection, share_key, hashes[0], 404)