Esempio n. 1
0
File: udp.py Progetto: Rahuldee/XIG
    def __init__(self, xig_core, url, xbee_addr):
        self.__core = xig_core
        self.__toxbee_buf = ""
        self.__fromxbee_buf = ""
        self.__xbee_addr = xbee_addr
        self.__state = UDPSession.STATE_INIT
        self.__max_buf_size = self.__core.getConfig().global_max_buf_size 
        self.__command_parser = StreamingCommandParser()
              
        # Parse URL:
        parsedUrl = urlparse.urlsplit(url)
        self.__urlScheme = parsedUrl[0]
        self.__urlNetLoc = parsedUrl[1]
        
        logger.info("session to %s" % (self.__urlNetLoc))
        
        # check for portnumber in url
        if ':' not in self.__urlNetLoc:
            self.__do_error("UDP URL requires port number (e.g. udp://host:port)")
            return
        self.__urlNetLoc, portStr = self.__urlNetLoc.split(':')
        try:
            self.__urlPort = int(portStr)
        except ValueError:
            self.__do_error("UDP port number must be integer")
            return

        # Create command handlers:
        self.__command_parser.register_command(Command("xig://abort\r",
                                                self.__commandAbortHandler))
        self.__command_parser.register_command(Command("xig://abort\n",
                                                self.__commandAbortHandler))
        
        # Perform UDP connection:
        self.__create_socket()
Esempio n. 2
0
    def parse_url(self, url):
        parsedurl = urlparse.urlsplit(url)

        scheme = parsedurl[0]
        authority = parsedurl[1]
        path = parsedurl[2]
        if len(parsedurl[3]):
            query =  + parsedurl[3]
        else:
            query = None

        return scheme, authority, path, query
Esempio n. 3
0
    def __init__(self, xig_core, url, xbee_addr):

        self.__core = xig_core
        self.__write_buf = ""
        self.__read_buf = ""
        self.__xbee_addr = xbee_addr
        self.__max_buf_size = self.__core.getConfig().global_max_buf_size

        # Read configuration from configuration file:
        self.__targets = self.getTargetsFromConfig()

        # self.__oscclient = OSCClient.OSCClient()
        self.__multiclient = OSCClient.OSCMultiClient()

        # Parse URL:
        parsedUrl = urlparse.urlsplit(url)

        # could be rewritten as self.__urlScheme = parsedUrl.scheme  etc.
        self.__urlScheme = parsedUrl[0]
        self.__urlNetLoc = parsedUrl[1]
        self.__urlPath = parsedUrl[2]
        if len(parsedUrl[3]):
            # paramString = parsedUrl[3]
            self.__urlParameters = parsedUrl[3].split('&')
        else:
            self.__urlParameters = []

        if len(self.__urlNetLoc):
            self.__urlPort = 0
            if ':' in self.__urlNetLoc:
                self.__urlNetLoc, portStr = self.__urlNetLoc.split(':')
                self.__urlPort = int(portStr)
            self.__multiclient.setOSCTarget(
                (self.__urlNetLoc,
                 self.__urlPort))  # use this host target if supplied
        else:
            # self.__oscclient.connect(self.__target)
            for target in self.__targets:
                self.__multiclient.setOSCTarget(target)

        logger.info("starting OSC connection to [%s] %s | %s | %s'" %
                    (self.__urlScheme, self.__urlNetLoc, self.__urlPath,
                     self.__urlParameters))

        self.__connect()
Esempio n. 4
0
File: osc.py Progetto: Rahuldee/XIG
    def __init__(self, xig_core, url, xbee_addr):
        
        self.__core = xig_core
        self.__write_buf = ""
        self.__read_buf = ""
        self.__xbee_addr = xbee_addr
        self.__max_buf_size = self.__core.getConfig().global_max_buf_size 

        # Read configuration from configuration file:
        self.__targets = self.getTargetsFromConfig()

        # self.__oscclient = OSCClient.OSCClient()
        self.__multiclient = OSCClient.OSCMultiClient()
        
        # Parse URL:
        parsedUrl = urlparse.urlsplit(url)
        
        # could be rewritten as self.__urlScheme = parsedUrl.scheme  etc.
        self.__urlScheme = parsedUrl[0]
        self.__urlNetLoc = parsedUrl[1]
        self.__urlPath = parsedUrl[2]
        if len(parsedUrl[3]):
            # paramString = parsedUrl[3]
            self.__urlParameters = parsedUrl[3].split('&')
        else:
            self.__urlParameters = []

        if len(self.__urlNetLoc) :
            self.__urlPort = 0
            if ':' in self.__urlNetLoc:
                self.__urlNetLoc, portStr = self.__urlNetLoc.split(':')
                self.__urlPort = int(portStr)
            self.__multiclient.setOSCTarget( (self.__urlNetLoc,self.__urlPort) )        # use this host target if supplied
        else:
            # self.__oscclient.connect(self.__target)
            for target in self.__targets:
                self.__multiclient.setOSCTarget( target )
        
        logger.info("starting OSC connection to [%s] %s | %s | %s'" % (self.__urlScheme,self.__urlNetLoc,self.__urlPath, self.__urlParameters))

        self.__connect()
Esempio n. 5
0
    def __init__(self, xig_core, url, xbee_addr):
        self.__core = xig_core
        self.__toxbee_buf = ""
        self.__fromxbee_buf = ""
        self.__xbee_addr = xbee_addr
        self.__state = UDPSession.STATE_INIT
        self.__max_buf_size = self.__core.getConfig().global_max_buf_size
        self.__command_parser = StreamingCommandParser()

        # Parse URL:
        parsedUrl = urlparse.urlsplit(url)
        self.__urlScheme = parsedUrl[0]
        self.__urlNetLoc = parsedUrl[1]

        logger.info("session to %s" % (self.__urlNetLoc))

        # check for portnumber in url
        if ':' not in self.__urlNetLoc:
            self.__do_error(
                "UDP URL requires port number (e.g. udp://host:port)")
            return
        self.__urlNetLoc, portStr = self.__urlNetLoc.split(':')
        try:
            self.__urlPort = int(portStr)
        except ValueError:
            self.__do_error("UDP port number must be integer")
            return

        # Create command handlers:
        self.__command_parser.register_command(
            Command("xig://abort\r", self.__commandAbortHandler))
        self.__command_parser.register_command(
            Command("xig://abort\n", self.__commandAbortHandler))

        # Perform UDP connection:
        self.__create_socket()