Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _BroadcastCollect( self ):
if not self._silent and self._management_controller is not None:
self._management_controller.SetVariable( 'media_collect', self._media_collect )
page_key = self._management_controller.GetKey( 'page' )
HG.client_controller.pub( 'collect_media', page_key, self._media_collect )
HG.client_controller.pub( 'a_collect_happened', page_key )
def AppendGUISession( self, name, load_in_a_page_of_pages = True ):
job_key = ClientThreading.JobKey()
job_key.SetVariable( 'popup_text_1', 'loading session "{}"\u2026'.format( name ) )
HG.client_controller.pub( 'message', job_key )
# get that message showing before we do the work of loading session
HG.client_controller.app.processEvents()
try:
session = self._controller.Read( 'serialisable_named', HydrusSerialisable.SERIALISABLE_TYPE_GUI_SESSION, name )
except Exception as e:
HydrusData.ShowText( 'While trying to load session ' + name + ', this error happened:' )
HydrusData.ShowException( e )
self.NewPageQuery( CC.LOCAL_FILE_SERVICE_KEY )
return
def NotifyGallerySeedsUpdated( self, gallery_seeds ):
with self._lock:
self._SetStatusDirty()
HG.client_controller.pub( 'gallery_seed_log_gallery_seeds_updated', self._gallery_seed_log_key, gallery_seeds )
def _CopyAccountKey( self ):
account = self._service.GetAccount()
account_key = account.GetAccountKey()
account_key_hex = account_key.hex()
HG.client_controller.pub( 'clipboard', 'text', account_key_hex )
def _ExportToClipboard( self ):
export_object = self._GetExportObject()
if export_object is not None:
json = export_object.DumpToString()
HG.client_controller.pub( 'clipboard', 'text', json )
def _ExportToClipboard( self ):
payload = self._GetExportableURLsString()
HG.client_controller.pub( 'clipboard', 'text', payload )
else:
try: job_key.SetVariable( 'popup_title', str( etype.__name__ ) )
except: job_key.SetVariable( 'popup_title', str( etype ) )
job_key.SetVariable( 'popup_text_1', first_line )
job_key.SetVariable( 'popup_traceback', trace )
text = job_key.ToString()
HydrusData.Print( 'Uncaught exception:' )
HydrusData.DebugPrint( text )
HG.client_controller.pub( 'message', job_key )
except:
text = 'Encountered an error I could not parse:'
text += os.linesep
text += str( ( etype, value, tb ) )
try: text += traceback.format_exc()
except: pass
HydrusData.ShowText( text )
time.sleep( 1 )
predicates = ClientGUISearch.FleshOutPredicates( self, predicates )
if len( predicates ) > 0:
s = sorted( ( predicate.ToString() for predicate in predicates ) )
page_name = ', '.join( s )
activate_window = HG.client_controller.new_options.GetBoolean( 'activate_window_on_tag_search_page_activation' )
file_service_key = self._GetCurrentFileServiceKey()
HG.client_controller.pub( 'new_page_query', file_service_key, initial_predicates = predicates, page_name = page_name, activate_window = activate_window )
if show == 'all':
hashes = file_seed_cache.GetHashes()
elif show == 'new':
file_import_options = ClientImportOptions.FileImportOptions()
file_import_options.SetPresentationOptions( True, False, False )
hashes = file_seed_cache.GetPresentedHashes( file_import_options )
if len( hashes ) > 0:
HG.client_controller.pub( 'new_page_query', CC.LOCAL_FILE_SERVICE_KEY, initial_hashes = hashes )
message = 'This will instruct your database to forget its entire record of locally deleted files, meaning that if it ever encounters any of those files again, it will assume they are new and reimport them. This operation cannot be undone.'
result = ClientGUIDialogsQuick.GetYesNo( self, message, yes_label = 'do it', no_label = 'forget it' )
if result == QW.QDialog.Accepted:
hashes = None
content_update = HydrusData.ContentUpdate( HC.CONTENT_TYPE_FILES, HC.CONTENT_UPDATE_ADVANCED, ( 'delete_deleted', hashes ) )
service_keys_to_content_updates = { CC.COMBINED_LOCAL_FILE_SERVICE_KEY : [ content_update ] }
HG.client_controller.Write( 'content_updates', service_keys_to_content_updates )
HG.client_controller.pub( 'service_updated', self._service )