def toDaemon(self, *args):
     server = GUIServerThread.instance()
     if server:
         server.toDaemon(*args)
     else:
         sys.stderr.write('Error No GUI OSC Server, can not send %s.\n' %
                          args)
Exemple #2
0
    def open(self, project_path, session_name, jack_client_name):
        self.wait_for_open = True
        self.project_path = project_path

        server = GUIServerThread.instance()
        if server:
            server.openSession(project_path, 0)
Exemple #3
0
    def open(self, project_path, session_name, jack_client_name):
        self.wait_for_open = True

        #Here project_path is used for template if needed
        template_name = jack_client_name

        server = GUIServerThread.instance()
        if server:
            server.openSession(project_path, 0, template_name)
Exemple #4
0
    def save(self):
        if self._session._main_win:
            self._session._main_win.saveWindowSettings()

        self.wait_for_save = True

        server = GUIServerThread.instance()
        if server:
            server.saveSession()
Exemple #5
0
    def setDisannounced(self):
        server = GUIServerThread.instance()
        server.disannounce()

        self.port = None
        self.url = ''
        del self.address
        self.address = None
        self.is_announced = False
Exemple #6
0
 def stop(self):
     if self.launched_before:
         self.disannounce()
         QTimer.singleShot(10, QApplication.quit)
         return
     
     server = GUIServerThread.instance()
     server.toDaemon('/ray/server/quit')
     QTimer.singleShot(10, QApplication.quit)
Exemple #7
0
    def sendPropertiesToDaemon(self):
        server = GUIServerThread.instance()
        if not server:
            sys.stderr.write(
                'Server not found. Client %s can not send its properties\n'
                    % self.client_id)
            return

        server.toDaemon('/ray/client/update_properties',
                        *ray.ClientData.spreadClient(self))
Exemple #8
0
    def receiveAnnounce(
            self,
            src_addr,
            version,
            server_status,
            options,
            session_root,
            is_net_free):
        self.announce_timer.stop()

        if version.split('.')[:1] != ray.VERSION.split('.')[:1]:
            # works only if the two firsts digits are the same (ex: 0.6)
            self._signaler.daemon_url_request.emit(
                ErrDaemon.WRONG_VERSION, self.url)
            self.disannounce(src_addr)
            return

        if (CommandLineArgs.net_session_root
                and session_root != CommandLineArgs.net_session_root):
            self._signaler.daemon_url_request.emit(
                ErrDaemon.WRONG_ROOT, self.url)
            self.disannounce(src_addr)
            return

        if not is_net_free:
            self._signaler.daemon_url_request.emit(
                ErrDaemon.FORBIDDEN_ROOT, self.url)
            self.disannounce(src_addr)
            return

        if (CommandLineArgs.out_daemon
                and server_status != ray.ServerStatus.OFF):
            self._signaler.daemon_url_request.emit(ErrDaemon.NOT_OFF, self.url)
            self.disannounce(src_addr)
            return

        self.is_announced = True
        self.address = src_addr
        self.port = src_addr.port
        self.url = src_addr.url
        self.session_root = session_root

        self.is_nsm_locked = options & ray.Option.NSM_LOCKED
        save_all_from_saved_client = options & ray.Option.SAVE_FROM_CLIENT
        bookmark_session_folder = options & ray.Option.BOOKMARK_SESSION

        if self.is_nsm_locked:
            #self._signaler.daemon_nsm_locked.emit(True)
            self._session._main_win.setNsmLocked(True)
        elif CommandLineArgs.under_nsm:
            server = GUIServerThread.instance()
            server.toDaemon('/ray/server/set_nsm_locked')

        self._signaler.daemon_announce_ok.emit()
        self._session.setDaemonOptions(options)
Exemple #9
0
    def __init__(self):
        self.client_list = []
        self.trashed_clients = []
        self.favorite_list = []
        self.name = ''
        self.path = ''
        self.notes = ''
        self.is_running = False
        self.server_status = ray.ServerStatus.OFF

        self.is_renameable = True

        self._signaler = Signaler()

        server = GUIServerThread.instance()
        server.start()

        self._daemon_manager = DaemonManager(self)
        if CommandLineArgs.daemon_url:
            self._daemon_manager.setOscAddress(CommandLineArgs.daemon_url)
        elif CommandLineArgs.daemon_port:
            self._daemon_manager.setOscAddress(CommandLineArgs.daemon_port)
        elif not CommandLineArgs.out_daemon:
            self._daemon_manager.setNewOscAddress()

        # build nsm_child if NSM_URL in env
        self._nsm_child = None

        if CommandLineArgs.under_nsm:
            if CommandLineArgs.out_daemon:
                self._nsm_child = NSMChildOutside(self)
                self._daemon_manager.setExternal()
            else:
                self._nsm_child = NSMChild(self)

        # build and show Main UI
        self._main_win = MainWindow(self)

        self._daemon_manager.finishInit()
        server.finishInit(self)

        self._main_win.show()

        # display donations dialog under conditions
        if not RS.settings.value('hide_donations', False, type=bool):
            coreff_counter = RS.settings.value('coreff_counter', 0, type=int)
            coreff_counter += 1
            RS.settings.setValue('coreff_counter', coreff_counter)

            if coreff_counter % 44 == 29:
                self._main_win.donate(True)

        # The only way I found to not show Messages Dock by default.
        if not RS.settings.value('MainWindow/ShowMessages', False, type=bool):
            self._main_win.hideMessagesDock()
Exemple #10
0
    def sendRayHack(self):
        if self.protocol != ray.Protocol.RAY_HACK:
            return

        server = GUIServerThread.instance()
        if not server:
            return

        server.toDaemon('/ray/client/update_ray_hack_properties',
                        self.client_id,
                        *self.ray_hack.spread())
