示例#1
0
 def THREADExitEverything( self ):
     
     try:
         
         self.pub( 'splash_set_title_text', u'shutting down gui\u2026' )
         
         self.ShutdownView()
         
         self.pub( 'splash_set_title_text', u'shutting down db\u2026' )
         
         self.ShutdownModel()
         
         self.pub( 'splash_set_title_text', u'cleaning up\u2026' )
         self.pub( 'splash_set_status_text', u'' )
         
         HydrusData.CleanRunningFile( self.db_dir, 'client' )
         
     except HydrusExceptions.PermissionException:
         
         pass
         
     except HydrusExceptions.ShutdownException:
         
         pass
         
     except:
         
         ClientData.ReportShutdownException()
         
     finally:
         
         self._DestroySplash()
示例#2
0
    def THREADExitEverything(self):

        try:

            self.pub('splash_set_title_text', 'shutting down gui...')

            self.ShutdownView()

            self.pub('splash_set_title_text', 'shutting down db...')

            self.ShutdownModel()

            HydrusData.CleanRunningFile(HC.DB_DIR, 'client')

        except HydrusExceptions.PermissionException:
            pass
        except HydrusExceptions.ShutdownException:
            pass
        except:

            text = 'A serious error occured while trying to exit the program. Its traceback may be shown next. It should have also been written to client.log. You may need to quit the program from task manager.'

            HydrusData.DebugPrint(text)

            traceback.print_exc()

            wx.CallAfter(wx.MessageBox, traceback.format_exc())
            wx.CallAfter(wx.MessageBox, text)

        finally:

            self.pub('splash_destroy')
示例#3
0
    def Exit(self):

        HydrusData.Print(u'Shutting down daemons and services\u2026')

        self.ShutdownView()

        HydrusData.Print(u'Shutting down db\u2026')

        self.ShutdownModel()

        HydrusData.CleanRunningFile(self.db_dir, 'server')
示例#4
0
    def Exit(self):

        HydrusData.Print('Shutting down daemons and services...')

        self.ShutdownView()

        HydrusData.Print('Shutting down db...')

        self.ShutdownModel()

        HydrusData.CleanRunningFile(HC.DB_DIR, 'server')
示例#5
0
 def Exit( self ):
     
     if HG.emergency_exit:
         
         self.ShutdownView()
         self.ShutdownModel()
         
         HydrusData.CleanRunningFile( self.db_dir, 'client' )
         
     else:
         
         try:
             
             idle_shutdown_action = self.options[ 'idle_shutdown' ]
             
             if idle_shutdown_action in ( CC.IDLE_ON_SHUTDOWN, CC.IDLE_ON_SHUTDOWN_ASK_FIRST ):
                 
                 idle_shutdown_max_minutes = self.options[ 'idle_shutdown_max_minutes' ]
                 
                 time_to_stop = HydrusData.GetNow() + ( idle_shutdown_max_minutes * 60 )
                 
                 if self.ThereIsIdleShutdownWorkDue( time_to_stop ):
                     
                     if idle_shutdown_action == CC.IDLE_ON_SHUTDOWN_ASK_FIRST:
                         
                         text = 'Is now a good time for the client to do up to ' + HydrusData.ConvertIntToPrettyString( idle_shutdown_max_minutes ) + ' minutes\' maintenance work? (Will auto-no in 15 seconds)'
                         
                         with ClientGUIDialogs.DialogYesNo( self._splash, text, title = 'Maintenance is due' ) as dlg_yn:
                             
                             job = self.CallLaterWXSafe( dlg_yn, 15, dlg_yn.EndModal, wx.ID_NO )
                             
                             try:
                                 
                                 if dlg_yn.ShowModal() == wx.ID_YES:
                                     
                                     HG.do_idle_shutdown_work = True
                                     
                                 
                             finally:
                                 
                                 job.Cancel()
                                 
                             
                         
                     else:
                         
                         HG.do_idle_shutdown_work = True
                         
                     
                 
             
             self.CallToThreadLongRunning( self.THREADExitEverything )
             
         except:
             
             self._DestroySplash()
             
             HydrusData.DebugPrint( traceback.format_exc() )
             
             HG.emergency_exit = True
             
             self.Exit()
示例#6
0
    def Exit(self):

        if HG.emergency_exit:

            self.ShutdownView()
            self.ShutdownModel()

            HydrusData.CleanRunningFile(self.db_dir, 'client')

        else:

            try:

                last_shutdown_work_time = self.Read('last_shutdown_work_time')

                shutdown_work_period = self.new_options.GetInteger(
                    'shutdown_work_period')

                we_can_shutdown_work = HydrusData.TimeHasPassed(
                    last_shutdown_work_time + shutdown_work_period)

                idle_shutdown_action = self.options['idle_shutdown']

                if we_can_shutdown_work and idle_shutdown_action in (
                        CC.IDLE_ON_SHUTDOWN, CC.IDLE_ON_SHUTDOWN_ASK_FIRST):

                    idle_shutdown_max_minutes = self.options[
                        'idle_shutdown_max_minutes']

                    time_to_stop = HydrusData.GetNow() + (
                        idle_shutdown_max_minutes * 60)

                    work_to_do = self.GetIdleShutdownWorkDue(time_to_stop)

                    if len(work_to_do) > 0:

                        if idle_shutdown_action == CC.IDLE_ON_SHUTDOWN_ASK_FIRST:

                            text = 'Is now a good time for the client to do up to ' + HydrusData.ToHumanInt(
                                idle_shutdown_max_minutes
                            ) + ' minutes\' maintenance work? (Will auto-no in 15 seconds)'
                            text += os.linesep * 2
                            text += 'The outstanding jobs appear to be:'
                            text += os.linesep * 2
                            text += os.linesep.join(work_to_do)

                            with ClientGUIDialogs.DialogYesNo(
                                    self._splash, text,
                                    title='Maintenance is due') as dlg_yn:

                                job = self.CallLaterWXSafe(
                                    dlg_yn, 15, dlg_yn.EndModal, wx.ID_NO)

                                try:

                                    if dlg_yn.ShowModal() == wx.ID_YES:

                                        HG.do_idle_shutdown_work = True

                                    else:

                                        self.Write('last_shutdown_work_time',
                                                   HydrusData.GetNow())

                                finally:

                                    job.Cancel()

                        else:

                            HG.do_idle_shutdown_work = True

                self.CallToThreadLongRunning(self.THREADExitEverything)

            except:

                self._DestroySplash()

                HydrusData.DebugPrint(traceback.format_exc())

                HG.emergency_exit = True

                self.Exit()