예제 #1
0
    def send(self, expr):
        if self.verbose:
            print "Sending: " + expr

        self.sock.send(expr)

        reply = self.sock.recv(16384)

        if reply.startswith('(') and reply.endswith(')'):
            result = skill.parse(reply[1:-1])
        elif not reply.startswith('(') and reply.endswith('()'):
            result = skill.parse(reply[:-2])
        else:
            raise Exception("Invalid reply from server: %s" % reply)

        return result
예제 #2
0
	def send(self, expr, parse=True, parseall=False):
		if self.verbose:
			print >> sys.stderr, "Sending: " + expr
		self.cds.sendline(expr)
		self.cds.expect(self.prompt)
		if self.verbose:
			print >> sys.stderr, "Got:", self.cds.before

		responselines = [s for s in re.split("[\r]\n",self.cds.before) if s != ""]

		if responselines[-1].find("*Error*") > 0:
			raise SkillError(self.cds.before)

		result = True
		if parse:
			if parseall:
				response = self.cds.before
			else:
				response = responselines
			try:
			    result = skill.parse(response)
			except:
			    raise Exception("Could not parse response")

		if self.verbose:
			print >> sys.stderr, "Result:", result
		
		return result
예제 #3
0
	def send(self, expr):
            if self.verbose:
                print "Sending: "+expr

            self.sock.send(expr)

            reply = self.sock.recv(16384)

	    if reply.startswith('(') and reply.endswith(')'):
                result = skill.parse(reply[1:-1])
	    elif not reply.startswith('(') and reply.endswith('()'):
                result = skill.parse(reply[:-2])
	    else:
                raise Exception("Invalid reply from server: %s" % reply)

	    return result
예제 #4
0
파일: cds.py 프로젝트: sfgorky/pycircuit
	def send(self, expr, parse=True, parseall=False):
		if self.verbose:
			print >> sys.stderr, "Sending: " + expr
		self.cds.sendline(expr)
		self.cds.expect(self.prompt)
		if self.verbose:
			print >> sys.stderr, "Got:", self.cds.before

		responselines = [s for s in re.split("[\r]\n",self.cds.before) if s != ""]

		if responselines[-1].find("*Error*") > 0:
			raise SkillError(self.cds.before)

		result = True
		if parse:
			if parseall:
				response = self.cds.before
			else:
				response = responselines
			try:
			    result = skill.parse(response)
			except:
			    raise Exception("Could not parse response")

		if self.verbose:
			print >> sys.stderr, "Result:", result
		
		return result
예제 #5
0
파일: cds.py 프로젝트: dreyfert/pycircuit
	def send(self, expr):
		if self.verbose:
			print "Sending: "+expr
		self.cds.sendline(expr)
		self.cds.expect(self.prompt)
		if self.verbose:
			print "Got:", self.cds.before

		response = [s for s in re.split("[\r]\n",self.cds.before) if s != ""][-1]

		try:
		    result = skill.parse(response)
		except:
		    print response
		    raise Exception("Could not parse response")

		if response.find("*Error*") > 0:
			raise Exception(response)

		if self.verbose:
			print "Result:", result
		
		return result