Exemple #11
0
    def removeFavorite(self, name, factory, from_server=False):
        for favorite in self.favorite_list:
            if favorite.name == name and favorite.factory == factory:
                self.favorite_list.remove(favorite)
                break

        self._main_win.updateFavoritesMenu()

        if not from_server:
            server = GUIServerThread.instance()
            if server:
                server.toDaemon('/ray/favorites/remove', name, int(factory))
Exemple #12
0
    def disannounce(self, address=None):
        if not address:
            address = self.address

        if address:
            server = GUIServerThread.instance()
            server.disannounce(address)

        self.port = None
        self.url = ''
        del self.address
        self.address = None
        self.is_announced = False
Exemple #13
0
    def start(self):
        if self.launched_before:
            self.callDaemon()
            return

        ray_control_process = QProcess()
        ray_control_process.start("ray_control", ['get_port_gui_free'])
        ray_control_process.waitForFinished(2000)

        if ray_control_process.exitCode() == 0:
            port_str_lines = ray_control_process.readAllStandardOutput().data(
            ).decode('utf-8')
            port_str = port_str_lines.partition('\n')[0]

            if port_str and port_str.isdigit():
                self.address = Address(int(port_str))
                self.port = self.address.port
                self.url = self.address.url
                self.launched_before = True
                self.is_local = True
                self.callDaemon()
                return

        server = GUIServerThread.instance()
        if not server:
            sys.stderr.write(
                "impossible for GUI to launch daemon. server missing.\n")

        # start process
        arguments = [
            '--gui-url',
            str(server.url), '--osc-port',
            str(self.port), '--session-root', CommandLineArgs.session_root
        ]

        if CommandLineArgs.session:
            arguments.append('--session')
            arguments.append(CommandLineArgs.session)

        if CommandLineArgs.debug_only:
            arguments.append('--debug-only')
        elif CommandLineArgs.debug:
            arguments.append('--debug')
        elif CommandLineArgs.no_client_messages:
            arguments.append('--no-client-messages')

        if CommandLineArgs.config_dir:
            arguments.append('--config-dir')
            arguments.append(CommandLineArgs.config_dir)

        self.process.startDetached('ray-daemon', arguments)
    def dropEvent(self, event):
        QListWidget.dropEvent(self, event)

        client_ids_list = []

        for i in range(self.count()):
            item = self.item(i)
            #widget = self.itemWidget(item)
            client_id = item.getClientId()
            client_ids_list.append(client_id)

        server = GUIServerThread.instance()
        if server:
            server.toDaemon('/ray/session/reorder_clients', *client_ids_list)
Exemple #15
0
    def callDaemon(self):
        if not self.address:
            # I don't know really why, but it works only with a timer
            QTimer.singleShot(5, self.showDaemonUrlWindow)
            return

        self.announce_timer.start()

        server = GUIServerThread.instance()
        if not server:
            sys.stderr.write(
                'GUI can not call daemon, GUI OSC server is missing.\n')
            return

        server.announce()
Exemple #16
0
    def addFavorite(self, name, icon_name, factory, from_server=False):
        for favorite in self.favorite_list:
            if favorite.name == name and favorite.factory == factory:
                favorite.icon = icon_name
                return

        fav = ray.Favorite(name, icon_name, factory)
        self.favorite_list.append(fav)

        self._main_win.updateFavoritesMenu()

        if not from_server:
            server = GUIServerThread.instance()
            if server:
                server.toDaemon('/ray/favorites/add', name, icon_name,
                                int(factory))
Exemple #17
0
def signalHandler(sig, frame):
    if sig in (signal.SIGINT, signal.SIGTERM):
        if session._daemon_manager.launched_before:
            if (CommandLineArgs.under_nsm
                    and session.server_status != ray.ServerStatus.OFF):
                session._main_win.terminate_request = True
                
                server = GUIServerThread.instance()
                if server:
                    server.abortSession()
            else:
                session._daemon_manager.stop()
            return
        
        session._main_win.terminate_request = True
        session._daemon_manager.stop()
Exemple #18
0
 def sendPropertiesToDaemon(self):
     server = GUIServerThread.instance()
     if not server:
         sys.stderr.write(
             'Server not found. Client %s can not send its properties\n'
                 % self.client_id)
         return
     
     server.toDaemon('/ray/client/update_properties',
                     self.client_id,
                     self.executable_path,
                     self.arguments,
                     self.name,
                     self.prefix_mode,
                     self.custom_prefix,
                     self.label,
                     self.description,
                     self.icon_name,
                     self.capabilities,
                     int(self.check_last_save),
                     self.ignored_extensions)
Exemple #19
0
    QFontDatabase.addApplicationFont(":fonts/Ubuntu-C.ttf")
    
    initGuiTools()
    
    #Add raysession/src/bin to $PATH to can use raysession after make, whitout install
    ray.addSelfBinToPath()
    
    #get arguments
    parser = ArgParser()
    
    #connect signals
    signal.signal(signal.SIGINT , signalHandler)
    signal.signal(signal.SIGTERM, signalHandler)
    
    #needed for signals SIGINT, SIGTERM
    timer = QTimer()
    timer.start(200)
    timer.timeout.connect(lambda: None)
    
    #build session
    server = GUIServerThread()
    session = SignaledSession()
        
    app.exec()
    
    server.stop()
    session.quit()
    
    del session
    del app
 def toDaemon(self, *args):
     server = GUIServerThread.instance()
     if server:
         server.toDaemon(*args)
Exemple #21
0
    def closeSession(self):
        self.wait_for_close = True

        server = GUIServerThread.instance()
        if server:
            server.closeSession()