def __init__(self, editor, manager, uri, encoding, stdin, parameters): editor.set_data("InstanceManager", manager) editor.set_data("parameters", parameters) from UniqueStampGenerator import Generator Generator(editor) from RegistrationManager import Manager Manager(editor) from FilenameGeneratorModeManager import Manager Manager(editor, uri) from ContentDetector import Detector Detector(editor, uri) from FileModificationMonitor import Monitor Monitor(editor) from URIManager import Manager Manager(editor, uri) from LanguageManager import Manager Manager(editor, uri) from SchemeManager import Manager Manager(editor) from GladeObjectManager import Manager Manager(editor) from CompletionWindowVisibilityManager import Manager Manager(editor) from BusyManager import Manager Manager(editor) from RecentManager import Manager Manager(editor) from GUI.Manager import Manager Manager(editor, uri) from ScrollbarVisibilityUpdater import Updater Updater(editor) ######################################################################## from FreezeManager import Manager Manager(editor) from EncodingSystem.Manager import Manager Manager(editor) from FileChangeMonitor import Monitor Monitor(editor) from SaveSystem.Manager import Manager Manager(editor) from TriggerSystem.Manager import Manager Manager(editor) from ReadonlyManager import Manager Manager(editor) # Register with instance manager after a successful editor # initialization. manager.register_editor(editor) from BarObjectManager import Manager Manager(editor) from FullScreenManager import Manager Manager(editor) # This should be the last lines in this method. from PluginSystemInitializer import Initializer Initializer(editor, uri) if stdin: editor.reset_text(stdin) from URILoader.Manager import Manager Manager(editor, uri, encoding) from gtk.gdk import notify_startup_complete notify_startup_complete()
def _startup_complete(self, *args): GTKXpraClient._startup_complete(self, *args) gdk.notify_startup_complete()
def __init__(self, args): component.Component.__init__(self, 'IPCInterface') self.listener = None ipc_dir = get_config_dir('ipc') if not os.path.exists(ipc_dir): os.makedirs(ipc_dir) socket = os.path.join(ipc_dir, 'deluge-gtk') if windows_check(): # If we're on windows we need to check the global mutex to see if deluge is # already running. import win32event import win32api import winerror self.mutex = win32event.CreateMutex(None, False, 'deluge') if win32api.GetLastError() != winerror.ERROR_ALREADY_EXISTS: # Create listen socket self.factory = Factory() self.factory.protocol = IPCProtocolServer import random port = random.randrange(20000, 65535) self.listener = reactor.listenTCP(port, self.factory) # Store the port number in the socket file with open(socket, 'w') as _file: _file.write(str(port)) # We need to process any args when starting this process process_args(args) else: # Send to existing deluge process with open(socket) as _file: port = int(_file.readline()) self.factory = ClientFactory() self.factory.args = args self.factory.protocol = IPCProtocolClient reactor.connectTCP('127.0.0.1', port, self.factory) reactor.run() sys.exit(0) else: # Find and remove any restart tempfiles restart_tempfile = glob(os.path.join(ipc_dir, 'restart.*')) for f in restart_tempfile: os.remove(f) lockfile = socket + '.lock' log.debug('Checking if lockfile exists: %s', lockfile) if os.path.lexists(lockfile): def delete_lockfile(): log.debug('Delete stale lockfile.') try: os.remove(lockfile) os.remove(socket) except OSError as ex: log.error('Failed to delete lockfile: %s', ex) try: os.kill(int(os.readlink(lockfile)), 0) except OSError: delete_lockfile() else: if restart_tempfile: log.warning( 'Found running PID but it is not a Deluge process, removing lockfile...' ) delete_lockfile() try: self.factory = Factory() self.factory.protocol = IPCProtocolServer self.listener = reactor.listenUNIX(socket, self.factory, wantPID=True) except twisted.internet.error.CannotListenError as ex: log.info( 'Deluge is already running! Sending arguments to running instance...' ) self.factory = IPCClientFactory() self.factory.args = args reactor.connectUNIX(socket, self.factory, checkPID=True) reactor.run() if self.factory.stop: log.info('Success sending arguments to running Deluge.') from gtk.gdk import notify_startup_complete notify_startup_complete() sys.exit(0) else: if restart_tempfile: log.error('Deluge restart failed: %s', ex) sys.exit(1) else: log.warning('Restarting Deluge... (%s)', ex) # Create a tempfile to keep track of restart mkstemp(prefix='restart.', dir=ipc_dir) os.execv(sys.argv[0], sys.argv) else: process_args(args)