Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
HydrusData.Print( 'Initialising daemons\u2026' )
self.InitView()
HydrusData.Print( 'Server is running. Press Ctrl+C to quit.' )
try:
while not HG.model_shutdown and not self._shutdown:
time.sleep( 1 )
except KeyboardInterrupt:
HydrusData.Print( 'Received a keyboard interrupt\u2026' )
HydrusData.Print( 'Shutting down controller\u2026' )
self.Exit()
if load_f is not None and callable( load_f ):
try:
load_f( self._player.handle, mpv_config_path.encode( 'utf-8' ) ) # pylint: disable=E1102
except Exception as e:
HydrusData.ShowText( 'MPV could not load its configuration file! This was probably due to an invalid parameter value inside the conf. The error follows:' )
HydrusData.ShowException( e )
else:
HydrusData.Print( 'Was unable to load mpv.conf--has the MPV API changed?' )
def StartServices( *args, **kwargs ):
HydrusData.Print( 'starting services\u2026' )
for service in services:
service_key = service.GetServiceKey()
service_type = service.GetServiceType()
name = service.GetName()
port = service.GetPort()
allow_non_local_connections = service.AllowsNonLocalConnections()
use_https = service.UseHTTPS()
if port is None:
continue
raise Exception( 'Tried to bind port {} for "{}" but it failed.'.format( port, service.GetName() ) )
except Exception as e:
HydrusData.Print( traceback.format_exc() )
HydrusData.Print( 'Services started' )
if len( self._service_keys_to_connected_ports ) > 0:
HydrusData.Print( 'Stopping services\u2026' )
deferreds = []
for ( ipv4_port, ipv6_port ) in self._service_keys_to_connected_ports.values():
if ipv4_port is not None:
deferred = defer.maybeDeferred( ipv4_port.stopListening )
deferreds.append( deferred )
if ipv6_port is not None:
deferred = defer.maybeDeferred( ipv6_port.stopListening )
message = 'Hydrus found multiple missing locations in your file storage. Some of these locations seemed to be fixable, others did not. The client will now inform you about both problems.'
self._controller.SafeShowCriticalMessage( 'Multiple file location problems.', message )
if len( correct_rows ) > 0:
summaries = sorted( ( '{} moved from {} to {}'.format( HydrusData.ToHumanInt( count ), missing_location, correct_location ) for ( ( missing_location, correct_location ), count ) in fixes_counter.items() ) )
summary_message = 'Some client file folders were missing, but they seem to be in other known locations! The folders are:'
summary_message += os.linesep * 2
summary_message += os.linesep.join( summaries )
summary_message += os.linesep * 2
summary_message += 'Assuming you did this on purpose, Hydrus is ready to update its internal knowledge to reflect these new mappings as soon as this dialog closes. If you know these proposed fixes are incorrect, terminate the program now.'
HydrusData.Print( summary_message )
self._controller.SafeShowCriticalMessage( 'About to auto-heal client file folders.', summary_message )
HG.client_controller.WriteSynchronous( 'repair_client_files', correct_rows )
if len( presentation_hashes ) > 0:
job_key.SetVariable( 'popup_files', ( presentation_hashes, 'downloads' ) )
elif status == CC.STATUS_DELETED:
num_deleted += 1
except Exception as e:
num_failed += 1
HydrusData.Print( url + ' failed to import!' )
HydrusData.PrintException( e )
finally:
job_key.DeleteVariable( 'popup_text_2' )
job_key.DeleteVariable( 'popup_network_job' )
text_components = []
if num_successful > 0:
text_components.append( HydrusData.ToHumanInt( num_successful ) + ' successful' )
try:
job_key = ClientThreading.JobKey( cancellable = True, maintenance_mode = maintenance_mode, stop_time = stop_time )
title = '{} sync: processing updates'.format( self._name )
job_key.SetVariable( 'popup_title', title )
( this_is_first_definitions_work, definition_hashes, this_is_first_content_work, content_hashes ) = HG.client_controller.Read( 'repository_update_hashes_to_process', self._service_key )
if len( definition_hashes ) == 0 and len( content_hashes ) == 0:
return # no work to do
HydrusData.Print( title )
num_updates_done = 0
num_updates_to_do = len( definition_hashes ) + len( content_hashes )
HG.client_controller.pub( 'message', job_key )
HG.client_controller.pub( 'splash_set_title_text', title, print_to_log = False )
total_definition_rows_completed = 0
total_content_rows_completed = 0
did_definition_analyze = False
did_content_analyze = False
definition_start_time = HydrusData.GetNowPrecise()
try:
def CreateSplash( self, title ):
if self._splash is not None:
self._DestroySplash()
try:
self._splash = ClientGUISplash.FrameSplash( self, title )
except:
HydrusData.Print( 'There was an error trying to start the splash screen!' )
HydrusData.Print( traceback.format_exc() )
raise
def ShowTextClient( text ):
job_key = ClientThreading.JobKey()
job_key.SetVariable( 'popup_text_1', str( text ) )
text = job_key.ToString()
HydrusData.Print( text )
HG.client_controller.pub( 'message', job_key )