Version 198
This commit is contained in:
parent
74dbea0f18
commit
edba55b7a4
|
@ -8,6 +8,24 @@
|
|||
<div class="content">
|
||||
<h3>changelog</h3>
|
||||
<ul>
|
||||
<li><h3>version 198</h3></li>
|
||||
<ul>
|
||||
<li>ipfs download now parses directory multihashes</li>
|
||||
<li>ipfs directory trees are thrown up on a new checkbox tree dialog for selection/filtering</li>
|
||||
<li>created a new download_urls (i.e. multiple urls in one popup) popup call, which the new ipfs directory downloader uses</li>
|
||||
<li>improved a very inefficient line of sql in the mappings fetch stage of query result building that was also used in the manage tags dialog. on my dev machine, fetching 256 files' mappings dropped from 2.5s to 9ms!</li>
|
||||
<li>regular gallery pages and 'page of images' pages now have a 'paste input' button to mass-add newline-separated queries from the clipboard</li>
|
||||
<li>fixed a typo in new txt_tags import folder code</li>
|
||||
<li>fixed bad autocomplete predicate sorting</li>
|
||||
<li>fixed some sibling autocomplete search_text matching logic</li>
|
||||
<li>some byte-based value/range presentation will now correctly convert to bytes, rather than regular decimal numbers</li>
|
||||
<li>improved linesep splitting code across the program</li>
|
||||
<li>fixed get/setlabel calls across the program to get/setlabeltext, so ampersand characters are handled properly</li>
|
||||
<li>wrote an 'all known files' autocomplete cache db and prepped a bunch of code for it--it should be easy to finish next week</li>
|
||||
<li>added a new regex practise link to the regex dialogs</li>
|
||||
<li>os x release should display better on retina displays</li>
|
||||
<li>misc cleanup</li>
|
||||
</ul>
|
||||
<li><h3>version 197</h3></li>
|
||||
<ul>
|
||||
<li>on client boot, autocomplete caches for specific file/tag service cross-references are now initialised and populated. progress is shown on the splash window</li>
|
||||
|
|
|
@ -1072,9 +1072,9 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
for tag_service_id in tag_service_ids:
|
||||
|
||||
ac_cache = self._ac_caches[ ( service_id, tag_service_id ) ]
|
||||
specific_ac_cache = self._specific_ac_caches[ ( service_id, tag_service_id ) ]
|
||||
|
||||
ac_cache.SimpleWrite( 'add_files', valid_hash_ids )
|
||||
specific_ac_cache.SimpleWrite( 'add_files', valid_hash_ids )
|
||||
|
||||
current_mapping_ids_raw = self._c.execute( 'SELECT namespace_id, tag_id, hash_id FROM mappings WHERE service_id = ? AND status = ? AND hash_id IN ' + splayed_valid_hash_ids + ';', ( tag_service_id, HC.CURRENT ) ).fetchall()
|
||||
|
||||
|
@ -1084,7 +1084,7 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
current_mapping_ids = [ ( namespace_id, tag_id, hash_ids ) for ( ( namespace_id, tag_id ), hash_ids ) in current_mapping_ids_dict.items() ]
|
||||
|
||||
ac_cache.SimpleWrite( 'add_mappings', current_mapping_ids )
|
||||
specific_ac_cache.SimpleWrite( 'add_mappings', current_mapping_ids )
|
||||
|
||||
|
||||
pending_mapping_ids_raw = self._c.execute( 'SELECT namespace_id, tag_id, hash_id FROM mappings WHERE service_id = ? AND status = ? AND hash_id IN ' + splayed_valid_hash_ids + ';', ( tag_service_id, HC.PENDING ) ).fetchall()
|
||||
|
@ -1095,7 +1095,7 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
pending_mapping_ids = [ ( namespace_id, tag_id, hash_ids ) for ( ( namespace_id, tag_id ), hash_ids ) in pending_mapping_ids_dict.items() ]
|
||||
|
||||
ac_cache.SimpleWrite( 'pend_mappings', pending_mapping_ids )
|
||||
specific_ac_cache.SimpleWrite( 'pend_mappings', pending_mapping_ids )
|
||||
|
||||
|
||||
|
||||
|
@ -1191,29 +1191,27 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
service_id = self._c.lastrowid
|
||||
|
||||
ac_cache_pairs_to_create = []
|
||||
specific_ac_cache_pairs_to_create = []
|
||||
|
||||
if service_type in HC.TAG_SERVICES:
|
||||
|
||||
self._GenerateACCacheCombinedFiles( service_id )
|
||||
|
||||
file_service_ids = self._GetServiceIds( ( HC.LOCAL_FILE, HC.FILE_REPOSITORY ) )
|
||||
|
||||
ac_cache_pairs_to_create.extend( [ ( file_service_id, service_id ) for file_service_id in file_service_ids ] )
|
||||
specific_ac_cache_pairs_to_create.extend( [ ( file_service_id, service_id ) for file_service_id in file_service_ids ] )
|
||||
|
||||
|
||||
if service_type in ( HC.LOCAL_FILE, HC.FILE_REPOSITORY ):
|
||||
|
||||
tag_service_ids = self._GetServiceIds( HC.TAG_SERVICES )
|
||||
|
||||
ac_cache_pairs_to_create.extend( [ ( service_id, tag_service_id ) for tag_service_id in tag_service_ids ] )
|
||||
specific_ac_cache_pairs_to_create.extend( [ ( service_id, tag_service_id ) for tag_service_id in tag_service_ids ] )
|
||||
|
||||
|
||||
for ( file_service_id, tag_service_id ) in ac_cache_pairs_to_create:
|
||||
for ( file_service_id, tag_service_id ) in specific_ac_cache_pairs_to_create:
|
||||
|
||||
db_filename = 'ac_cache_' + str( file_service_id ) + '_' + str( tag_service_id ) + '.db'
|
||||
|
||||
db_path = os.path.join( HC.CLIENT_CACHE_DIR, db_filename )
|
||||
|
||||
self._GenerateACCache( db_path, file_service_id, tag_service_id )
|
||||
self._GenerateACCacheSpecific( file_service_id, tag_service_id )
|
||||
|
||||
|
||||
|
||||
|
@ -1515,7 +1513,7 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
self._tag_archives = {}
|
||||
|
||||
for ac_cache in self._ac_caches.values():
|
||||
for ac_cache in self._specific_ac_caches.values() + self._combined_files_ac_caches.values():
|
||||
|
||||
ac_cache.Shutdown()
|
||||
|
||||
|
@ -1525,7 +1523,8 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
|
||||
|
||||
self._ac_caches = {}
|
||||
self._specific_ac_caches = {}
|
||||
self._combined_files_ac_caches = {}
|
||||
|
||||
|
||||
def _CopyFiles( self, hashes ):
|
||||
|
@ -1762,7 +1761,8 @@ class DB( HydrusDB.HydrusDB ):
|
|||
init_service_info.append( ( CC.COMBINED_TAG_SERVICE_KEY, HC.COMBINED_TAG, CC.COMBINED_TAG_SERVICE_KEY ) )
|
||||
init_service_info.append( ( CC.LOCAL_BOORU_SERVICE_KEY, HC.LOCAL_BOORU, CC.LOCAL_BOORU_SERVICE_KEY ) )
|
||||
|
||||
self._ac_caches = {}
|
||||
self._specific_ac_caches = {}
|
||||
self._combined_files_ac_caches = {}
|
||||
|
||||
for ( service_key, service_type, name ) in init_service_info:
|
||||
|
||||
|
@ -1771,7 +1771,7 @@ class DB( HydrusDB.HydrusDB ):
|
|||
self._AddService( service_key, service_type, name, info )
|
||||
|
||||
|
||||
for ac_cache in self._ac_caches.values():
|
||||
for ac_cache in self._specific_ac_caches.values() + self._combined_files_ac_caches.values():
|
||||
|
||||
ac_cache.Shutdown()
|
||||
|
||||
|
@ -1781,7 +1781,8 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
|
||||
|
||||
del self._ac_caches
|
||||
del self._specific_ac_caches
|
||||
del self._combined_files_ac_caches
|
||||
|
||||
self._c.executemany( 'INSERT INTO yaml_dumps VALUES ( ?, ?, ? );', ( ( YAML_DUMP_ID_REMOTE_BOORU, name, booru ) for ( name, booru ) in ClientDefaults.GetDefaultBoorus().items() ) )
|
||||
|
||||
|
@ -1860,11 +1861,11 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
|
||||
|
||||
ac_caches = self._GetACCaches( file_service_id = service_id )
|
||||
specific_ac_caches = self._GetACCachesSpecific( file_service_id = service_id )
|
||||
|
||||
for ac_cache in ac_caches:
|
||||
for specific_ac_cache in specific_ac_caches:
|
||||
|
||||
ac_cache.SimpleWrite( 'delete_files', valid_hash_ids )
|
||||
specific_ac_cache.SimpleWrite( 'delete_files', valid_hash_ids )
|
||||
|
||||
|
||||
self.pub_after_commit( 'notify_new_pending' )
|
||||
|
@ -2224,7 +2225,13 @@ class DB( HydrusDB.HydrusDB ):
|
|||
job_key.Finish()
|
||||
|
||||
|
||||
def _GenerateACCache( self, db_path, file_service_id, tag_service_id ):
|
||||
def _GenerateACCacheCombinedFiles( self, tag_service_id ):
|
||||
|
||||
return
|
||||
|
||||
db_filename = 'ac_cache_combined_files_' + str( tag_service_id ) + '.db'
|
||||
|
||||
db_path = os.path.join( HC.CLIENT_CACHE_DIR, db_filename )
|
||||
|
||||
populate_it = False
|
||||
|
||||
|
@ -2233,7 +2240,70 @@ class DB( HydrusDB.HydrusDB ):
|
|||
populate_it = True
|
||||
|
||||
|
||||
ac_cache = ClientDBACCache.DB( self._controller, db_path, no_wal = self._no_wal )
|
||||
combined_files_ac_cache = ClientDBACCache.CombinedFilesDB( self._controller, db_path, no_wal = self._no_wal )
|
||||
|
||||
if populate_it:
|
||||
|
||||
unique_mapping_ids = self._c.execute( 'SELECT namespace_id, tag_id FROM existing_tags;' ).fetchall()
|
||||
|
||||
num_done = 0
|
||||
total_to_do = len( unique_mapping_ids )
|
||||
|
||||
for sub_unique_mapping_ids in HydrusData.SplitListIntoChunks( unique_mapping_ids, 5000 ):
|
||||
|
||||
prefix = 'generating combined files ac cache ' + HydrusData.ToUnicode( tag_service_id ) + ': '
|
||||
|
||||
self._controller.pub( 'splash_set_status_text', prefix + 'updating mapping counts ' + HydrusData.ConvertValueRangeToPrettyString( num_done, total_to_do ) )
|
||||
|
||||
count_ids = []
|
||||
|
||||
for ( namespace_id, tag_id ) in sub_unique_mapping_ids:
|
||||
|
||||
current_count = 0
|
||||
pending_count = 0
|
||||
|
||||
results = self._c.execute( 'SELECT status, COUNT( * ) FROM mappings WHERE service_id = ? AND namespace_id = ? AND tag_id = ? AND status IN ( ?, ? ) GROUP BY status;', ( tag_service_id, namespace_id, tag_id, HC.CURRENT, HC.PENDING ) ).fetchall()
|
||||
|
||||
for ( status, count ) in results:
|
||||
|
||||
if status == HC.CURRENT:
|
||||
|
||||
current_count = count
|
||||
|
||||
elif status == HC.PENDING:
|
||||
|
||||
pending_count = count
|
||||
|
||||
|
||||
|
||||
count_ids.append( ( namespace_id, tag_id, current_count, pending_count ) )
|
||||
|
||||
|
||||
combined_files_ac_cache.SimpleWriteSynchronous( 'update_counts', count_ids )
|
||||
|
||||
num_done += len( sub_unique_mapping_ids )
|
||||
|
||||
|
||||
|
||||
self._combined_files_ac_caches[ tag_service_id ] = combined_files_ac_cache
|
||||
|
||||
return db_path
|
||||
|
||||
|
||||
def _GenerateACCacheSpecific( self, file_service_id, tag_service_id ):
|
||||
|
||||
db_filename = 'ac_cache_' + str( file_service_id ) + '_' + str( tag_service_id ) + '.db'
|
||||
|
||||
db_path = os.path.join( HC.CLIENT_CACHE_DIR, db_filename )
|
||||
|
||||
populate_it = False
|
||||
|
||||
if not os.path.exists( db_path ):
|
||||
|
||||
populate_it = True
|
||||
|
||||
|
||||
specific_ac_cache = ClientDBACCache.SpecificServicesDB( self._controller, db_path, no_wal = self._no_wal )
|
||||
|
||||
if populate_it:
|
||||
|
||||
|
@ -2243,7 +2313,7 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
hash_ids = [ hash_id for ( hash_id, ) in self._c.execute( 'SELECT hash_id FROM current_files WHERE service_id = ?;', ( file_service_id, ) ) ]
|
||||
|
||||
ac_cache.SimpleWriteSynchronous( 'add_files', hash_ids )
|
||||
specific_ac_cache.SimpleWriteSynchronous( 'add_files', hash_ids )
|
||||
|
||||
#
|
||||
|
||||
|
@ -2260,37 +2330,39 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
if len( current_mappings_ids ) > 0:
|
||||
|
||||
ac_cache.SimpleWriteSynchronous( 'add_mappings', current_mappings_ids )
|
||||
specific_ac_cache.SimpleWriteSynchronous( 'add_mappings', current_mappings_ids )
|
||||
|
||||
|
||||
pending_mappings_ids = [ ( namespace_id, tag_id, [ hash_id for ( hash_id, ) in self._c.execute( 'SELECT hash_id FROM mappings, current_files USING ( hash_id ) WHERE current_files.service_id = ? AND mappings.service_id = ? AND namespace_id = ? AND tag_id = ? AND status = ?;', ( file_service_id, tag_service_id, namespace_id, tag_id, HC.PENDING ) ) ] ) for ( namespace_id, tag_id ) in sub_unique_mapping_ids ]
|
||||
|
||||
if len( pending_mappings_ids ) > 0:
|
||||
|
||||
ac_cache.SimpleWriteSynchronous( 'pend_mappings', pending_mappings_ids )
|
||||
specific_ac_cache.SimpleWriteSynchronous( 'pend_mappings', pending_mappings_ids )
|
||||
|
||||
|
||||
num_done += len( sub_unique_mapping_ids )
|
||||
|
||||
|
||||
|
||||
self._ac_caches[ ( file_service_id, tag_service_id ) ] = ac_cache
|
||||
self._specific_ac_caches[ ( file_service_id, tag_service_id ) ] = specific_ac_cache
|
||||
|
||||
return db_path
|
||||
|
||||
|
||||
def _GetACCaches( self, file_service_id = None, tag_service_id = None ):
|
||||
def _GetACCachesSpecific( self, file_service_id = None, tag_service_id = None ):
|
||||
|
||||
result = []
|
||||
|
||||
for ( potential_file_service_id, potential_tag_service_id ) in self._ac_caches.keys():
|
||||
for ( potential_file_service_id, potential_tag_service_id ) in self._specific_ac_caches.keys():
|
||||
|
||||
if file_service_id is not None and file_service_id == potential_file_service_id:
|
||||
|
||||
result.append( self._ac_caches[ ( potential_file_service_id, potential_tag_service_id ) ] )
|
||||
result.append( self._specific_ac_caches[ ( potential_file_service_id, potential_tag_service_id ) ] )
|
||||
|
||||
|
||||
if tag_service_id is not None and tag_service_id == potential_tag_service_id:
|
||||
|
||||
result.append( self._ac_caches[ ( potential_file_service_id, potential_tag_service_id ) ] )
|
||||
result.append( self._specific_ac_caches[ ( potential_file_service_id, potential_tag_service_id ) ] )
|
||||
|
||||
|
||||
|
||||
|
@ -2371,9 +2443,9 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
for search_tag_service_id in search_tag_service_ids:
|
||||
|
||||
ac_cache = self._ac_caches[ ( file_service_id, search_tag_service_id ) ]
|
||||
specific_ac_cache = self._specific_ac_caches[ ( file_service_id, search_tag_service_id ) ]
|
||||
|
||||
cache_results.extend( ac_cache.SimpleRead( 'ac_counts', namespace_ids_to_tag_ids ) )
|
||||
cache_results.extend( specific_ac_cache.SimpleRead( 'ac_counts', namespace_ids_to_tag_ids ) )
|
||||
|
||||
|
||||
|
||||
|
@ -3385,7 +3457,10 @@ class DB( HydrusDB.HydrusDB ):
|
|||
return hash_ids
|
||||
|
||||
|
||||
def _GetHashIdsToHashes( self, hash_ids ): return { hash_id : hash for ( hash_id, hash ) in self._c.execute( 'SELECT hash_id, hash FROM hashes WHERE hash_id IN ' + HydrusData.SplayListForDB( hash_ids ) + ';' ) }
|
||||
def _GetHashIdsToHashes( self, hash_ids ):
|
||||
|
||||
return { hash_id : hash for ( hash_id, hash ) in self._c.execute( 'SELECT hash_id, hash FROM hashes WHERE hash_id IN ' + HydrusData.SplayListForDB( hash_ids ) + ';' ) }
|
||||
|
||||
|
||||
def _GetHashIdStatus( self, hash_id ):
|
||||
|
||||
|
@ -3501,6 +3576,7 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
def _GetMediaResults( self, service_key, hash_ids ):
|
||||
|
||||
|
||||
service_id = self._GetServiceId( service_key )
|
||||
|
||||
splayed_hash_ids = HydrusData.SplayListForDB( hash_ids )
|
||||
|
@ -3525,13 +3601,15 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
hash_ids_to_hashes = self._GetHashIdsToHashes( hash_ids )
|
||||
|
||||
hash_ids_to_tags = HydrusData.BuildKeyToListDict( [ ( hash_id, ( service_id, ( status, HydrusTags.CombineTag( namespace, tag ) ) ) ) for ( hash_id, service_id, namespace, tag, status ) in self._c.execute( 'SELECT hash_id, service_id, namespace, tag, status FROM namespaces, ( tags, mappings USING ( tag_id ) ) USING ( namespace_id ) WHERE hash_id IN ' + splayed_hash_ids + ';' ) ] )
|
||||
hash_ids_to_raw_tag_ids = {}
|
||||
|
||||
hash_ids_to_petitioned_tags = HydrusData.BuildKeyToListDict( [ ( hash_id, ( service_id, ( HC.PETITIONED, HydrusTags.CombineTag( namespace, tag ) ) ) ) for ( hash_id, service_id, namespace, tag ) in self._c.execute( 'SELECT hash_id, service_id, namespace, tag FROM namespaces, ( tags, mapping_petitions USING ( tag_id ) ) USING ( namespace_id ) WHERE hash_id IN ' + splayed_hash_ids + ';' ) ] )
|
||||
|
||||
for ( hash_id, tag_data ) in hash_ids_to_petitioned_tags.items():
|
||||
for hash_id in hash_ids:
|
||||
|
||||
hash_ids_to_tags[ hash_id ].extend( tag_data )
|
||||
raw_results = [ ( service_id, ( status, HydrusTags.CombineTag( namespace, tag ) ) ) for ( service_id, namespace, tag, status ) in self._c.execute( 'SELECT service_id, namespace, tag, status FROM namespaces, ( tags, mappings USING ( tag_id ) ) USING ( namespace_id ) WHERE hash_id = ?;', ( hash_id, ) ) ]
|
||||
|
||||
raw_results.extend( ( ( service_id, ( HC.PETITIONED, HydrusTags.CombineTag( namespace, tag ) ) ) for ( service_id, namespace, tag ) in self._c.execute( 'SELECT service_id, namespace, tag FROM namespaces, ( tags, mapping_petitions USING ( tag_id ) ) USING ( namespace_id ) WHERE hash_id = ?;', ( hash_id, ) ) ) )
|
||||
|
||||
hash_ids_to_raw_tag_ids[ hash_id ] = raw_results
|
||||
|
||||
|
||||
hash_ids_to_current_file_service_ids = HydrusData.BuildKeyToListDict( self._c.execute( 'SELECT hash_id, service_id FROM current_files WHERE hash_id IN ' + splayed_hash_ids + ';' ) )
|
||||
|
@ -3544,10 +3622,10 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
hash_ids_to_local_ratings = HydrusData.BuildKeyToListDict( [ ( hash_id, ( service_id, rating ) ) for ( service_id, hash_id, rating ) in self._c.execute( 'SELECT service_id, hash_id, rating FROM local_ratings WHERE hash_id IN ' + splayed_hash_ids + ';' ) ] )
|
||||
|
||||
service_ids_to_service_keys = { service_id : service_key for ( service_id, service_key ) in self._c.execute( 'SELECT service_id, service_key FROM services;' ) }
|
||||
|
||||
# build it
|
||||
|
||||
service_ids_to_service_keys = { service_id : service_key for ( service_id, service_key ) in self._c.execute( 'SELECT service_id, service_key FROM services;' ) }
|
||||
|
||||
media_results = []
|
||||
|
||||
for hash_id in hash_ids:
|
||||
|
@ -3560,11 +3638,11 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
#
|
||||
|
||||
tags_dict = HydrusData.BuildKeyToListDict( hash_ids_to_tags[ hash_id ] )
|
||||
raw_tag_ids_dict = HydrusData.BuildKeyToListDict( hash_ids_to_raw_tag_ids[ hash_id ] )
|
||||
|
||||
service_keys_to_statuses_to_tags = collections.defaultdict( HydrusData.default_dict_set )
|
||||
|
||||
service_keys_to_statuses_to_tags.update( { service_ids_to_service_keys[ service_id ] : HydrusData.BuildKeyToSetDict( tags_info ) for ( service_id, tags_info ) in tags_dict.items() } )
|
||||
service_keys_to_statuses_to_tags.update( { service_ids_to_service_keys[ service_id ] : HydrusData.BuildKeyToSetDict( tags_info ) for ( service_id, tags_info ) in raw_tag_ids_dict.items() } )
|
||||
|
||||
tags_manager = ClientMedia.TagsManager( service_keys_to_statuses_to_tags )
|
||||
|
||||
|
@ -4636,38 +4714,45 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
def _InitACCaches( self ):
|
||||
|
||||
self._ac_caches = {}
|
||||
self._specific_ac_caches = {}
|
||||
|
||||
if not os.path.exists( HC.CLIENT_CACHE_DIR ): os.makedirs( HC.CLIENT_CACHE_DIR )
|
||||
|
||||
deletee_filenames = set( ( filename for filename in os.listdir( HC.CLIENT_CACHE_DIR ) if filename.endswith( '.db' ) ) )
|
||||
existing_db_paths = set( ( os.path.join( HC.CLIENT_CACHE_DIR, filename ) for filename in os.listdir( HC.CLIENT_CACHE_DIR ) if filename.endswith( '.db' ) ) )
|
||||
useful_db_paths = set()
|
||||
|
||||
file_service_ids = self._GetServiceIds( ( HC.LOCAL_FILE, HC.FILE_REPOSITORY ) )
|
||||
tag_service_ids = self._GetServiceIds( HC.TAG_SERVICES )
|
||||
|
||||
for ( file_service_id, tag_service_id ) in itertools.product( file_service_ids, tag_service_ids ):
|
||||
|
||||
db_filename = 'ac_cache_' + str( file_service_id ) + '_' + str( tag_service_id ) + '.db'
|
||||
db_path = self._GenerateACCacheSpecific( file_service_id, tag_service_id )
|
||||
|
||||
deletee_filenames.discard( db_filename )
|
||||
|
||||
db_path = os.path.join( HC.CLIENT_CACHE_DIR, db_filename )
|
||||
|
||||
self._GenerateACCache( db_path, file_service_id, tag_service_id )
|
||||
useful_db_paths.add( db_path )
|
||||
|
||||
|
||||
for filename in deletee_filenames:
|
||||
self._combined_files_ac_caches = {}
|
||||
|
||||
for tag_service_id in tag_service_ids:
|
||||
|
||||
path = os.path.join( HC.CLIENT_CACHE_DIR, filename )
|
||||
db_path = self._GenerateACCacheCombinedFiles( tag_service_id )
|
||||
|
||||
try:
|
||||
useful_db_paths.add( db_path )
|
||||
|
||||
|
||||
for db_path in existing_db_paths:
|
||||
|
||||
if db_path not in useful_db_paths:
|
||||
|
||||
ClientData.DeletePath( path )
|
||||
|
||||
except Exception as e:
|
||||
|
||||
HydrusData.Print( 'I tried to delete the superfluous file ' + path + ', but encountered this error:' )
|
||||
HydrusData.ShowExceptionDefault( e )
|
||||
try:
|
||||
|
||||
ClientData.DeletePath( path )
|
||||
|
||||
except Exception as e:
|
||||
|
||||
HydrusData.Print( 'I tried to delete the superfluous file ' + db_path + ', but encountered this error:' )
|
||||
HydrusData.PrintException( e )
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -6882,7 +6967,7 @@ class DB( HydrusDB.HydrusDB ):
|
|||
if petitioned_mappings_ids is None: petitioned_mappings_ids = []
|
||||
if petitioned_rescinded_mappings_ids is None: petitioned_rescinded_mappings_ids = []
|
||||
|
||||
ac_caches = self._GetACCaches( tag_service_id = tag_service_id )
|
||||
specific_ac_caches = self._GetACCachesSpecific( tag_service_id = tag_service_id )
|
||||
|
||||
# this method grew into a monster that merged deleted, pending and current according to a heirarchy of services
|
||||
# this cost a lot of CPU time and was extremely difficult to maintain
|
||||
|
@ -7007,6 +7092,9 @@ class DB( HydrusDB.HydrusDB ):
|
|||
change_in_num_tags += num_tags_added
|
||||
change_in_num_files += num_files_added
|
||||
|
||||
#combined_files_current_counter = collections.Counter()
|
||||
#combined_files_pending_counter = collections.Counter()
|
||||
|
||||
if len( mappings_ids ) > 0:
|
||||
|
||||
for ( namespace_id, tag_id, hash_ids ) in mappings_ids:
|
||||
|
@ -7019,10 +7107,13 @@ class DB( HydrusDB.HydrusDB ):
|
|||
change_in_num_deleted_mappings -= num_deleted_deleted
|
||||
change_in_num_pending_mappings -= num_pending_deleted
|
||||
|
||||
|
||||
for ac_cache in ac_caches:
|
||||
#combined_files_current_counter[ ( namespace_id, tag_id ) ] += num_deleted_made_current + num_pending_made_current + num_raw_adds
|
||||
#combined_files_pending_counter[ ( namespace_id, tag_id ) ] -= num_pending_deleted
|
||||
|
||||
ac_cache.SimpleWrite( 'add_mappings', mappings_ids )
|
||||
|
||||
for specific_ac_cache in specific_ac_caches:
|
||||
|
||||
specific_ac_cache.SimpleWrite( 'add_mappings', mappings_ids )
|
||||
|
||||
|
||||
|
||||
|
@ -7038,10 +7129,12 @@ class DB( HydrusDB.HydrusDB ):
|
|||
change_in_num_deleted_mappings += num_current_made_deleted + num_raw_adds
|
||||
change_in_num_petitioned_mappings -= num_deleted_petitions
|
||||
|
||||
|
||||
for ac_cache in ac_caches:
|
||||
#combined_files_current_counter[ ( namespace_id, tag_id ) ] -= num_current_deleted
|
||||
|
||||
ac_cache.SimpleWrite( 'delete_mappings', deleted_mappings_ids )
|
||||
|
||||
for specific_ac_cache in specific_ac_caches:
|
||||
|
||||
specific_ac_cache.SimpleWrite( 'delete_mappings', deleted_mappings_ids )
|
||||
|
||||
|
||||
|
||||
|
@ -7053,10 +7146,12 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
change_in_num_pending_mappings += num_raw_adds
|
||||
|
||||
|
||||
for ac_cache in ac_caches:
|
||||
#combined_files_pending_counter[ ( namespace_id, tag_id ) ] += num_raw_adds
|
||||
|
||||
ac_cache.SimpleWrite( 'pend_mappings', pending_mappings_ids )
|
||||
|
||||
for specific_ac_cache in specific_ac_caches:
|
||||
|
||||
specific_ac_cache.SimpleWrite( 'pend_mappings', pending_mappings_ids )
|
||||
|
||||
|
||||
|
||||
|
@ -7068,12 +7163,24 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
change_in_num_pending_mappings -= num_pending_rescinded
|
||||
|
||||
|
||||
for ac_cache in ac_caches:
|
||||
|
||||
ac_cache.SimpleWrite( 'rescind_pending_mappings', pending_rescinded_mappings_ids )
|
||||
#combined_files_pending_counter[ ( namespace_id, tag_id ) ] -= num_pending_rescinded
|
||||
|
||||
|
||||
for specific_ac_cache in specific_ac_caches:
|
||||
|
||||
specific_ac_cache.SimpleWrite( 'rescind_pending_mappings', pending_rescinded_mappings_ids )
|
||||
|
||||
|
||||
|
||||
#combined_files_seen_ids = set( combined_files_current_counter.keys() )
|
||||
#combined_files_seen_ids.update( combined_files_pending_counter.keys() )
|
||||
|
||||
#combined_files_count_iterator = ( ( namespace_id, tag_id, combined_files_current_counter[ ( namespace_id, tag_id ) ], combined_files_pending_counter[ ( namespace_id, tag_id ) ] ) for ( namespace_id, tag_id ) in combined_files_seen_ids )
|
||||
|
||||
#combined_files_ac_cache = self._combined_files_ac_caches[ service_id ]
|
||||
#combined_files_ac_cache.SimpleWrite( 'update_counts', combined_files_count_iterator )
|
||||
|
||||
#
|
||||
|
||||
post_existing_namespace_ids = { namespace_id for namespace_id in namespace_ids_to_search_for if self._c.execute( 'SELECT 1 WHERE EXISTS ( SELECT namespace_id FROM mappings WHERE namespace_id = ? AND service_id = ? AND status IN ( ?, ? ) );', ( namespace_id, tag_service_id, HC.CURRENT, HC.PENDING ) ).fetchone() is not None }
|
||||
post_existing_tag_ids = { tag_id for tag_id in tag_ids_to_search_for if self._c.execute( 'SELECT 1 WHERE EXISTS ( SELECT tag_id FROM mappings WHERE tag_id = ? AND service_id = ? AND status IN ( ?, ? ) );', ( tag_id, tag_service_id, HC.CURRENT, HC.PENDING ) ).fetchone() is not None }
|
||||
|
|
|
@ -43,9 +43,9 @@ import HydrusData
|
|||
import ClientSearch
|
||||
import HydrusGlobals
|
||||
|
||||
class DB( HydrusDB.HydrusDB ):
|
||||
class SpecificServicesDB( HydrusDB.HydrusDB ):
|
||||
|
||||
DB_NAME = 'ac_cache'
|
||||
DB_NAME = 'ac_cache_specific_services'
|
||||
READ_WRITE_ACTIONS = []
|
||||
WRITE_SPECIAL_ACTIONS = [ 'vacuum' ]
|
||||
UPDATE_WAIT = 0
|
||||
|
@ -148,9 +148,6 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
self._c.execute( 'CREATE TABLE ac_cache ( namespace_id INTEGER, tag_id INTEGER, current_count INTEGER, pending_count INTEGER, PRIMARY KEY( namespace_id, tag_id ) );' )
|
||||
|
||||
self._c.execute( 'CREATE TABLE existing_tags ( namespace_id INTEGER, tag_id INTEGER, PRIMARY KEY( namespace_id, tag_id ) );' )
|
||||
self._c.execute( 'CREATE INDEX existing_tags_tag_id_index ON existing_tags ( tag_id );' )
|
||||
|
||||
self._c.execute( 'CREATE TABLE analyze_timestamps ( name TEXT, timestamp INTEGER );' )
|
||||
self._c.execute( 'CREATE TABLE maintenance_timestamps ( name TEXT, timestamp INTEGER );' )
|
||||
self._c.execute( 'CREATE TABLE version ( version INTEGER );' )
|
||||
|
@ -342,4 +339,157 @@ class DB( HydrusDB.HydrusDB ):
|
|||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
class CombinedFilesDB( HydrusDB.HydrusDB ):
|
||||
|
||||
DB_NAME = 'ac_cache_combined_files'
|
||||
READ_WRITE_ACTIONS = []
|
||||
WRITE_SPECIAL_ACTIONS = [ 'vacuum' ]
|
||||
UPDATE_WAIT = 0
|
||||
|
||||
def _Analyze( self, stale_time_delta, stop_time ):
|
||||
|
||||
all_names = [ name for ( name, ) in self._c.execute( 'SELECT name FROM sqlite_master;' ) ]
|
||||
|
||||
existing_names_to_timestamps = dict( self._c.execute( 'SELECT name, timestamp FROM analyze_timestamps;' ).fetchall() )
|
||||
|
||||
names_to_analyze = [ name for name in all_names if name not in existing_names_to_timestamps or HydrusData.TimeHasPassed( existing_names_to_timestamps[ name ] + stale_time_delta ) ]
|
||||
|
||||
random.shuffle( names_to_analyze )
|
||||
|
||||
while len( names_to_analyze ) > 0:
|
||||
|
||||
name = names_to_analyze.pop()
|
||||
|
||||
started = HydrusData.GetNowPrecise()
|
||||
|
||||
self._c.execute( 'ANALYZE ' + name + ';' )
|
||||
|
||||
self._c.execute( 'REPLACE INTO analyze_timestamps ( name, timestamp ) VALUES ( ?, ? );', ( name, HydrusData.GetNow() ) )
|
||||
|
||||
time_took = HydrusData.GetNowPrecise() - started
|
||||
|
||||
if HydrusData.TimeHasPassed( stop_time ) or not self._controller.CurrentlyIdle():
|
||||
|
||||
break
|
||||
|
||||
|
||||
|
||||
self._c.execute( 'ANALYZE sqlite_master;' ) # this reloads the current stats into the query planner
|
||||
|
||||
still_more_to_do = len( names_to_analyze ) > 0
|
||||
|
||||
return still_more_to_do
|
||||
|
||||
|
||||
def _CreateDB( self ):
|
||||
|
||||
self._c.execute( 'PRAGMA auto_vacuum = 0;' ) # none
|
||||
|
||||
if HC.PLATFORM_WINDOWS:
|
||||
|
||||
self._c.execute( 'PRAGMA page_size = 4096;' )
|
||||
|
||||
|
||||
try: self._c.execute( 'BEGIN IMMEDIATE' )
|
||||
except Exception as e:
|
||||
|
||||
raise HydrusExceptions.DBAccessException( HydrusData.ToUnicode( e ) )
|
||||
|
||||
|
||||
self._c.execute( 'CREATE TABLE ac_cache ( namespace_id INTEGER, tag_id INTEGER, current_count INTEGER, pending_count INTEGER, PRIMARY KEY( namespace_id, tag_id ) );' )
|
||||
|
||||
self._c.execute( 'CREATE TABLE analyze_timestamps ( name TEXT, timestamp INTEGER );' )
|
||||
self._c.execute( 'CREATE TABLE maintenance_timestamps ( name TEXT, timestamp INTEGER );' )
|
||||
self._c.execute( 'CREATE TABLE version ( version INTEGER );' )
|
||||
|
||||
self._c.execute( 'INSERT INTO version ( version ) VALUES ( ? );', ( HC.SOFTWARE_VERSION, ) )
|
||||
|
||||
self._c.execute( 'COMMIT' )
|
||||
|
||||
|
||||
def _GetAutocompleteCounts( self, namespace_ids_to_tag_ids ):
|
||||
|
||||
results = []
|
||||
|
||||
for ( namespace_id, tag_ids ) in namespace_ids_to_tag_ids.items():
|
||||
|
||||
results.extend( ( ( namespace_id, tag_id, current_count, pending_count ) for ( tag_id, current_count, pending_count ) in self._c.execute( 'SELECT tag_id, current_count, pending_count FROM ac_cache WHERE namespace_id = ? AND tag_id IN ' + HydrusData.SplayListForDB( tag_ids ) + ';', ( namespace_id, ) ) ) )
|
||||
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def _ManageDBError( self, job, e ):
|
||||
|
||||
( exception_type, value, tb ) = sys.exc_info()
|
||||
|
||||
new_e = type( e )( os.linesep.join( traceback.format_exception( exception_type, value, tb ) ) )
|
||||
|
||||
job.PutResult( new_e )
|
||||
|
||||
|
||||
def _UpdateCounts( self, count_ids ):
|
||||
|
||||
self._c.executemany( 'INSERT OR IGNORE INTO ac_cache ( namespace_id, tag_id, current_count, pending_count ) VALUES ( ?, ?, ?, ? );', ( ( namespace_id, tag_id, 0, 0 ) for ( namespace_id, tag_id, current_delta, pending_delta ) in count_ids ) )
|
||||
|
||||
self._c.executemany( 'UPDATE ac_cache SET current_count = current_count + ?, pending_count = pending_count + ? WHERE namespace_id = ? AND tag_id = ?;', ( ( current_delta, pending_delta, namespace_id, tag_id ) for ( namespace_id, tag_id, current_delta, pending_delta ) in count_ids ) )
|
||||
|
||||
self._c.executemany( 'DELETE FROM ac_cache WHERE namespace_id = ? AND tag_id = ? AND current_count = ? AND pending_count = ?;', ( ( namespace_id, tag_id, 0, 0 ) for ( namespace_id, tag_id, current_delta, pending_delta ) in count_ids ) )
|
||||
|
||||
|
||||
def _Read( self, action, *args, **kwargs ):
|
||||
|
||||
if action == 'ac_counts': result = self._GetAutocompleteCounts( *args, **kwargs )
|
||||
else: raise Exception( 'db received an unknown read command: ' + action )
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def _UpdateDB( self, version ):
|
||||
|
||||
self._c.execute( 'UPDATE version SET version = ?;', ( version + 1, ) )
|
||||
|
||||
|
||||
def _Vacuum( self ):
|
||||
|
||||
if not self._fast_big_transaction_wal:
|
||||
|
||||
self._c.execute( 'PRAGMA journal_mode = TRUNCATE;' )
|
||||
|
||||
|
||||
if HC.PLATFORM_WINDOWS:
|
||||
|
||||
ideal_page_size = 4096
|
||||
|
||||
else:
|
||||
|
||||
ideal_page_size = 1024
|
||||
|
||||
|
||||
( page_size, ) = self._c.execute( 'PRAGMA page_size;' ).fetchone()
|
||||
|
||||
if page_size != ideal_page_size:
|
||||
|
||||
self._c.execute( 'PRAGMA journal_mode = TRUNCATE;' )
|
||||
self._c.execute( 'PRAGMA page_size = ' + str( ideal_page_size ) + ';' )
|
||||
|
||||
|
||||
self._c.execute( 'VACUUM' )
|
||||
|
||||
self._c.execute( 'REPLACE INTO maintenance_timestamps ( name, timestamp ) VALUES ( ?, ? );', ( 'vacuum', HydrusData.GetNow() ) )
|
||||
|
||||
self._InitDBCursor()
|
||||
|
||||
|
||||
def _Write( self, action, *args, **kwargs ):
|
||||
|
||||
if action == 'update_counts': result = self._UpdateCounts( *args, **kwargs )
|
||||
elif action == 'analyze': result = self._Analyze( *args, **kwargs )
|
||||
elif action == 'vacuum': result = self._Vacuum( *args, **kwargs )
|
||||
else: raise Exception( 'db received an unknown write command: ' + action )
|
||||
|
||||
return result
|
||||
|
||||
|
|
@ -1835,15 +1835,70 @@ class ServiceRepository( ServiceRestricted ):
|
|||
|
||||
class ServiceIPFS( ServiceRemote ):
|
||||
|
||||
def GetDaemonVersion( self ):
|
||||
def _ConvertMultihashToURLTree( self, name, size, multihash ):
|
||||
|
||||
api_base_url = self._GetAPIBaseURL()
|
||||
|
||||
links_url = api_base_url + 'object/links/' + multihash
|
||||
|
||||
response = ClientNetworking.RequestsGet( links_url )
|
||||
|
||||
links_json = response.json()
|
||||
|
||||
is_directory = False
|
||||
|
||||
for link in links_json[ 'Links' ]:
|
||||
|
||||
if link[ 'Name' ] != '':
|
||||
|
||||
is_directory = True
|
||||
|
||||
|
||||
|
||||
if is_directory:
|
||||
|
||||
children = []
|
||||
|
||||
for link in links_json[ 'Links' ]:
|
||||
|
||||
subname = link[ 'Name' ]
|
||||
subsize = link[ 'Size' ]
|
||||
submultihash = link[ 'Hash' ]
|
||||
|
||||
children.append( self._ConvertMultihashToURLTree( subname, subsize, submultihash ) )
|
||||
|
||||
|
||||
if size is None:
|
||||
|
||||
size = sum( ( subsize for ( type_gumpf, subname, subsize, submultihash ) in children ) )
|
||||
|
||||
|
||||
return ( 'directory', name, size, children )
|
||||
|
||||
else:
|
||||
|
||||
url = api_base_url + 'cat/' + multihash
|
||||
|
||||
return ( 'file', name, size, url )
|
||||
|
||||
|
||||
|
||||
def _GetAPIBaseURL( self ):
|
||||
|
||||
credentials = self.GetCredentials()
|
||||
|
||||
( host, port ) = credentials.GetAddress()
|
||||
|
||||
path = '/api/v0/version'
|
||||
api_base_url = 'http://' + host + ':' + str( port ) + '/api/v0/'
|
||||
|
||||
url = 'http://' + host + ':' + str( port ) + path
|
||||
return api_base_url
|
||||
|
||||
|
||||
def GetDaemonVersion( self ):
|
||||
|
||||
api_base_url = self._GetAPIBaseURL()
|
||||
|
||||
url = api_base_url + 'version'
|
||||
|
||||
response = ClientNetworking.RequestsGet( url )
|
||||
|
||||
|
@ -1854,50 +1909,59 @@ class ServiceIPFS( ServiceRemote ):
|
|||
|
||||
def ImportFile( self, multihash ):
|
||||
|
||||
credentials = self.GetCredentials()
|
||||
|
||||
( host, port ) = credentials.GetAddress()
|
||||
|
||||
api_url = 'http://' + host + ':' + str( port ) + '/api/v0/'
|
||||
|
||||
links_url = api_url + 'object/links/' + multihash
|
||||
|
||||
response = ClientNetworking.RequestsGet( links_url )
|
||||
|
||||
links_json = response.json()
|
||||
|
||||
for link in links_json[ 'Links' ]:
|
||||
def on_wx_select_tree( job_key, url_tree ):
|
||||
|
||||
if link[ 'Name' ] != '':
|
||||
import ClientGUIDialogs
|
||||
|
||||
HydrusData.ShowText( multihash + ' appears to be a directory or other non-single file ipfs object, and cannot yet be downloaded.' )
|
||||
|
||||
return
|
||||
with ClientGUIDialogs.DialogSelectFromURLTree( None, url_tree ) as dlg:
|
||||
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
|
||||
urls = dlg.GetURLs()
|
||||
|
||||
if len( urls ) > 0:
|
||||
|
||||
HydrusGlobals.client_controller.CallToThread( ClientDownloading.THREADDownloadURLs, job_key, urls, multihash )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
def off_wx():
|
||||
|
||||
job_key = ClientThreading.JobKey( pausable = True, cancellable = True )
|
||||
|
||||
job_key.SetVariable( 'popup_text_1', 'Looking up multihash information' )
|
||||
|
||||
HydrusGlobals.client_controller.pub( 'message', job_key )
|
||||
|
||||
url_tree = self._ConvertMultihashToURLTree( multihash, None, multihash )
|
||||
|
||||
if url_tree[0] == 'file':
|
||||
|
||||
url = url_tree[3]
|
||||
|
||||
HydrusGlobals.client_controller.CallToThread( ClientDownloading.THREADDownloadURL, job_key, url, multihash )
|
||||
|
||||
else:
|
||||
|
||||
job_key.SetVariable( 'popup_text_1', 'Waiting for user selection' )
|
||||
|
||||
wx.CallAfter( on_wx_select_tree, job_key, url_tree )
|
||||
|
||||
|
||||
|
||||
url = api_url + 'cat/' + multihash
|
||||
|
||||
url_string = multihash
|
||||
|
||||
job_key = ClientThreading.JobKey( pausable = True, cancellable = True )
|
||||
|
||||
HydrusGlobals.client_controller.pub( 'message', job_key )
|
||||
|
||||
HydrusGlobals.client_controller.CallToThread( ClientDownloading.THREADDownloadURL, job_key, url, url_string )
|
||||
HydrusGlobals.client_controller.CallToThread( off_wx )
|
||||
|
||||
|
||||
def PinFile( self, hash, mime ):
|
||||
|
||||
mime_string = HC.mime_string_lookup[ mime ]
|
||||
|
||||
credentials = self.GetCredentials()
|
||||
api_base_url = self._GetAPIBaseURL()
|
||||
|
||||
( host, port ) = credentials.GetAddress()
|
||||
|
||||
url = 'http://' + host + ':' + str( port ) + '/api/v0/add'
|
||||
url = api_base_url + 'add'
|
||||
|
||||
client_files_manager = HydrusGlobals.client_controller.GetClientFilesManager()
|
||||
|
||||
|
@ -1916,11 +1980,9 @@ class ServiceIPFS( ServiceRemote ):
|
|||
|
||||
def UnpinFile( self, multihash ):
|
||||
|
||||
credentials = self.GetCredentials()
|
||||
api_base_url = self._GetAPIBaseURL()
|
||||
|
||||
( host, port ) = credentials.GetAddress()
|
||||
|
||||
url = 'http://' + host + ':' + str( port ) + '/api/v0/pin/rm/' + multihash
|
||||
url = api_base_url + 'pin/rm/' + multihash
|
||||
|
||||
ClientNetworking.RequestsGet( url )
|
||||
|
||||
|
|
|
@ -218,15 +218,6 @@ def THREADDownloadURL( job_key, url, url_string ):
|
|||
|
||||
job_key.SetVariable( 'popup_text_1', url_string + ' - initialising' )
|
||||
|
||||
def hook( gauge_value, gauge_range ):
|
||||
|
||||
if gauge_range is None: text = url_string + ' - ' + HydrusData.ConvertIntToBytes( gauge_value )
|
||||
else: text = url_string + ' - ' + HydrusData.ConvertValueRangeToPrettyString( gauge_value, gauge_range )
|
||||
|
||||
job_key.SetVariable( 'popup_text_1', text )
|
||||
job_key.SetVariable( 'popup_gauge_1', ( gauge_value, gauge_range ) )
|
||||
|
||||
|
||||
( os_file_handle, temp_path ) = HydrusPaths.GetTempPath()
|
||||
|
||||
try:
|
||||
|
@ -259,7 +250,11 @@ def THREADDownloadURL( job_key, url, url_string ):
|
|||
|
||||
gauge_value += len( chunk )
|
||||
|
||||
hook( gauge_value, gauge_range )
|
||||
if gauge_range is None: text = url_string + ' - ' + HydrusData.ConvertIntToBytes( gauge_value )
|
||||
else: text = url_string + ' - ' + HydrusData.ConvertValueRangeToBytes( gauge_value, gauge_range )
|
||||
|
||||
job_key.SetVariable( 'popup_text_1', text )
|
||||
job_key.SetVariable( 'popup_gauge_1', ( gauge_value, gauge_range ) )
|
||||
|
||||
|
||||
|
||||
|
@ -299,6 +294,147 @@ def THREADDownloadURL( job_key, url, url_string ):
|
|||
|
||||
job_key.Finish()
|
||||
|
||||
def THREADDownloadURLs( job_key, urls, title ):
|
||||
|
||||
job_key.SetVariable( 'popup_text_1', title + ' - initialising' )
|
||||
|
||||
num_successful = 0
|
||||
num_redundant = 0
|
||||
num_deleted = 0
|
||||
num_failed = 0
|
||||
|
||||
successful_hashes = set()
|
||||
|
||||
for ( i, url ) in enumerate( urls ):
|
||||
|
||||
( i_paused, should_quit ) = job_key.WaitIfNeeded()
|
||||
|
||||
if should_quit:
|
||||
|
||||
break
|
||||
|
||||
|
||||
job_key.SetVariable( 'popup_text_1', title + ' - ' + HydrusData.ConvertValueRangeToPrettyString( i + 1, len( urls ) ) )
|
||||
job_key.SetVariable( 'popup_gauge_1', ( i + 1, len( urls ) ) )
|
||||
|
||||
( os_file_handle, temp_path ) = HydrusPaths.GetTempPath()
|
||||
|
||||
try:
|
||||
|
||||
response = ClientNetworking.RequestsGet( url, stream = True )
|
||||
|
||||
if 'content-length' in response.headers:
|
||||
|
||||
gauge_range = int( response.headers[ 'content-length' ] )
|
||||
|
||||
else:
|
||||
|
||||
gauge_range = None
|
||||
|
||||
|
||||
gauge_value = 0
|
||||
|
||||
with open( temp_path, 'wb' ) as f:
|
||||
|
||||
for chunk in response.iter_content( chunk_size = 65536 ):
|
||||
|
||||
( i_paused, should_quit ) = job_key.WaitIfNeeded()
|
||||
|
||||
if should_quit:
|
||||
|
||||
return
|
||||
|
||||
|
||||
f.write( chunk )
|
||||
|
||||
gauge_value += len( chunk )
|
||||
|
||||
if gauge_range is None: text = 'downloading - ' + HydrusData.ConvertIntToBytes( gauge_value )
|
||||
else: text = 'downloading - ' + HydrusData.ConvertValueRangeToBytes( gauge_value, gauge_range )
|
||||
|
||||
job_key.SetVariable( 'popup_text_2', text )
|
||||
job_key.SetVariable( 'popup_gauge_2', ( gauge_value, gauge_range ) )
|
||||
|
||||
|
||||
|
||||
job_key.SetVariable( 'popup_text_2', 'importing' )
|
||||
|
||||
( result, hash ) = HydrusGlobals.client_controller.WriteSynchronous( 'import_file', temp_path )
|
||||
|
||||
except HydrusExceptions.NetworkException:
|
||||
|
||||
job_key.Cancel()
|
||||
|
||||
raise
|
||||
|
||||
except Exception as e:
|
||||
|
||||
HydrusData.Print( url + ' failed to import!' )
|
||||
HydrusData.PrintException( e )
|
||||
|
||||
num_failed += 1
|
||||
|
||||
continue
|
||||
|
||||
finally:
|
||||
|
||||
HydrusPaths.CleanUpTempPath( os_file_handle, temp_path )
|
||||
|
||||
|
||||
if result in ( CC.STATUS_SUCCESSFUL, CC.STATUS_REDUNDANT ):
|
||||
|
||||
if result == CC.STATUS_SUCCESSFUL:
|
||||
|
||||
num_successful += 1
|
||||
|
||||
else:
|
||||
|
||||
num_redundant += 1
|
||||
|
||||
|
||||
successful_hashes.add( hash )
|
||||
|
||||
elif result == CC.STATUS_DELETED:
|
||||
|
||||
num_deleted += 1
|
||||
|
||||
|
||||
|
||||
text_components = []
|
||||
|
||||
if num_successful > 0:
|
||||
|
||||
text_components.append( HydrusData.ConvertIntToPrettyString( num_successful ) + ' successful' )
|
||||
|
||||
|
||||
if num_redundant > 0:
|
||||
|
||||
text_components.append( HydrusData.ConvertIntToPrettyString( num_redundant ) + ' already in db' )
|
||||
|
||||
|
||||
if num_deleted > 0:
|
||||
|
||||
text_components.append( HydrusData.ConvertIntToPrettyString( num_deleted ) + ' deleted' )
|
||||
|
||||
|
||||
if num_failed > 0:
|
||||
|
||||
text_components.append( HydrusData.ConvertIntToPrettyString( num_failed ) + ' failed (errors written to log)' )
|
||||
|
||||
|
||||
job_key.SetVariable( 'popup_text_1', title + ' - ' + ', '.join( text_components ) )
|
||||
|
||||
if len( successful_hashes ) > 0:
|
||||
|
||||
job_key.SetVariable( 'popup_files', successful_hashes )
|
||||
|
||||
|
||||
job_key.DeleteVariable( 'popup_gauge_1' )
|
||||
job_key.DeleteVariable( 'popup_text_2' )
|
||||
job_key.DeleteVariable( 'popup_gauge_2' )
|
||||
|
||||
job_key.Finish()
|
||||
|
||||
def Parse4chanPostScreen( html ):
|
||||
|
||||
soup = GetSoup( html )
|
||||
|
|
|
@ -3135,7 +3135,7 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
|
||||
self._bytes.Hide()
|
||||
|
||||
self._bytes_text.SetLabel( 'used ' + HydrusData.ConvertIntToBytes( used_monthly_data ) + monthly_requests_text + ' this month' )
|
||||
self._bytes_text.SetLabelText( 'used ' + HydrusData.ConvertIntToBytes( used_monthly_data ) + monthly_requests_text + ' this month' )
|
||||
|
||||
else:
|
||||
|
||||
|
@ -3144,7 +3144,7 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
self._bytes.SetRange( max_monthly_data )
|
||||
self._bytes.SetValue( used_monthly_data )
|
||||
|
||||
self._bytes_text.SetLabel( 'used ' + HydrusData.ConvertValueRangeToPrettyString( used_monthly_data, max_monthly_data ) + monthly_requests_text + ' this month' )
|
||||
self._bytes_text.SetLabelText( 'used ' + HydrusData.ConvertValueRangeToPrettyString( used_monthly_data, max_monthly_data ) + monthly_requests_text + ' this month' )
|
||||
|
||||
|
||||
|
||||
|
@ -3156,9 +3156,9 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
|
||||
account_type_string = account_type.ConvertToString()
|
||||
|
||||
if self._account_type.GetLabel() != account_type_string:
|
||||
if self._account_type.GetLabelText() != account_type_string:
|
||||
|
||||
self._account_type.SetLabel( account_type_string )
|
||||
self._account_type.SetLabelText( account_type_string )
|
||||
|
||||
self._account_type.Wrap( 400 )
|
||||
|
||||
|
@ -3175,7 +3175,7 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
self._age.SetValue( min( now - created, expires - created ) )
|
||||
|
||||
|
||||
self._age_text.SetLabel( account.GetExpiresString() )
|
||||
self._age_text.SetLabelText( account.GetExpiresString() )
|
||||
|
||||
max_num_bytes = account_type.GetMaxBytes()
|
||||
max_num_requests = account_type.GetMaxRequests()
|
||||
|
@ -3192,7 +3192,7 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
self._bytes.SetValue( used_bytes )
|
||||
|
||||
|
||||
self._bytes_text.SetLabel( account.GetUsedBytesString() )
|
||||
self._bytes_text.SetLabelText( account.GetUsedBytesString() )
|
||||
|
||||
if max_num_requests is None: self._requests.Hide()
|
||||
else:
|
||||
|
@ -3203,7 +3203,7 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
self._requests.SetValue( min( used_requests, max_num_requests ) )
|
||||
|
||||
|
||||
self._requests_text.SetLabel( account.GetUsedRequestsString() )
|
||||
self._requests_text.SetLabelText( account.GetUsedRequestsString() )
|
||||
|
||||
if service_type in HC.REPOSITORIES:
|
||||
|
||||
|
@ -3225,7 +3225,7 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
self._updates.SetValue( num_updates_downloaded )
|
||||
|
||||
|
||||
self._updates_text.SetLabel( self._service.GetUpdateStatus() )
|
||||
self._updates_text.SetLabelText( self._service.GetUpdateStatus() )
|
||||
|
||||
if account.HasPermission( HC.RESOLVE_PETITIONS ):
|
||||
|
||||
|
@ -3249,7 +3249,7 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
self._thumbnails.SetRange( self._num_thumbs )
|
||||
self._thumbnails.SetValue( min( self._num_local_thumbs, self._num_thumbs ) )
|
||||
|
||||
self._thumbnails_text.SetLabel( HydrusData.ConvertValueRangeToPrettyString( self._num_local_thumbs, self._num_thumbs ) + ' thumbnails downloaded' )
|
||||
self._thumbnails_text.SetLabelText( HydrusData.ConvertValueRangeToPrettyString( self._num_local_thumbs, self._num_thumbs ) + ' thumbnails downloaded' )
|
||||
|
||||
|
||||
def _DisplayService( self ):
|
||||
|
@ -3267,11 +3267,11 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
num_files = service_info[ HC.SERVICE_INFO_NUM_FILES ]
|
||||
total_size = service_info[ HC.SERVICE_INFO_TOTAL_SIZE ]
|
||||
|
||||
self._files_text.SetLabel( HydrusData.ConvertIntToPrettyString( num_files ) + ' files, totalling ' + HydrusData.ConvertIntToBytes( total_size ) )
|
||||
self._files_text.SetLabelText( HydrusData.ConvertIntToPrettyString( num_files ) + ' files, totalling ' + HydrusData.ConvertIntToBytes( total_size ) )
|
||||
|
||||
num_deleted_files = service_info[ HC.SERVICE_INFO_NUM_DELETED_FILES ]
|
||||
|
||||
self._deleted_files_text.SetLabel( HydrusData.ConvertIntToPrettyString( num_deleted_files ) + ' deleted files' )
|
||||
self._deleted_files_text.SetLabelText( HydrusData.ConvertIntToPrettyString( num_deleted_files ) + ' deleted files' )
|
||||
|
||||
if service_type == HC.FILE_REPOSITORY:
|
||||
|
||||
|
@ -3288,26 +3288,26 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
num_tags = service_info[ HC.SERVICE_INFO_NUM_TAGS ]
|
||||
num_mappings = service_info[ HC.SERVICE_INFO_NUM_MAPPINGS ]
|
||||
|
||||
self._tags_text.SetLabel( HydrusData.ConvertIntToPrettyString( num_files ) + ' hashes, ' + HydrusData.ConvertIntToPrettyString( num_namespaces ) + ' namespaces, ' + HydrusData.ConvertIntToPrettyString( num_tags ) + ' tags, totalling ' + HydrusData.ConvertIntToPrettyString( num_mappings ) + ' mappings' )
|
||||
self._tags_text.SetLabelText( HydrusData.ConvertIntToPrettyString( num_files ) + ' hashes, ' + HydrusData.ConvertIntToPrettyString( num_namespaces ) + ' namespaces, ' + HydrusData.ConvertIntToPrettyString( num_tags ) + ' tags, totalling ' + HydrusData.ConvertIntToPrettyString( num_mappings ) + ' mappings' )
|
||||
|
||||
if service_type == HC.TAG_REPOSITORY:
|
||||
|
||||
num_deleted_mappings = service_info[ HC.SERVICE_INFO_NUM_DELETED_MAPPINGS ]
|
||||
|
||||
self._deleted_tags_text.SetLabel( HydrusData.ConvertIntToPrettyString( num_deleted_mappings ) + ' deleted mappings' )
|
||||
self._deleted_tags_text.SetLabelText( HydrusData.ConvertIntToPrettyString( num_deleted_mappings ) + ' deleted mappings' )
|
||||
|
||||
|
||||
elif service_type in ( HC.LOCAL_RATING_LIKE, HC.LOCAL_RATING_NUMERICAL ):
|
||||
|
||||
num_ratings = service_info[ HC.SERVICE_INFO_NUM_FILES ]
|
||||
|
||||
self._ratings_text.SetLabel( str( num_ratings ) + ' files rated' )
|
||||
self._ratings_text.SetLabelText( str( num_ratings ) + ' files rated' )
|
||||
|
||||
elif service_type == HC.LOCAL_BOORU:
|
||||
|
||||
num_shares = service_info[ HC.SERVICE_INFO_NUM_SHARES ]
|
||||
|
||||
self._num_shares.SetLabel( HydrusData.ConvertIntToPrettyString( num_shares ) + ' shares currently active' )
|
||||
self._num_shares.SetLabelText( HydrusData.ConvertIntToPrettyString( num_shares ) + ' shares currently active' )
|
||||
|
||||
|
||||
|
||||
|
@ -3634,7 +3634,7 @@ class FrameReviewServices( ClientGUICommon.Frame ):
|
|||
|
||||
try:
|
||||
|
||||
self._updates_text.SetLabel( self._service.GetUpdateStatus() )
|
||||
self._updates_text.SetLabelText( self._service.GetUpdateStatus() )
|
||||
|
||||
except wx.PyDeadObjectError:
|
||||
|
||||
|
@ -3691,7 +3691,7 @@ class FrameSeedCache( ClientGUICommon.Frame ):
|
|||
|
||||
( status, ( total_processed, total ) ) = self._seed_cache.GetStatus()
|
||||
|
||||
self._text.SetLabel( status )
|
||||
self._text.SetLabelText( status )
|
||||
|
||||
self.Layout()
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class CollapsiblePanel( wx.Panel ):
|
|||
|
||||
if self._expanded:
|
||||
|
||||
self._button.SetLabel( 'expand' )
|
||||
self._button.SetLabelText( 'expand' )
|
||||
|
||||
self._panel.Hide()
|
||||
|
||||
|
@ -115,7 +115,7 @@ class CollapsiblePanel( wx.Panel ):
|
|||
|
||||
else:
|
||||
|
||||
self._button.SetLabel( 'collapse' )
|
||||
self._button.SetLabelText( 'collapse' )
|
||||
|
||||
self._panel.Show()
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ class AnimatedStaticTextTimestamp( wx.StaticText ):
|
|||
|
||||
if update:
|
||||
|
||||
self.SetLabel( self._prefix + self._rendering_function( self._timestamp ) + self._suffix )
|
||||
self.SetLabelText( self._prefix + self._rendering_function( self._timestamp ) + self._suffix )
|
||||
|
||||
wx.PostEvent( self.GetEventHandler(), wx.SizeEvent() )
|
||||
|
||||
|
@ -666,7 +666,7 @@ class AutoCompleteDropdownTags( AutoCompleteDropdown ):
|
|||
|
||||
name = file_service.GetName()
|
||||
|
||||
self._file_repo_button.SetLabel( name )
|
||||
self._file_repo_button.SetLabelText( name )
|
||||
|
||||
wx.CallAfter( self.RefreshList )
|
||||
|
||||
|
@ -684,7 +684,7 @@ class AutoCompleteDropdownTags( AutoCompleteDropdown ):
|
|||
|
||||
name = tag_service.GetName()
|
||||
|
||||
self._tag_repo_button.SetLabel( name )
|
||||
self._tag_repo_button.SetLabelText( name )
|
||||
|
||||
self._cache_text = ''
|
||||
self._current_namespace = ''
|
||||
|
@ -997,8 +997,6 @@ class AutoCompleteDropdownTagsRead( AutoCompleteDropdownTags ):
|
|||
|
||||
self._cached_results = siblings_manager.CollapsePredicates( self._cached_results )
|
||||
|
||||
self._cached_results = ClientSearch.SortPredicates( self._cached_results )
|
||||
|
||||
|
||||
predicates = self._cached_results
|
||||
|
||||
|
@ -1053,12 +1051,12 @@ class AutoCompleteDropdownTagsRead( AutoCompleteDropdownTags ):
|
|||
|
||||
predicates = siblings_manager.CollapsePredicates( predicates )
|
||||
|
||||
predicates = ClientSearch.SortPredicates( predicates )
|
||||
|
||||
self._next_updatelist_is_probably_fast = True
|
||||
|
||||
|
||||
matches = ClientSearch.FilterPredicates( search_text, predicates )
|
||||
matches = ClientSearch.FilterPredicatesBySearchEntry( search_text, predicates )
|
||||
|
||||
matches = ClientSearch.SortPredicates( matches )
|
||||
|
||||
|
||||
if self._include_unusual_predicate_types:
|
||||
|
@ -1094,7 +1092,10 @@ class AutoCompleteDropdownTagsRead( AutoCompleteDropdownTags ):
|
|||
|
||||
matches.insert( 0, predicate )
|
||||
|
||||
except: pass
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
for match in matches:
|
||||
|
@ -1293,8 +1294,6 @@ class AutoCompleteDropdownTagsWrite( AutoCompleteDropdownTags ):
|
|||
|
||||
predicates = HydrusGlobals.client_controller.Read( 'autocomplete_predicates', file_service_key = self._file_service_key, tag_service_key = self._tag_service_key, search_text = search_text, exact_match = True, add_namespaceless = False )
|
||||
|
||||
predicates = ClientSearch.SortPredicates( predicates )
|
||||
|
||||
else:
|
||||
|
||||
if must_do_a_search or self._cache_text == '' or not half_complete_tag.startswith( self._cache_text ):
|
||||
|
@ -1303,15 +1302,15 @@ class AutoCompleteDropdownTagsWrite( AutoCompleteDropdownTags ):
|
|||
|
||||
self._cached_results = HydrusGlobals.client_controller.Read( 'autocomplete_predicates', file_service_key = self._file_service_key, tag_service_key = self._tag_service_key, search_text = search_text, add_namespaceless = False )
|
||||
|
||||
self._cached_results = ClientSearch.SortPredicates( self._cached_results )
|
||||
|
||||
|
||||
predicates = self._cached_results
|
||||
|
||||
self._next_updatelist_is_probably_fast = True
|
||||
|
||||
|
||||
matches = ClientSearch.FilterPredicates( half_complete_tag, predicates, service_key = self._tag_service_key, expand_parents = self._expand_parents )
|
||||
matches = ClientSearch.FilterPredicatesBySearchEntry( half_complete_tag, predicates, service_key = self._tag_service_key, expand_parents = self._expand_parents )
|
||||
|
||||
matches = ClientSearch.SortPredicates( matches )
|
||||
|
||||
self._PutAtTopOfMatches( matches, entry_predicate )
|
||||
|
||||
|
@ -1798,13 +1797,13 @@ class FitResistantStaticText( wx.StaticText ):
|
|||
self.SetMaxSize( ( self._wrap, -1 ) )
|
||||
|
||||
|
||||
def SetLabel( self, label ):
|
||||
def SetLabelText( self, label ):
|
||||
|
||||
if label != self._last_label:
|
||||
|
||||
self._last_label = label
|
||||
|
||||
wx.StaticText.SetLabel( self, label )
|
||||
wx.StaticText.SetLabelText( self, label )
|
||||
|
||||
self.Wrap( self._wrap )
|
||||
|
||||
|
@ -4288,7 +4287,7 @@ class OnOffButton( wx.Button ):
|
|||
|
||||
self._on = False
|
||||
|
||||
self.SetLabel( self._off_label )
|
||||
self.SetLabelText( self._off_label )
|
||||
|
||||
self.SetForegroundColour( ( 128, 0, 0 ) )
|
||||
|
||||
|
@ -4298,7 +4297,7 @@ class OnOffButton( wx.Button ):
|
|||
|
||||
self._on = True
|
||||
|
||||
self.SetLabel( self._on_label )
|
||||
self.SetLabelText( self._on_label )
|
||||
|
||||
self.SetForegroundColour( ( 0, 128, 0 ) )
|
||||
|
||||
|
@ -4346,7 +4345,7 @@ class PopupDismissAll( PopupWindow ):
|
|||
|
||||
def EventButton( self, event ): self.GetParent().DismissAll()
|
||||
|
||||
def SetNumMessages( self, num_messages_pending ): self._text.SetLabel( HydrusData.ConvertIntToPrettyString( num_messages_pending ) + ' more messages' )
|
||||
def SetNumMessages( self, num_messages_pending ): self._text.SetLabelText( HydrusData.ConvertIntToPrettyString( num_messages_pending ) + ' more messages' )
|
||||
|
||||
class PopupMessage( PopupWindow ):
|
||||
|
||||
|
@ -4500,13 +4499,13 @@ class PopupMessage( PopupWindow ):
|
|||
|
||||
if self._caller_tb_text.IsShown():
|
||||
|
||||
self._show_caller_tb_button.SetLabel( 'show caller traceback' )
|
||||
self._show_caller_tb_button.SetLabelText( 'show caller traceback' )
|
||||
|
||||
self._caller_tb_text.Hide()
|
||||
|
||||
else:
|
||||
|
||||
self._show_caller_tb_button.SetLabel( 'hide caller traceback' )
|
||||
self._show_caller_tb_button.SetLabelText( 'hide caller traceback' )
|
||||
|
||||
self._caller_tb_text.Show()
|
||||
|
||||
|
@ -4518,13 +4517,13 @@ class PopupMessage( PopupWindow ):
|
|||
|
||||
if self._db_tb_text.IsShown():
|
||||
|
||||
self._show_db_tb_button.SetLabel( 'show db traceback' )
|
||||
self._show_db_tb_button.SetLabelText( 'show db traceback' )
|
||||
|
||||
self._db_tb_text.Hide()
|
||||
|
||||
else:
|
||||
|
||||
self._show_db_tb_button.SetLabel( 'hide db traceback' )
|
||||
self._show_db_tb_button.SetLabelText( 'hide db traceback' )
|
||||
|
||||
self._db_tb_text.Show()
|
||||
|
||||
|
@ -4545,13 +4544,13 @@ class PopupMessage( PopupWindow ):
|
|||
|
||||
if self._tb_text.IsShown():
|
||||
|
||||
self._show_tb_button.SetLabel( 'show traceback' )
|
||||
self._show_tb_button.SetLabelText( 'show traceback' )
|
||||
|
||||
self._tb_text.Hide()
|
||||
|
||||
else:
|
||||
|
||||
self._show_tb_button.SetLabel( 'hide traceback' )
|
||||
self._show_tb_button.SetLabelText( 'hide traceback' )
|
||||
|
||||
self._tb_text.Show()
|
||||
|
||||
|
@ -4578,7 +4577,7 @@ class PopupMessage( PopupWindow ):
|
|||
|
||||
text = self._job_key.GetVariable( 'popup_title' )
|
||||
|
||||
if self._title.GetLabel() != text: self._title.SetLabel( text )
|
||||
if self._title.GetLabelText() != text: self._title.SetLabelText( text )
|
||||
|
||||
self._title.Show()
|
||||
|
||||
|
@ -4595,7 +4594,7 @@ class PopupMessage( PopupWindow ):
|
|||
text = self._job_key.GetVariable( 'popup_text_1' )
|
||||
|
||||
|
||||
if self._text_1.GetLabel() != text: self._text_1.SetLabel( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
if self._text_1.GetLabelText() != text: self._text_1.SetLabelText( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
|
||||
self._text_1.Show()
|
||||
|
||||
|
@ -4620,7 +4619,7 @@ class PopupMessage( PopupWindow ):
|
|||
|
||||
text = self._job_key.GetVariable( 'popup_text_2' )
|
||||
|
||||
if self._text_2.GetLabel() != text: self._text_2.SetLabel( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
if self._text_2.GetLabelText() != text: self._text_2.SetLabelText( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
|
||||
self._text_2.Show()
|
||||
|
||||
|
@ -4647,7 +4646,7 @@ class PopupMessage( PopupWindow ):
|
|||
|
||||
text = 'show ' + HydrusData.ConvertIntToPrettyString( len( hashes ) ) + ' files'
|
||||
|
||||
if self._show_files_button.GetLabel() != text: self._show_files_button.SetLabel( text )
|
||||
if self._show_files_button.GetLabelText() != text: self._show_files_button.SetLabelText( text )
|
||||
|
||||
self._show_files_button.Show()
|
||||
|
||||
|
@ -4660,7 +4659,7 @@ class PopupMessage( PopupWindow ):
|
|||
|
||||
text = self._job_key.GetVariable( 'popup_traceback' )
|
||||
|
||||
if self._tb_text.GetLabel() != text: self._tb_text.SetLabel( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
if self._tb_text.GetLabelText() != text: self._tb_text.SetLabelText( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
|
||||
self._show_tb_button.Show()
|
||||
|
||||
|
@ -4674,7 +4673,7 @@ class PopupMessage( PopupWindow ):
|
|||
|
||||
text = self._job_key.GetVariable( 'popup_caller_traceback' )
|
||||
|
||||
if self._caller_tb_text.GetLabel() != text: self._caller_tb_text.SetLabel( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
if self._caller_tb_text.GetLabelText() != text: self._caller_tb_text.SetLabelText( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
|
||||
self._show_caller_tb_button.Show()
|
||||
|
||||
|
@ -4688,7 +4687,7 @@ class PopupMessage( PopupWindow ):
|
|||
|
||||
text = self._job_key.GetVariable( 'popup_db_traceback' )
|
||||
|
||||
if self._db_tb_text.GetLabel() != text: self._db_tb_text.SetLabel( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
if self._db_tb_text.GetLabelText() != text: self._db_tb_text.SetLabelText( self._ProcessText( HydrusData.ToUnicode( text ) ) )
|
||||
|
||||
self._show_db_tb_button.Show()
|
||||
|
||||
|
@ -6247,7 +6246,7 @@ class RadioBox( StaticBox ):
|
|||
|
||||
def SetSelection( self, index ): self._indices_to_radio_buttons[ index ].SetValue( True )
|
||||
|
||||
def SetString( self, index, text ): self._indices_to_radio_buttons[ index ].SetLabel( text )
|
||||
def SetString( self, index, text ): self._indices_to_radio_buttons[ index ].SetLabelText( text )
|
||||
|
||||
class ShowKeys( Frame ):
|
||||
|
||||
|
@ -6340,12 +6339,12 @@ class WaitingPolitelyStaticText( wx.StaticText ):
|
|||
|
||||
if self._waiting:
|
||||
|
||||
self.SetLabel( 'waiting' )
|
||||
self.SetLabelText( 'waiting' )
|
||||
self.SetToolTipString( 'waiting before attempting another download' )
|
||||
|
||||
else:
|
||||
|
||||
self.SetLabel( 'ready ' )
|
||||
self.SetLabelText( 'ready ' )
|
||||
self.SetToolTipString( 'ready to download' )
|
||||
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import time
|
|||
import traceback
|
||||
import urllib
|
||||
import wx
|
||||
import wx.lib.agw.customtreectrl
|
||||
import yaml
|
||||
import HydrusData
|
||||
import ClientSearch
|
||||
|
@ -492,7 +493,7 @@ class DialogAdvancedContentUpdate( Dialog ):
|
|||
|
||||
self._tag = list( tags )[0]
|
||||
|
||||
self._specific_tag.SetLabel( HydrusTags.RenderTag( self._tag ) )
|
||||
self._specific_tag.SetLabelText( HydrusTags.RenderTag( self._tag ) )
|
||||
|
||||
|
||||
|
||||
|
@ -1672,7 +1673,7 @@ class DialogInputLocalFiles( Dialog ):
|
|||
self._gauge.SetValue( gauge_value )
|
||||
|
||||
|
||||
self._gauge_text.SetLabel( text )
|
||||
self._gauge_text.SetLabelText( text )
|
||||
|
||||
|
||||
def THREADParseImportablePaths( self, raw_paths, job_key ):
|
||||
|
@ -1788,7 +1789,8 @@ class DialogInputNamespaceRegex( Dialog ):
|
|||
|
||||
self._shortcuts = ClientGUICommon.RegexButton( self )
|
||||
|
||||
self._regex_link = wx.HyperlinkCtrl( self, id = -1, label = 'a good regex introduction', url = 'http://www.aivosto.com/vbtips/regex.html' )
|
||||
self._regex_intro_link = wx.HyperlinkCtrl( self, id = -1, label = 'a good regex introduction', url = 'http://www.aivosto.com/vbtips/regex.html' )
|
||||
self._regex_practise_link = wx.HyperlinkCtrl( self, id = -1, label = 'regex practise', url = 'http://regexr.com/3cvmf' )
|
||||
|
||||
self._ok = wx.Button( self, id = wx.ID_OK, label = 'Ok' )
|
||||
self._ok.Bind( wx.EVT_BUTTON, self.EventOK )
|
||||
|
@ -1821,7 +1823,8 @@ class DialogInputNamespaceRegex( Dialog ):
|
|||
vbox.AddF( wx.StaticText( self, label = intro ), CC.FLAGS_EXPAND_PERPENDICULAR )
|
||||
vbox.AddF( control_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
|
||||
vbox.AddF( self._shortcuts, CC.FLAGS_LONE_BUTTON )
|
||||
vbox.AddF( self._regex_link, CC.FLAGS_LONE_BUTTON )
|
||||
vbox.AddF( self._regex_intro_link, CC.FLAGS_LONE_BUTTON )
|
||||
vbox.AddF( self._regex_practise_link, CC.FLAGS_LONE_BUTTON )
|
||||
vbox.AddF( b_box, CC.FLAGS_BUTTON_SIZER )
|
||||
|
||||
self.SetSizer( vbox )
|
||||
|
@ -2363,7 +2366,7 @@ class DialogModifyAccounts( Dialog ):
|
|||
|
||||
else: subject_string = 'modifying ' + HydrusData.ConvertIntToPrettyString( len( self._subject_identifiers ) ) + ' accounts'
|
||||
|
||||
self._subject_text.SetLabel( subject_string )
|
||||
self._subject_text.SetLabelText( subject_string )
|
||||
|
||||
#
|
||||
|
||||
|
@ -2476,7 +2479,7 @@ class DialogModifyAccounts( Dialog ):
|
|||
|
||||
account_info = response[ 'account_info' ]
|
||||
|
||||
self._subject_text.SetLabel( HydrusData.ToUnicode( account_info ) )
|
||||
self._subject_text.SetLabelText( HydrusData.ToUnicode( account_info ) )
|
||||
|
||||
|
||||
if len( self._subject_identifiers ) > 1: wx.MessageBox( 'Done!' )
|
||||
|
@ -2709,16 +2712,16 @@ class DialogPageChooser( Dialog ):
|
|||
|
||||
( entry_type, obj ) = entry
|
||||
|
||||
if entry_type == 'menu': button.SetLabel( obj )
|
||||
if entry_type == 'menu': button.SetLabelText( obj )
|
||||
elif entry_type in ( 'page_query', 'page_petitions' ):
|
||||
|
||||
name = HydrusGlobals.client_controller.GetServicesManager().GetService( obj ).GetName()
|
||||
|
||||
button.SetLabel( name )
|
||||
button.SetLabelText( name )
|
||||
|
||||
elif entry_type == 'page_import_booru':
|
||||
|
||||
button.SetLabel( 'booru' )
|
||||
button.SetLabelText( 'booru' )
|
||||
|
||||
elif entry_type == 'page_import_gallery':
|
||||
|
||||
|
@ -2726,10 +2729,10 @@ class DialogPageChooser( Dialog ):
|
|||
|
||||
text = HC.site_type_string_lookup[ site_type ]
|
||||
|
||||
button.SetLabel( text )
|
||||
button.SetLabelText( text )
|
||||
|
||||
elif entry_type == 'page_import_thread_watcher': button.SetLabel( 'thread watcher' )
|
||||
elif entry_type == 'page_import_page_of_images': button.SetLabel( 'page of images' )
|
||||
elif entry_type == 'page_import_thread_watcher': button.SetLabelText( 'thread watcher' )
|
||||
elif entry_type == 'page_import_page_of_images': button.SetLabelText( 'page of images' )
|
||||
|
||||
button.Show()
|
||||
|
||||
|
@ -3068,7 +3071,8 @@ class DialogPathsToTags( Dialog ):
|
|||
|
||||
self._regex_shortcuts = ClientGUICommon.RegexButton( self._regexes_panel )
|
||||
|
||||
self._regex_link = wx.HyperlinkCtrl( self._regexes_panel, id = -1, label = 'a good regex introduction', url = 'http://www.aivosto.com/vbtips/regex.html' )
|
||||
self._regex_intro_link = wx.HyperlinkCtrl( self._regexes_panel, id = -1, label = 'a good regex introduction', url = 'http://www.aivosto.com/vbtips/regex.html' )
|
||||
self._regex_practise_link = wx.HyperlinkCtrl( self._regexes_panel, id = -1, label = 'regex practise', url = 'http://regexr.com/3cvmf' )
|
||||
|
||||
#
|
||||
|
||||
|
@ -3147,7 +3151,8 @@ class DialogPathsToTags( Dialog ):
|
|||
self._regexes_panel.AddF( self._regexes, CC.FLAGS_EXPAND_BOTH_WAYS )
|
||||
self._regexes_panel.AddF( self._regex_box, CC.FLAGS_EXPAND_PERPENDICULAR )
|
||||
self._regexes_panel.AddF( self._regex_shortcuts, CC.FLAGS_LONE_BUTTON )
|
||||
self._regexes_panel.AddF( self._regex_link, CC.FLAGS_LONE_BUTTON )
|
||||
self._regexes_panel.AddF( self._regex_intro_link, CC.FLAGS_LONE_BUTTON )
|
||||
self._regexes_panel.AddF( self._regex_practise_link, CC.FLAGS_LONE_BUTTON )
|
||||
|
||||
#
|
||||
|
||||
|
@ -3213,7 +3218,7 @@ class DialogPathsToTags( Dialog ):
|
|||
|
||||
try:
|
||||
|
||||
txt_tags = [ HydrusData.ToUnicode( tag ) for tag in txt_tags_string.split( os.linesep ) ]
|
||||
txt_tags = [ HydrusData.ToUnicode( tag ) for tag in HydrusData.SplitByLinesep( txt_tags_string ) ]
|
||||
|
||||
tags.extend( txt_tags )
|
||||
|
||||
|
@ -3689,62 +3694,167 @@ class DialogSelectBooru( Dialog ):
|
|||
return gallery_identifier
|
||||
|
||||
|
||||
class DialogSelectFromURLTree( Dialog ):
|
||||
|
||||
def __init__( self, parent, url_tree ):
|
||||
|
||||
Dialog.__init__( self, parent, 'select items' )
|
||||
|
||||
agwStyle = wx.lib.agw.customtreectrl.TR_DEFAULT_STYLE | wx.lib.agw.customtreectrl.TR_AUTO_CHECK_CHILD
|
||||
|
||||
self._tree = wx.lib.agw.customtreectrl.CustomTreeCtrl( self, agwStyle = agwStyle )
|
||||
|
||||
self._ok = wx.Button( self, id = wx.ID_OK )
|
||||
self._ok.SetForegroundColour( ( 0, 128, 0 ) )
|
||||
|
||||
self._cancel = wx.Button( self, id = wx.ID_CANCEL )
|
||||
self._cancel.SetForegroundColour( ( 128, 0, 0 ) )
|
||||
|
||||
#
|
||||
|
||||
( text_gumpf, name, size, children ) = url_tree
|
||||
|
||||
root_name = self._RenderItemName( name, size )
|
||||
|
||||
root_item = self._tree.AddRoot( root_name, ct_type = 1 )
|
||||
|
||||
self._AddDirectory( root_item, children )
|
||||
|
||||
self._tree.CheckItem( root_item )
|
||||
|
||||
self._tree.Expand( root_item )
|
||||
|
||||
#
|
||||
|
||||
button_hbox = wx.BoxSizer( wx.HORIZONTAL )
|
||||
|
||||
button_hbox.AddF( self._ok, CC.FLAGS_MIXED )
|
||||
button_hbox.AddF( self._cancel, CC.FLAGS_MIXED )
|
||||
|
||||
vbox = wx.BoxSizer( wx.VERTICAL )
|
||||
|
||||
vbox.AddF( self._tree, CC.FLAGS_EXPAND_BOTH_WAYS )
|
||||
vbox.AddF( button_hbox, CC.FLAGS_BUTTON_SIZER )
|
||||
|
||||
self.SetSizer( vbox )
|
||||
|
||||
( x, y ) = self.GetEffectiveMinSize()
|
||||
|
||||
x = max( x, 480 )
|
||||
y = max( y, 640 )
|
||||
|
||||
self.SetInitialSize( ( x, y ) )
|
||||
|
||||
|
||||
def _AddDirectory( self, root, children ):
|
||||
|
||||
for ( child_type, name, size, data ) in children:
|
||||
|
||||
item_name = self._RenderItemName( name, size )
|
||||
|
||||
if child_type == 'file':
|
||||
|
||||
self._tree.AppendItem( root, item_name, ct_type = 1, data = data )
|
||||
|
||||
else:
|
||||
|
||||
subroot = self._tree.AppendItem( root, item_name, ct_type = 1 )
|
||||
|
||||
self._AddDirectory( subroot, data )
|
||||
|
||||
|
||||
|
||||
|
||||
def _GetSelectedChildrenData( self, parent_item ):
|
||||
|
||||
result = []
|
||||
|
||||
cookie = 0
|
||||
|
||||
( child_item, cookie ) = self._tree.GetNextChild( parent_item, cookie )
|
||||
|
||||
while child_item is not None:
|
||||
|
||||
data = self._tree.GetItemPyData( child_item )
|
||||
|
||||
if data is None:
|
||||
|
||||
result.extend( self._GetSelectedChildrenData( child_item ) )
|
||||
|
||||
else:
|
||||
|
||||
if self._tree.IsItemChecked( child_item ):
|
||||
|
||||
result.append( data )
|
||||
|
||||
|
||||
|
||||
( child_item, cookie ) = self._tree.GetNextChild( parent_item, cookie )
|
||||
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def _RenderItemName( self, name, size ):
|
||||
|
||||
return name + ' - ' + HydrusData.ConvertIntToBytes( size )
|
||||
|
||||
|
||||
def GetURLs( self ):
|
||||
|
||||
root_item = self._tree.GetRootItem()
|
||||
|
||||
urls = self._GetSelectedChildrenData( root_item )
|
||||
|
||||
return urls
|
||||
|
||||
|
||||
|
||||
class DialogSelectImageboard( Dialog ):
|
||||
|
||||
def __init__( self, parent ):
|
||||
|
||||
def InitialiseControls():
|
||||
|
||||
self._hidden_cancel = wx.Button( self, id = wx.ID_CANCEL, size = ( 0, 0 ) )
|
||||
|
||||
self._tree = wx.TreeCtrl( self )
|
||||
self._tree.Bind( wx.EVT_TREE_ITEM_ACTIVATED, self.EventActivate )
|
||||
|
||||
|
||||
def PopulateControls():
|
||||
|
||||
all_imageboards = HydrusGlobals.client_controller.Read( 'imageboards' )
|
||||
|
||||
root_item = self._tree.AddRoot( 'all sites' )
|
||||
|
||||
for ( site, imageboards ) in all_imageboards.items():
|
||||
|
||||
site_item = self._tree.AppendItem( root_item, site )
|
||||
|
||||
for imageboard in imageboards:
|
||||
|
||||
name = imageboard.GetName()
|
||||
|
||||
self._tree.AppendItem( site_item, name, data = wx.TreeItemData( imageboard ) )
|
||||
|
||||
|
||||
|
||||
self._tree.Expand( root_item )
|
||||
|
||||
|
||||
def ArrangeControls():
|
||||
|
||||
vbox = wx.BoxSizer( wx.VERTICAL )
|
||||
|
||||
vbox.AddF( self._tree, CC.FLAGS_EXPAND_BOTH_WAYS )
|
||||
|
||||
self.SetSizer( vbox )
|
||||
|
||||
( x, y ) = self.GetEffectiveMinSize()
|
||||
|
||||
if x < 320: x = 320
|
||||
if y < 640: y = 640
|
||||
|
||||
self.SetInitialSize( ( x, y ) )
|
||||
|
||||
|
||||
Dialog.__init__( self, parent, 'select imageboard' )
|
||||
|
||||
InitialiseControls()
|
||||
self._hidden_cancel = wx.Button( self, id = wx.ID_CANCEL, size = ( 0, 0 ) )
|
||||
|
||||
PopulateControls()
|
||||
self._tree = wx.TreeCtrl( self )
|
||||
self._tree.Bind( wx.EVT_TREE_ITEM_ACTIVATED, self.EventActivate )
|
||||
|
||||
ArrangeControls()
|
||||
#
|
||||
|
||||
all_imageboards = HydrusGlobals.client_controller.Read( 'imageboards' )
|
||||
|
||||
root_item = self._tree.AddRoot( 'all sites' )
|
||||
|
||||
for ( site, imageboards ) in all_imageboards.items():
|
||||
|
||||
site_item = self._tree.AppendItem( root_item, site )
|
||||
|
||||
for imageboard in imageboards:
|
||||
|
||||
name = imageboard.GetName()
|
||||
|
||||
self._tree.AppendItem( site_item, name, data = wx.TreeItemData( imageboard ) )
|
||||
|
||||
|
||||
|
||||
self._tree.Expand( root_item )
|
||||
|
||||
#
|
||||
|
||||
vbox = wx.BoxSizer( wx.VERTICAL )
|
||||
|
||||
vbox.AddF( self._tree, CC.FLAGS_EXPAND_BOTH_WAYS )
|
||||
|
||||
self.SetSizer( vbox )
|
||||
|
||||
( x, y ) = self.GetEffectiveMinSize()
|
||||
|
||||
if x < 320: x = 320
|
||||
if y < 640: y = 640
|
||||
|
||||
self.SetInitialSize( ( x, y ) )
|
||||
|
||||
|
||||
def EventActivate( self, event ):
|
||||
|
|
|
@ -121,7 +121,7 @@ class DialogManage4chanPass( ClientGUIDialogs.Dialog ):
|
|||
elif HydrusData.TimeHasPassed( self._timeout ): label = 'timed out'
|
||||
else: label = 'authenticated - ' + HydrusData.ConvertTimestampToPrettyExpires( self._timeout )
|
||||
|
||||
self._status.SetLabel( label )
|
||||
self._status.SetLabelText( label )
|
||||
|
||||
|
||||
def EventOK( self, event ):
|
||||
|
@ -2984,7 +2984,7 @@ class DialogManageImportFoldersEdit( ClientGUIDialogs.Dialog ):
|
|||
text = 'Not loading tags from neighbouring .txt files for any tag services.'
|
||||
|
||||
|
||||
self._txt_parse_st.SetLabel( text )
|
||||
self._txt_parse_st.SetLabelText( text )
|
||||
|
||||
|
||||
def EventCheckLocations( self, event ):
|
||||
|
@ -4880,21 +4880,21 @@ class DialogManageOptions( ClientGUIDialogs.Dialog ):
|
|||
|
||||
estimated_bytes_per_fullscreen = 3 * width * height
|
||||
|
||||
self._estimated_number_fullscreens.SetLabel( '(about ' + HydrusData.ConvertIntToPrettyString( ( self._fullscreen_cache_size.GetValue() * 1048576 ) / estimated_bytes_per_fullscreen ) + '-' + HydrusData.ConvertIntToPrettyString( ( self._fullscreen_cache_size.GetValue() * 1048576 ) / ( estimated_bytes_per_fullscreen / 4 ) ) + ' images)' )
|
||||
self._estimated_number_fullscreens.SetLabelText( '(about ' + HydrusData.ConvertIntToPrettyString( ( self._fullscreen_cache_size.GetValue() * 1048576 ) / estimated_bytes_per_fullscreen ) + '-' + HydrusData.ConvertIntToPrettyString( ( self._fullscreen_cache_size.GetValue() * 1048576 ) / ( estimated_bytes_per_fullscreen / 4 ) ) + ' images)' )
|
||||
|
||||
|
||||
def EventPreviewsUpdate( self, event ):
|
||||
|
||||
estimated_bytes_per_preview = 3 * 400 * 400
|
||||
|
||||
self._estimated_number_previews.SetLabel( '(about ' + HydrusData.ConvertIntToPrettyString( ( self._preview_cache_size.GetValue() * 1048576 ) / estimated_bytes_per_preview ) + ' previews)' )
|
||||
self._estimated_number_previews.SetLabelText( '(about ' + HydrusData.ConvertIntToPrettyString( ( self._preview_cache_size.GetValue() * 1048576 ) / estimated_bytes_per_preview ) + ' previews)' )
|
||||
|
||||
|
||||
def EventThumbnailsUpdate( self, event ):
|
||||
|
||||
estimated_bytes_per_thumb = 3 * self._thumbnail_height.GetValue() * self._thumbnail_width.GetValue()
|
||||
|
||||
self._estimated_number_thumbnails.SetLabel( '(about ' + HydrusData.ConvertIntToPrettyString( ( self._thumbnail_cache_size.GetValue() * 1048576 ) / estimated_bytes_per_thumb ) + ' thumbnails)' )
|
||||
self._estimated_number_thumbnails.SetLabelText( '(about ' + HydrusData.ConvertIntToPrettyString( ( self._thumbnail_cache_size.GetValue() * 1048576 ) / estimated_bytes_per_thumb ) + ' thumbnails)' )
|
||||
|
||||
|
||||
def UpdateOptions( self ):
|
||||
|
@ -5131,8 +5131,8 @@ class DialogManagePixivAccount( ClientGUIDialogs.Dialog ):
|
|||
( response_gumpf, cookies ) = HydrusGlobals.client_controller.DoHTTP( HC.POST, 'http://www.pixiv.net/login.php', request_headers = headers, body = body, return_cookies = True )
|
||||
|
||||
# _ only given to logged in php sessions
|
||||
if 'PHPSESSID' in cookies and '_' in cookies[ 'PHPSESSID' ]: self._status.SetLabel( 'OK!' )
|
||||
else: self._status.SetLabel( 'Did not work!' )
|
||||
if 'PHPSESSID' in cookies and '_' in cookies[ 'PHPSESSID' ]: self._status.SetLabelText( 'OK!' )
|
||||
else: self._status.SetLabelText( 'Did not work!' )
|
||||
|
||||
wx.CallLater( 2000, self._status.SetLabel, '' )
|
||||
|
||||
|
@ -6982,7 +6982,7 @@ class DialogManageServices( ClientGUIDialogs.Dialog ):
|
|||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
|
||||
self._reset_downloading_button.SetLabel( 'everything will be reset on dialog ok!' )
|
||||
self._reset_downloading_button.SetLabelText( 'everything will be reset on dialog ok!' )
|
||||
|
||||
self._reset_downloading = True
|
||||
|
||||
|
@ -6999,7 +6999,7 @@ class DialogManageServices( ClientGUIDialogs.Dialog ):
|
|||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
|
||||
self._reset_processing_button.SetLabel( 'processing will be reset on dialog ok!' )
|
||||
self._reset_processing_button.SetLabelText( 'processing will be reset on dialog ok!' )
|
||||
|
||||
self._reset_processing = True
|
||||
|
||||
|
@ -7502,7 +7502,7 @@ class DialogManageSubscriptions( ClientGUIDialogs.Dialog ):
|
|||
|
||||
self._original_subscription.CheckNow()
|
||||
|
||||
self._check_now_button.SetLabel( 'will check on dialog ok' )
|
||||
self._check_now_button.SetLabelText( 'will check on dialog ok' )
|
||||
self._check_now_button.Disable()
|
||||
|
||||
|
||||
|
@ -7516,7 +7516,7 @@ class DialogManageSubscriptions( ClientGUIDialogs.Dialog ):
|
|||
|
||||
self._original_subscription.Reset()
|
||||
|
||||
self._reset_cache_button.SetLabel( 'cache will be reset on dialog ok' )
|
||||
self._reset_cache_button.SetLabelText( 'cache will be reset on dialog ok' )
|
||||
self._reset_cache_button.Disable()
|
||||
|
||||
|
||||
|
@ -8980,7 +8980,7 @@ class DialogManageTagSiblings( ClientGUIDialogs.Dialog ):
|
|||
|
||||
if len( new_tags ) == 0:
|
||||
|
||||
self._new_sibling.SetLabel( '' )
|
||||
self._new_sibling.SetLabelText( '' )
|
||||
|
||||
self._current_new = None
|
||||
|
||||
|
@ -8990,7 +8990,7 @@ class DialogManageTagSiblings( ClientGUIDialogs.Dialog ):
|
|||
|
||||
self._old_siblings.RemoveTags( { new } )
|
||||
|
||||
self._new_sibling.SetLabel( HydrusTags.RenderTag( new ) )
|
||||
self._new_sibling.SetLabelText( HydrusTags.RenderTag( new ) )
|
||||
|
||||
self._current_new = new
|
||||
|
||||
|
@ -9682,9 +9682,11 @@ class DialogManageTags( ClientGUIDialogs.Dialog ):
|
|||
|
||||
tags = self._tags_box.GetSelectedTags()
|
||||
|
||||
hashes = set( itertools.chain.from_iterable( ( m.GetHashes() for m in self._media ) ) )
|
||||
|
||||
for tag in tags:
|
||||
|
||||
contents.extend( [ HydrusData.Content( HC.CONTENT_TYPE_MAPPING, ( tag, hash ) ) for hash in self._hashes ] )
|
||||
contents.extend( [ HydrusData.Content( HC.CONTENT_TYPE_MAPPING, ( tag, hash ) ) for hash in hashes ] )
|
||||
|
||||
|
||||
if len( contents ) > 0:
|
||||
|
@ -9757,9 +9759,9 @@ class DialogManageTags( ClientGUIDialogs.Dialog ):
|
|||
|
||||
if media is None: media = []
|
||||
|
||||
self._hashes = { hash for hash in itertools.chain.from_iterable( ( m.GetHashes() for m in media ) ) }
|
||||
hashes = { hash for hash in itertools.chain.from_iterable( ( m.GetHashes() for m in media ) ) }
|
||||
|
||||
if len( self._hashes ) > 0: media_results = HydrusGlobals.client_controller.Read( 'media_results', self._file_service_key, self._hashes )
|
||||
if len( hashes ) > 0: media_results = HydrusGlobals.client_controller.Read( 'media_results', self._file_service_key, hashes )
|
||||
else: media_results = []
|
||||
|
||||
# this should now be a nice clean copy of the original media
|
||||
|
|
|
@ -328,7 +328,7 @@ class FullscreenHoverFrameCommands( FullscreenHoverFrame ):
|
|||
|
||||
if len( label ) > 0:
|
||||
|
||||
self._title_text.SetLabel( label )
|
||||
self._title_text.SetLabelText( label )
|
||||
|
||||
self._title_text.Show()
|
||||
|
||||
|
@ -336,7 +336,7 @@ class FullscreenHoverFrameCommands( FullscreenHoverFrame ):
|
|||
|
||||
label = self._current_media.GetPrettyInfo() + ' | ' + self._current_media.GetPrettyAge()
|
||||
|
||||
self._info_text.SetLabel( label )
|
||||
self._info_text.SetLabelText( label )
|
||||
|
||||
self._info_text.Show()
|
||||
|
||||
|
@ -412,7 +412,7 @@ class FullscreenHoverFrameCommands( FullscreenHoverFrame ):
|
|||
|
||||
label = ClientData.ConvertZoomToPercentage( self._current_zoom )
|
||||
|
||||
self._zoom_text.SetLabel( label )
|
||||
self._zoom_text.SetLabelText( label )
|
||||
|
||||
self._top_hbox.Layout()
|
||||
|
||||
|
@ -440,7 +440,7 @@ class FullscreenHoverFrameCommands( FullscreenHoverFrame ):
|
|||
|
||||
self._current_index_string = text
|
||||
|
||||
self._index_text.SetLabel( self._current_index_string )
|
||||
self._index_text.SetLabelText( self._current_index_string )
|
||||
|
||||
self._top_hbox.Layout()
|
||||
|
||||
|
@ -601,7 +601,7 @@ class FullscreenHoverFrameRatings( FullscreenHoverFrame ):
|
|||
|
||||
remote_string = os.linesep.join( remote_strings )
|
||||
|
||||
self._file_repos.SetLabel( remote_string )
|
||||
self._file_repos.SetLabelText( remote_string )
|
||||
|
||||
self._file_repos.Show()
|
||||
|
||||
|
|
|
@ -248,10 +248,10 @@ def GenerateDumpMultipartFormDataCTAndBody( fields ):
|
|||
|
||||
dc.Clear()
|
||||
|
||||
self._refresh_button.SetLabel( '' )
|
||||
self._refresh_button.SetLabelText( '' )
|
||||
self._refresh_button.Disable()
|
||||
|
||||
self._captcha_time_left.SetLabel( '' )
|
||||
self._captcha_time_left.SetLabelText( '' )
|
||||
|
||||
elif self._captcha_challenge == '':
|
||||
|
||||
|
@ -265,16 +265,16 @@ def GenerateDumpMultipartFormDataCTAndBody( fields ):
|
|||
|
||||
if event.IsAllowed():
|
||||
|
||||
self._refresh_button.SetLabel( 'get captcha' )
|
||||
self._refresh_button.SetLabelText( 'get captcha' )
|
||||
self._refresh_button.Enable()
|
||||
|
||||
else:
|
||||
|
||||
self._refresh_button.SetLabel( 'not yet' )
|
||||
self._refresh_button.SetLabelText( 'not yet' )
|
||||
self._refresh_button.Disable()
|
||||
|
||||
|
||||
self._captcha_time_left.SetLabel( '' )
|
||||
self._captcha_time_left.SetLabelText( '' )
|
||||
|
||||
else:
|
||||
|
||||
|
@ -284,10 +284,10 @@ def GenerateDumpMultipartFormDataCTAndBody( fields ):
|
|||
|
||||
wx.CallAfter( wx_bmp.Destroy )
|
||||
|
||||
self._refresh_button.SetLabel( 'get new captcha' )
|
||||
self._refresh_button.SetLabelText( 'get new captcha' )
|
||||
self._refresh_button.Enable()
|
||||
|
||||
self._captcha_time_left.SetLabel( HydrusData.ConvertTimestampToPrettyExpires( self._captcha_runs_out ) )
|
||||
self._captcha_time_left.SetLabelText( HydrusData.ConvertTimestampToPrettyExpires( self._captcha_runs_out ) )
|
||||
|
||||
|
||||
del dc
|
||||
|
@ -297,7 +297,7 @@ def GenerateDumpMultipartFormDataCTAndBody( fields ):
|
|||
|
||||
if ready is None:
|
||||
|
||||
self._ready_button.SetLabel( '' )
|
||||
self._ready_button.SetLabelText( '' )
|
||||
self._ready_button.Disable()
|
||||
|
||||
else:
|
||||
|
@ -305,12 +305,12 @@ def GenerateDumpMultipartFormDataCTAndBody( fields ):
|
|||
if ready:
|
||||
|
||||
self._captcha_entry.Disable()
|
||||
self._ready_button.SetLabel( 'edit' )
|
||||
self._ready_button.SetLabelText( 'edit' )
|
||||
|
||||
else:
|
||||
|
||||
self._captcha_entry.Enable()
|
||||
self._ready_button.SetLabel( 'ready' )
|
||||
self._ready_button.SetLabelText( 'ready' )
|
||||
|
||||
|
||||
self._ready_button.Enable()
|
||||
|
@ -366,7 +366,7 @@ def GenerateDumpMultipartFormDataCTAndBody( fields ):
|
|||
else: event.Skip()
|
||||
|
||||
|
||||
def EventReady( self, event ): self._DrawReady( not self._ready_button.GetLabel() == 'edit' )
|
||||
def EventReady( self, event ): self._DrawReady( not self._ready_button.GetLabelText() == 'edit' )
|
||||
|
||||
def EventRefreshCaptcha( self, event ):
|
||||
|
||||
|
@ -401,7 +401,7 @@ def GenerateDumpMultipartFormDataCTAndBody( fields ):
|
|||
|
||||
|
||||
# change this to hold (current challenge, bmp, timestamp it runs out, value, whethere ready to post)
|
||||
def GetValues( self ): return ( self._captcha_challenge, self._bitmap, self._captcha_runs_out, self._captcha_entry.GetValue(), self._ready_button.GetLabel() == 'edit' )
|
||||
def GetValues( self ): return ( self._captcha_challenge, self._bitmap, self._captcha_runs_out, self._captcha_entry.GetValue(), self._ready_button.GetLabelText() == 'edit' )
|
||||
|
||||
def TIMEREvent( self, event ):
|
||||
|
||||
|
@ -921,7 +921,7 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
|
||||
if self._current_hash is None:
|
||||
|
||||
self._post_info.SetLabel( 'no file selected' )
|
||||
self._post_info.SetLabelText( 'no file selected' )
|
||||
|
||||
for ( name, ( field_type, field, default ) ) in self._post_fields.items():
|
||||
|
||||
|
@ -938,7 +938,7 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
|
||||
index = self._sorted_media_hashes.index( self._current_hash )
|
||||
|
||||
self._post_info.SetLabel( HydrusData.ConvertValueRangeToPrettyString( index + 1, num_files ) + ': ' + dump_status_string )
|
||||
self._post_info.SetLabelText( HydrusData.ConvertValueRangeToPrettyString( index + 1, num_files ) + ': ' + dump_status_string )
|
||||
|
||||
for ( name, field_type, value ) in post_field_info:
|
||||
|
||||
|
@ -1066,7 +1066,7 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
dump_status_enum = CC.DUMPER_RECOVERABLE_ERROR
|
||||
dump_status_string = ''
|
||||
|
||||
self._progress_info.SetLabel( 'Flood limit hit, retrying.' )
|
||||
self._progress_info.SetLabelText( 'Flood limit hit, retrying.' )
|
||||
|
||||
self._next_dump_time = HydrusData.GetNow() + self._flood_time
|
||||
|
||||
|
@ -1077,7 +1077,7 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
|
||||
HydrusData.ShowText( phrase )
|
||||
|
||||
self._progress_info.SetLabel( 'error: ' + phrase )
|
||||
self._progress_info.SetLabelText( 'error: ' + phrase )
|
||||
|
||||
self._start_button.Disable()
|
||||
|
||||
|
@ -1088,7 +1088,7 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
dump_status_enum = CC.DUMPER_UNRECOVERABLE_ERROR
|
||||
dump_status_string = ''
|
||||
|
||||
self._progress_info.SetLabel( 'thread specified does not exist!' )
|
||||
self._progress_info.SetLabelText( 'thread specified does not exist!' )
|
||||
|
||||
self._start_button.Disable()
|
||||
|
||||
|
@ -1112,7 +1112,7 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
|
||||
if self._next_dump_index == len( self._sorted_media_hashes ):
|
||||
|
||||
self._progress_info.SetLabel( 'done - ' + str( self._num_dumped ) + ' dumped' )
|
||||
self._progress_info.SetLabelText( 'done - ' + str( self._num_dumped ) + ' dumped' )
|
||||
|
||||
self._start_button.Disable()
|
||||
|
||||
|
@ -1148,7 +1148,7 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
|
||||
def EventStartButton( self, event ):
|
||||
|
||||
if self._start_button.GetLabel() in ( 'start', 'continue' ):
|
||||
if self._start_button.GetLabelText() in ( 'start', 'continue' ):
|
||||
|
||||
for ( name, ( field_type, field ) ) in self._thread_fields.items():
|
||||
|
||||
|
@ -1166,7 +1166,7 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
try: int( thread_id )
|
||||
except:
|
||||
|
||||
self._progress_info.SetLabel( 'set thread_id field first' )
|
||||
self._progress_info.SetLabelText( 'set thread_id field first' )
|
||||
|
||||
return
|
||||
|
||||
|
@ -1179,7 +1179,7 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
for ( field_type, field ) in self._thread_fields.values(): field.Disable()
|
||||
|
||||
self._dumping = True
|
||||
self._start_button.SetLabel( 'pause' )
|
||||
self._start_button.SetLabelText( 'pause' )
|
||||
|
||||
if self._next_dump_time == 0: self._next_dump_time = HydrusData.GetNow() + 5
|
||||
|
||||
|
@ -1191,8 +1191,8 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
|
||||
self._dumping = False
|
||||
|
||||
if self._num_dumped == 0: self._start_button.SetLabel( 'start' )
|
||||
else: self._start_button.SetLabel( 'continue' )
|
||||
if self._num_dumped == 0: self._start_button.SetLabelText( 'start' )
|
||||
else: self._start_button.SetLabelText( 'continue' )
|
||||
|
||||
|
||||
|
||||
|
@ -1324,10 +1324,10 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
|
||||
|
||||
|
||||
if wait: self._progress_info.SetLabel( 'waiting for captcha' )
|
||||
if wait: self._progress_info.SetLabelText( 'waiting for captcha' )
|
||||
else:
|
||||
|
||||
self._progress_info.SetLabel( 'dumping' ) # 100% cpu time here - may or may not be desirable
|
||||
self._progress_info.SetLabelText( 'dumping' ) # 100% cpu time here - may or may not be desirable
|
||||
|
||||
post_fields = []
|
||||
|
||||
|
@ -1388,12 +1388,12 @@ class ManagementPanelDumper( ManagementPanel ):
|
|||
wx.CallAfter( self.CALLBACKDoneDump, hash, post_field_info, status, phrase )
|
||||
|
||||
|
||||
else: self._progress_info.SetLabel( 'dumping next file in ' + str( time_left ) + ' seconds' )
|
||||
else: self._progress_info.SetLabelText( 'dumping next file in ' + str( time_left ) + ' seconds' )
|
||||
|
||||
else:
|
||||
|
||||
if self._num_dumped == 0: self._progress_info.SetLabel( 'will dump to ' + self._imageboard.GetName() )
|
||||
else: self._progress_info.SetLabel( 'paused after ' + str( self._num_dumped ) + ' files dumped' )
|
||||
if self._num_dumped == 0: self._progress_info.SetLabelText( 'will dump to ' + self._imageboard.GetName() )
|
||||
else: self._progress_info.SetLabelText( 'paused after ' + str( self._num_dumped ) + ' files dumped' )
|
||||
|
||||
|
||||
|
||||
|
@ -1435,7 +1435,7 @@ class ManagementPanelGalleryImport( ManagementPanel ):
|
|||
|
||||
self._pending_queries_panel = ClientGUICommon.StaticBox( self._gallery_downloader_panel, 'pending queries' )
|
||||
|
||||
self._pending_queries_listbox = wx.ListBox( self._pending_queries_panel, size = ( -1, 200 ) )
|
||||
self._pending_queries_listbox = wx.ListBox( self._pending_queries_panel, size = ( -1, 100 ) )
|
||||
|
||||
self._advance_button = wx.Button( self._pending_queries_panel, label = u'\u2191' )
|
||||
self._advance_button.Bind( wx.EVT_BUTTON, self.EventAdvance )
|
||||
|
@ -1449,6 +1449,9 @@ class ManagementPanelGalleryImport( ManagementPanel ):
|
|||
self._query_input = wx.TextCtrl( self._pending_queries_panel, style = wx.TE_PROCESS_ENTER )
|
||||
self._query_input.Bind( wx.EVT_KEY_DOWN, self.EventKeyDown )
|
||||
|
||||
self._query_paste = wx.Button( self._pending_queries_panel, label = 'paste queries' )
|
||||
self._query_paste.Bind( wx.EVT_BUTTON, self.EventPaste )
|
||||
|
||||
self._get_tags_if_redundant = wx.CheckBox( self._gallery_downloader_panel, label = 'get tags even if file is already in db' )
|
||||
self._get_tags_if_redundant.Bind( wx.EVT_CHECKBOX, self.EventGetTagsIfRedundant )
|
||||
self._get_tags_if_redundant.SetToolTipString( 'only fetch tags from the gallery if the file is new' )
|
||||
|
@ -1483,8 +1486,13 @@ class ManagementPanelGalleryImport( ManagementPanel ):
|
|||
queue_hbox.AddF( self._pending_queries_listbox, CC.FLAGS_EXPAND_BOTH_WAYS )
|
||||
queue_hbox.AddF( queue_buttons_vbox, CC.FLAGS_MIXED )
|
||||
|
||||
input_hbox = wx.BoxSizer( wx.HORIZONTAL )
|
||||
|
||||
input_hbox.AddF( self._query_input, CC.FLAGS_EXPAND_BOTH_WAYS )
|
||||
input_hbox.AddF( self._query_paste, CC.FLAGS_MIXED )
|
||||
|
||||
self._pending_queries_panel.AddF( queue_hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
|
||||
self._pending_queries_panel.AddF( self._query_input, CC.FLAGS_EXPAND_PERPENDICULAR )
|
||||
self._pending_queries_panel.AddF( input_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
|
||||
|
||||
#
|
||||
|
||||
|
@ -1574,9 +1582,9 @@ class ManagementPanelGalleryImport( ManagementPanel ):
|
|||
|
||||
|
||||
|
||||
if self._overall_status.GetLabel() != overall_status:
|
||||
if self._overall_status.GetLabelText() != overall_status:
|
||||
|
||||
self._overall_status.SetLabel( overall_status )
|
||||
self._overall_status.SetLabelText( overall_status )
|
||||
|
||||
|
||||
self._overall_gauge.SetRange( overall_range )
|
||||
|
@ -1637,14 +1645,14 @@ class ManagementPanelGalleryImport( ManagementPanel ):
|
|||
self._gallery_cancel_button.Disable()
|
||||
|
||||
|
||||
if self._gallery_status.GetLabel() != gallery_status:
|
||||
if self._gallery_status.GetLabelText() != gallery_status:
|
||||
|
||||
self._gallery_status.SetLabel( gallery_status )
|
||||
self._gallery_status.SetLabelText( gallery_status )
|
||||
|
||||
|
||||
if self._current_action.GetLabel() != current_action:
|
||||
if self._current_action.GetLabelText() != current_action:
|
||||
|
||||
self._current_action.SetLabel( current_action )
|
||||
self._current_action.SetLabelText( current_action )
|
||||
|
||||
|
||||
|
||||
|
@ -1733,12 +1741,15 @@ class ManagementPanelGalleryImport( ManagementPanel ):
|
|||
|
||||
self._gallery_import.PendQuery( query )
|
||||
|
||||
self._query_input.SetValue( '' )
|
||||
|
||||
self._Update()
|
||||
|
||||
|
||||
else: event.Skip()
|
||||
self._query_input.SetValue( '' )
|
||||
|
||||
self._Update()
|
||||
|
||||
else:
|
||||
|
||||
event.Skip()
|
||||
|
||||
|
||||
|
||||
def EventMenu( self, event ):
|
||||
|
@ -1765,6 +1776,41 @@ class ManagementPanelGalleryImport( ManagementPanel ):
|
|||
|
||||
|
||||
|
||||
def EventPaste( self, event ):
|
||||
|
||||
if wx.TheClipboard.Open():
|
||||
|
||||
data = wx.TextDataObject()
|
||||
|
||||
wx.TheClipboard.GetData( data )
|
||||
|
||||
wx.TheClipboard.Close()
|
||||
|
||||
raw_text = data.GetText()
|
||||
|
||||
try:
|
||||
|
||||
for query in HydrusData.SplitByLinesep( raw_text ):
|
||||
|
||||
if query != '':
|
||||
|
||||
self._gallery_import.PendQuery( query )
|
||||
|
||||
|
||||
|
||||
self._Update()
|
||||
|
||||
except:
|
||||
|
||||
wx.MessageBox( 'I could not understand what was in the clipboard' )
|
||||
|
||||
|
||||
else:
|
||||
|
||||
wx.MessageBox( 'I could not get permission to access the clipboard.' )
|
||||
|
||||
|
||||
|
||||
def EventSeedCache( self, event ):
|
||||
|
||||
seed_cache = self._gallery_import.GetSeedCache()
|
||||
|
@ -1843,9 +1889,9 @@ class ManagementPanelHDDImport( ManagementPanel ):
|
|||
|
||||
( ( overall_status, ( overall_value, overall_range ) ), paused ) = self._hdd_import.GetStatus()
|
||||
|
||||
if self._overall_status.GetLabel() != overall_status:
|
||||
if self._overall_status.GetLabelText() != overall_status:
|
||||
|
||||
self._overall_status.SetLabel( overall_status )
|
||||
self._overall_status.SetLabelText( overall_status )
|
||||
|
||||
|
||||
self._overall_gauge.SetRange( overall_range )
|
||||
|
@ -1893,9 +1939,9 @@ class ManagementPanelHDDImport( ManagementPanel ):
|
|||
|
||||
|
||||
|
||||
if self._current_action.GetLabel() != current_action:
|
||||
if self._current_action.GetLabelText() != current_action:
|
||||
|
||||
self._current_action.SetLabel( current_action )
|
||||
self._current_action.SetLabelText( current_action )
|
||||
|
||||
|
||||
|
||||
|
@ -1972,7 +2018,7 @@ class ManagementPanelPageOfImagesImport( ManagementPanel ):
|
|||
|
||||
self._pending_page_urls_panel = ClientGUICommon.StaticBox( self._page_of_images_panel, 'pending page urls' )
|
||||
|
||||
self._pending_page_urls_listbox = wx.ListBox( self._pending_page_urls_panel, size = ( -1, 200 ) )
|
||||
self._pending_page_urls_listbox = wx.ListBox( self._pending_page_urls_panel, size = ( -1, 100 ) )
|
||||
|
||||
self._advance_button = wx.Button( self._pending_page_urls_panel, label = u'\u2191' )
|
||||
self._advance_button.Bind( wx.EVT_BUTTON, self.EventAdvance )
|
||||
|
@ -1986,6 +2032,9 @@ class ManagementPanelPageOfImagesImport( ManagementPanel ):
|
|||
self._page_url_input = wx.TextCtrl( self._pending_page_urls_panel, style = wx.TE_PROCESS_ENTER )
|
||||
self._page_url_input.Bind( wx.EVT_KEY_DOWN, self.EventKeyDown )
|
||||
|
||||
self._page_url_paste = wx.Button( self._pending_page_urls_panel, label = 'paste urls' )
|
||||
self._page_url_paste.Bind( wx.EVT_BUTTON, self.EventPaste )
|
||||
|
||||
self._download_image_links = wx.CheckBox( self._page_of_images_panel, label = 'download image links' )
|
||||
self._download_image_links.Bind( wx.EVT_CHECKBOX, self.EventDownloadImageLinks )
|
||||
self._download_image_links.SetToolTipString( 'i.e. download the href url of an <a> tag if there is an <img> tag nested beneath it' )
|
||||
|
@ -2009,8 +2058,13 @@ class ManagementPanelPageOfImagesImport( ManagementPanel ):
|
|||
queue_hbox.AddF( self._pending_page_urls_listbox, CC.FLAGS_EXPAND_BOTH_WAYS )
|
||||
queue_hbox.AddF( queue_buttons_vbox, CC.FLAGS_MIXED )
|
||||
|
||||
input_hbox = wx.BoxSizer( wx.HORIZONTAL )
|
||||
|
||||
input_hbox.AddF( self._page_url_input, CC.FLAGS_EXPAND_BOTH_WAYS )
|
||||
input_hbox.AddF( self._page_url_paste, CC.FLAGS_MIXED )
|
||||
|
||||
self._pending_page_urls_panel.AddF( queue_hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
|
||||
self._pending_page_urls_panel.AddF( self._page_url_input, CC.FLAGS_EXPAND_PERPENDICULAR )
|
||||
self._pending_page_urls_panel.AddF( input_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
|
||||
|
||||
#
|
||||
|
||||
|
@ -2085,9 +2139,9 @@ class ManagementPanelPageOfImagesImport( ManagementPanel ):
|
|||
|
||||
|
||||
|
||||
if self._overall_status.GetLabel() != overall_status:
|
||||
if self._overall_status.GetLabelText() != overall_status:
|
||||
|
||||
self._overall_status.SetLabel( overall_status )
|
||||
self._overall_status.SetLabelText( overall_status )
|
||||
|
||||
|
||||
self._overall_gauge.SetRange( overall_range )
|
||||
|
@ -2124,14 +2178,14 @@ class ManagementPanelPageOfImagesImport( ManagementPanel ):
|
|||
|
||||
|
||||
|
||||
if self._parser_status.GetLabel() != parser_status:
|
||||
if self._parser_status.GetLabelText() != parser_status:
|
||||
|
||||
self._parser_status.SetLabel( parser_status )
|
||||
self._parser_status.SetLabelText( parser_status )
|
||||
|
||||
|
||||
if self._current_action.GetLabel() != current_action:
|
||||
if self._current_action.GetLabelText() != current_action:
|
||||
|
||||
self._current_action.SetLabel( current_action )
|
||||
self._current_action.SetLabelText( current_action )
|
||||
|
||||
|
||||
|
||||
|
@ -2202,7 +2256,10 @@ class ManagementPanelPageOfImagesImport( ManagementPanel ):
|
|||
self._Update()
|
||||
|
||||
|
||||
else: event.Skip()
|
||||
else:
|
||||
|
||||
event.Skip()
|
||||
|
||||
|
||||
|
||||
def EventMenu( self, event ):
|
||||
|
@ -2223,6 +2280,41 @@ class ManagementPanelPageOfImagesImport( ManagementPanel ):
|
|||
|
||||
|
||||
|
||||
def EventPaste( self, event ):
|
||||
|
||||
if wx.TheClipboard.Open():
|
||||
|
||||
data = wx.TextDataObject()
|
||||
|
||||
wx.TheClipboard.GetData( data )
|
||||
|
||||
wx.TheClipboard.Close()
|
||||
|
||||
raw_text = data.GetText()
|
||||
|
||||
try:
|
||||
|
||||
for page_url in HydrusData.SplitByLinesep( raw_text ):
|
||||
|
||||
if page_url != '':
|
||||
|
||||
self._page_of_images_import.PendPageURL( page_url )
|
||||
|
||||
|
||||
|
||||
self._Update()
|
||||
|
||||
except:
|
||||
|
||||
wx.MessageBox( 'I could not understand what was in the clipboard' )
|
||||
|
||||
|
||||
else:
|
||||
|
||||
wx.MessageBox( 'I could not get permission to access the clipboard.' )
|
||||
|
||||
|
||||
|
||||
def EventPause( self, event ):
|
||||
|
||||
self._page_of_images_import.PausePlay()
|
||||
|
@ -2339,7 +2431,7 @@ class ManagementPanelPetitions( ManagementPanel ):
|
|||
|
||||
if self._current_petition is None:
|
||||
|
||||
self._action_text.SetLabel( '' )
|
||||
self._action_text.SetLabelText( '' )
|
||||
self._reason_text.SetValue( '' )
|
||||
self._contents.Clear()
|
||||
self._process.Disable()
|
||||
|
@ -2353,7 +2445,7 @@ class ManagementPanelPetitions( ManagementPanel ):
|
|||
|
||||
( action_text, action_colour ) = self._current_petition.GetActionTextAndColour()
|
||||
|
||||
self._action_text.SetLabel( action_text )
|
||||
self._action_text.SetLabelText( action_text )
|
||||
self._action_text.SetForegroundColour( action_colour )
|
||||
|
||||
reason = self._current_petition.GetReason()
|
||||
|
@ -2399,7 +2491,7 @@ class ManagementPanelPetitions( ManagementPanel ):
|
|||
|
||||
def _DrawNumPetitions( self ):
|
||||
|
||||
self._num_petitions_text.SetLabel( HydrusData.ConvertIntToPrettyString( self._num_petitions ) + ' petitions' )
|
||||
self._num_petitions_text.SetLabelText( HydrusData.ConvertIntToPrettyString( self._num_petitions ) + ' petitions' )
|
||||
|
||||
if self._num_petitions > 0: self._get_petition.Enable()
|
||||
else: self._get_petition.Disable()
|
||||
|
@ -2516,7 +2608,7 @@ class ManagementPanelPetitions( ManagementPanel ):
|
|||
|
||||
|
||||
|
||||
self._num_petitions_text.SetLabel( u'Fetching\u2026' )
|
||||
self._num_petitions_text.SetLabelText( u'Fetching\u2026' )
|
||||
|
||||
self._controller.CallToThread( do_it )
|
||||
|
||||
|
@ -2871,9 +2963,9 @@ class ManagementPanelThreadWatcherImport( ManagementPanel ):
|
|||
|
||||
( watcher_status, ( overall_status, ( overall_value, overall_range ) ), check_now, paused ) = self._thread_watcher_import.GetStatus()
|
||||
|
||||
if self._overall_status.GetLabel() != overall_status:
|
||||
if self._overall_status.GetLabelText() != overall_status:
|
||||
|
||||
self._overall_status.SetLabel( overall_status )
|
||||
self._overall_status.SetLabelText( overall_status )
|
||||
|
||||
|
||||
self._overall_gauge.SetRange( overall_range )
|
||||
|
@ -2924,14 +3016,14 @@ class ManagementPanelThreadWatcherImport( ManagementPanel ):
|
|||
self._thread_check_now_button.Enable()
|
||||
|
||||
|
||||
if self._watcher_status.GetLabel() != watcher_status:
|
||||
if self._watcher_status.GetLabelText() != watcher_status:
|
||||
|
||||
self._watcher_status.SetLabel( watcher_status )
|
||||
self._watcher_status.SetLabelText( watcher_status )
|
||||
|
||||
|
||||
if self._current_action.GetLabel() != current_action:
|
||||
if self._current_action.GetLabelText() != current_action:
|
||||
|
||||
self._current_action.SetLabel( current_action )
|
||||
self._current_action.SetLabelText( current_action )
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1095,12 +1095,12 @@ class DraftPanel( wx.Panel ):
|
|||
if is_new:
|
||||
|
||||
self._draft_changed = True
|
||||
self._delete_draft.SetLabel( 'discard' )
|
||||
self._delete_draft.SetLabelText( 'discard' )
|
||||
|
||||
else:
|
||||
|
||||
self._draft_changed = False
|
||||
self._save_draft.SetLabel( 'saved' )
|
||||
self._save_draft.SetLabelText( 'saved' )
|
||||
self._save_draft.Disable()
|
||||
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ class DraftPanel( wx.Panel ):
|
|||
|
||||
raw_attachments = self._attachments.GetValue()
|
||||
|
||||
attachment_hashes = [ hash.decode( 'hex' ) for hash in raw_attachments.split( os.linesep ) if hash != '' ]
|
||||
attachment_hashes = [ hash.decode( 'hex' ) for hash in HydrusData.SplitByLinesep( raw_attachments ) if hash != '' ]
|
||||
|
||||
except:
|
||||
|
||||
|
@ -1192,10 +1192,10 @@ class DraftPanel( wx.Panel ):
|
|||
|
||||
self._draft_changed = False
|
||||
|
||||
self._save_draft.SetLabel( 'saved' )
|
||||
self._save_draft.SetLabelText( 'saved' )
|
||||
self._save_draft.Disable()
|
||||
|
||||
self._delete_draft.SetLabel( 'delete' )
|
||||
self._delete_draft.SetLabelText( 'delete' )
|
||||
|
||||
self._draft_message.Saved()
|
||||
|
||||
|
|
|
@ -419,7 +419,7 @@ class OptionsPanelTags( OptionsPanel ):
|
|||
|
||||
button_label = HydrusData.ConvertIntToPrettyString( len( explicit_tags ) ) + ' explicit tags'
|
||||
|
||||
explicit_button.SetLabel( button_label )
|
||||
explicit_button.SetLabelText( button_label )
|
||||
|
||||
self._service_keys_to_explicit_button_info[ service_key ] = ( explicit_tags, explicit_button )
|
||||
|
||||
|
@ -561,7 +561,7 @@ class OptionsPanelTags( OptionsPanel ):
|
|||
|
||||
button_label = HydrusData.ConvertIntToPrettyString( len( explicit_tags ) ) + ' explicit tags'
|
||||
|
||||
explicit_button.SetLabel( button_label )
|
||||
explicit_button.SetLabelText( button_label )
|
||||
|
||||
new_service_keys_to_explicit_button_info[ service_key ] = ( explicit_tags, explicit_button )
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import HydrusFileHandling
|
|||
import HydrusGlobals
|
||||
import HydrusPaths
|
||||
import HydrusSerialisable
|
||||
import HydrusTags
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
|
@ -1114,9 +1115,11 @@ class ImportFolder( HydrusSerialisable.SerialisableBaseNamed ):
|
|||
txt_tags_string = f.read()
|
||||
|
||||
|
||||
txt_tags = [ HydrusData.ToUnicode( tag ) for tag in txt_tags_string.split( os.linesep ) ]
|
||||
txt_tags = [ HydrusData.ToUnicode( tag ) for tag in HydrusData.SplitByLinesep( txt_tags_string ) ]
|
||||
|
||||
service_keys_to_tags = { service_key : tags for service_key in self._txt_parse_tag_service_keys }
|
||||
txt_tags = HydrusTags.CleanTags( txt_tags )
|
||||
|
||||
service_keys_to_tags = { service_key : txt_tags for service_key in self._txt_parse_tag_service_keys }
|
||||
|
||||
service_keys_to_content_updates = ClientData.ConvertServiceKeysToTagsToServiceKeysToContentUpdates( { hash }, service_keys_to_tags )
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import HydrusTags
|
|||
import re
|
||||
import wx
|
||||
|
||||
def FilterPredicatesBySearchEntry( search_entry, predicates ):
|
||||
def FilterPredicatesBySearchEntry( search_entry, predicates, service_key = None, expand_parents = False ):
|
||||
|
||||
tags_to_predicates = {}
|
||||
|
||||
|
@ -24,7 +24,16 @@ def FilterPredicatesBySearchEntry( search_entry, predicates ):
|
|||
|
||||
matching_tags = FilterTagsBySearchEntry( search_entry, tags_to_predicates.keys() )
|
||||
|
||||
return [ tags_to_predicates[ tag ] for tag in matching_tags ]
|
||||
matches = [ tags_to_predicates[ tag ] for tag in matching_tags ]
|
||||
|
||||
if service_key is not None and expand_parents:
|
||||
|
||||
parents_manager = HydrusGlobals.client_controller.GetManager( 'tag_parents' )
|
||||
|
||||
matches = parents_manager.ExpandPredicates( service_key, matches )
|
||||
|
||||
|
||||
return matches
|
||||
|
||||
def FilterTagsBySearchEntry( search_entry, tags, search_siblings = True ):
|
||||
|
||||
|
@ -91,7 +100,7 @@ def FilterTagsBySearchEntry( search_entry, tags, search_siblings = True ):
|
|||
continue
|
||||
|
||||
|
||||
comparee = tag
|
||||
comparee = possible_tag
|
||||
|
||||
|
||||
if re.search( re_predicate, comparee ) is not None:
|
||||
|
@ -105,19 +114,6 @@ def FilterTagsBySearchEntry( search_entry, tags, search_siblings = True ):
|
|||
|
||||
return result
|
||||
|
||||
def FilterPredicates( search_entry, predicates, service_key = None, expand_parents = False ):
|
||||
|
||||
matches = FilterPredicatesBySearchEntry( search_entry, predicates )
|
||||
|
||||
if service_key is not None and expand_parents:
|
||||
|
||||
parents_manager = HydrusGlobals.client_controller.GetManager( 'tag_parents' )
|
||||
|
||||
matches = parents_manager.ExpandPredicates( service_key, matches )
|
||||
|
||||
|
||||
return matches
|
||||
|
||||
def SortPredicates( predicates ):
|
||||
|
||||
def cmp_func( x, y ): return cmp( x.GetCount(), y.GetCount() )
|
||||
|
|
|
@ -54,7 +54,7 @@ options = {}
|
|||
# Misc
|
||||
|
||||
NETWORK_VERSION = 17
|
||||
SOFTWARE_VERSION = 197
|
||||
SOFTWARE_VERSION = 198
|
||||
|
||||
UNSCALED_THUMBNAIL_DIMENSIONS = ( 200, 200 )
|
||||
|
||||
|
|
|
@ -317,8 +317,6 @@ class HydrusDB( object ):
|
|||
|
||||
HydrusData.Print( traceback.format_exc() )
|
||||
|
||||
HydrusData.ShowExceptionDefault( e )
|
||||
|
||||
self._could_not_initialise = True
|
||||
|
||||
|
||||
|
|
|
@ -576,6 +576,10 @@ def ConvertUnitToInt( unit ):
|
|||
elif unit == 'MB': return 1048576
|
||||
elif unit == 'GB': return 1073741824
|
||||
|
||||
def ConvertValueRangeToBytes( value, range ):
|
||||
|
||||
return ConvertIntToBytes( value ) + '/' + ConvertIntToBytes( range )
|
||||
|
||||
def ConvertValueRangeToPrettyString( value, range ):
|
||||
|
||||
return ConvertIntToPrettyString( value ) + '/' + ConvertIntToPrettyString( range )
|
||||
|
@ -644,7 +648,7 @@ def GetSiblingProcessPorts( instance ):
|
|||
|
||||
try:
|
||||
|
||||
( pid, create_time ) = result.split( os.linesep )
|
||||
( pid, create_time ) = SplitByLinesep( result )
|
||||
|
||||
pid = int( pid )
|
||||
create_time = float( create_time )
|
||||
|
@ -735,7 +739,7 @@ def IsAlreadyRunning( instance ):
|
|||
|
||||
try:
|
||||
|
||||
( pid, create_time ) = result.split( os.linesep )
|
||||
( pid, create_time ) = SplitByLinesep( result )
|
||||
|
||||
pid = int( pid )
|
||||
create_time = float( create_time )
|
||||
|
@ -802,6 +806,34 @@ def Print( text ):
|
|||
|
||||
print( ToByteString( text ) )
|
||||
|
||||
ShowText = Print
|
||||
|
||||
def PrintException( e ):
|
||||
|
||||
if isinstance( e, HydrusExceptions.ShutdownException ):
|
||||
|
||||
return
|
||||
|
||||
|
||||
etype = type( e )
|
||||
|
||||
value = ToUnicode( e )
|
||||
|
||||
trace_list = traceback.format_stack()
|
||||
|
||||
trace = ''.join( trace_list )
|
||||
|
||||
message = ToUnicode( etype.__name__ ) + ': ' + ToUnicode( value ) + os.linesep + ToUnicode( trace )
|
||||
|
||||
Print( '' )
|
||||
Print( 'Exception:' )
|
||||
|
||||
DebugPrint( message )
|
||||
|
||||
time.sleep( 1 )
|
||||
|
||||
ShowException = PrintException
|
||||
|
||||
def Profile( code, g, l ):
|
||||
|
||||
profile = cProfile.Profile()
|
||||
|
@ -868,36 +900,20 @@ def RestartProcess():
|
|||
|
||||
os.execl( sys.executable, sys.executable, *sys.argv )
|
||||
|
||||
def ShowExceptionDefault( e ):
|
||||
|
||||
if isinstance( e, HydrusExceptions.ShutdownException ):
|
||||
|
||||
return
|
||||
|
||||
|
||||
etype = type( e )
|
||||
|
||||
value = ToUnicode( e )
|
||||
|
||||
trace_list = traceback.format_stack()
|
||||
|
||||
trace = ''.join( trace_list )
|
||||
|
||||
message = ToUnicode( etype.__name__ ) + ': ' + ToUnicode( value ) + os.linesep + ToUnicode( trace )
|
||||
|
||||
Print( '' )
|
||||
Print( 'Exception:' )
|
||||
|
||||
DebugPrint( message )
|
||||
|
||||
time.sleep( 1 )
|
||||
|
||||
ShowException = ShowExceptionDefault
|
||||
|
||||
ShowText = Print
|
||||
|
||||
def SplayListForDB( xs ): return '(' + ','.join( ( str( x ) for x in xs ) ) + ')'
|
||||
|
||||
def SplitByLinesep( raw_text ):
|
||||
|
||||
if '\r\n' in raw_text:
|
||||
|
||||
return raw_text.split( '\r\n' )
|
||||
|
||||
else:
|
||||
|
||||
return raw_text.split( '\n' )
|
||||
|
||||
|
||||
|
||||
def SplitIteratorIntoChunks( iterator, n ):
|
||||
|
||||
chunk = []
|
||||
|
@ -1938,7 +1954,7 @@ class ServerToClientContentUpdatePackage( HydrusSerialisable.SerialisableBase ):
|
|||
return num
|
||||
|
||||
|
||||
def IterateContentUpdateChunks( self, chunk_weight = 5000 ):
|
||||
def IterateContentUpdateChunks( self, chunk_weight = 1250 ):
|
||||
|
||||
data_types = [ HC.CONTENT_TYPE_FILES, HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_TYPE_TAG_SIBLINGS, HC.CONTENT_TYPE_TAG_PARENTS ]
|
||||
actions = [ HC.CONTENT_UPDATE_ADD, HC.CONTENT_UPDATE_DELETE ]
|
||||
|
|
|
@ -42,7 +42,7 @@ def GetExternalIP():
|
|||
|
||||
try:
|
||||
|
||||
lines = output.split( os.linesep )
|
||||
lines = HydrusData.SplitByLinesep( output )
|
||||
|
||||
i = lines.index( ' i protocol exPort->inAddr:inPort description remoteHost leaseTime' )
|
||||
|
||||
|
@ -106,7 +106,7 @@ def GetUPnPMappings():
|
|||
|
||||
try:
|
||||
|
||||
lines = output.split( os.linesep )
|
||||
lines = HydrusData.SplitByLinesep( output )
|
||||
|
||||
i = lines.index( ' i protocol exPort->inAddr:inPort description remoteHost leaseTime' )
|
||||
|
||||
|
|
Loading…
Reference in New Issue