Esempio n. 1
0
	def action(self,name,action):
		for k in self.server_list.keys():
			p = re.compile("%s:.*" %(name))
			match = p.findall(k)
			if match != [] :
				id=re.findall("\d",match[0],flags=0)[-1]

		url = self.super_url[id]
		sup_action = Server(url)
		if action == 'start':
			sup_action.start(name)
		elif action == 'stop':
			sup_action.stop(name)
Esempio n. 2
0
    def __init__(self):
        self.motors = Motors()
        #self.marg = MARG()
        # not sure if I want this here, but will add for now
        self.server = Server()

        self.prev_msg = b''
Esempio n. 3
0
	def refresh(self):
		index = 0
		fp = file('/Users/admin/python/ENV2.7/coohua_CMDB/CMDB/server.conf')
		for line in fp.readlines():
			id = str(index) 
			# server = Server(line.strip())
			# self.super_url.append(line.strip())
			# self.super_url[id] = line.strip()
			self.super_url[id] = line.strip()
			index += 1
			if len(line.strip()) == 0:break
		
		fp.close()
		#将server.py 得到的多个机器的supervisor数据统一导入server_list字典方便统一输出到页面
		for k1,v1 in self.super_url.items():
			# print s
			test = Server(v1,k1)
			test.refresh()
			for k in  test.dic.keys():
				self.server_list[k] = test.dic[k]
Esempio n. 4
0
	def action(self,name,action):
		#通过name找到id,正则过滤出key里面的id
		for k in self.server_list.keys():
			p = re.compile("%s:.*" %(name))
			match = p.findall(k)
			if match != [] :
				id=re.findall("\d",match[0],flags=0)[-1]
		#通过id可以得到url
		url = self.super_url[id]
		# print url
		# print id
		# print name
		# print action
		sup_action = Server(url,id)
		if action == 'start':
			sup_action.start(name)
		elif action == 'stop':
			sup_action.stop(name)
		elif action == 'restart':
			sup_action.restart(name)
Esempio n. 5
0
def api():
    with Server() as s:
        yield s.init()
Esempio n. 6
0
    speeds = []

    if (len(msg) != 4):
        return
    for i in msg:
        if (i == 49):
            speeds.append(10)
        else:
            speeds.append(0)
    print(speeds)
    return speeds


if __name__ == "__main__":

    server = Server()
    # eventually just run Quadcopter class and it will create a server and motors inside its init(?)
    motors = Motors()
    # set motor ESC PPMs to 0 so that the motors will not move no matter what
    motors.turn_off()

    server.start_server()
    server.accept_connections()
    server.listen_in_parallel()
    print("hello")

    # now here, decipher whatever the client sends so that the pi can run the motors
    initialized = False
    while not initialized:
        if (server.client_msg == b'1000'):
            initialized = True