Пример #1
0
	def listen(self):
		#print("thread !!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
		self.running=True

		while(1):
			understood=False
			data = self.recvall(512)
			
			if data==None:
				break

			print("command=",data,len(data))
			if data.startswith(str.encode("gpvdmfile")):
				self.rx_file(data)
				understood=True

			if data.startswith(str.encode("gpvdmpercent")):
				lines=data.split("\n")
				percent=float(inp_search_token_value(lines, "#percent"))
				self.progress_window.set_fraction(percent/100.0)
				understood=True

			if data.startswith(str.encode("gpvdmjobfinished")):
				lines=data.split("\n")
				name=inp_search_token_value(lines, "#job_name")
				self.label.set_text(gui_print_path("Finished:  ",name,60))
				understood=True

			if data.startswith(str.encode("gpvdmfinished")):
				self.stop()
				understood=True

			if data.startswith(str.encode("gpvdmheadquit")):
				self.stop()
				print("Server quit!")
				understood=True

			if data.startswith(str.encode("gpvdmnodelist")):
				self.process_node_list(data)
				understood=True

			if data.startswith(str.encode("gpvdm_sync_packet_two")):
				self.process_sync_packet_two(data)
				understood=True

			if data.startswith(str.encode("gpvdm_sync_packet_one")):
				self.process_sync_packet_one(data)
				understood=True

			if data.startswith(str.encode("gpvdm_job_list")):
				self.process_job_list(data)
				understood=True

			if data.startswith(str.encode("gpvdm_message")):
				print(data)
				understood=True

			if understood==False:
				print("Command ",data, "not understood")
Пример #2
0
    def listen(self):
        print "thread !!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
        self.running = True
        try:
            self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        except socket.error:
            print "Failed to create socket"
            sys.exit()

        self.socket.bind(("", 8889))

        while 1:
            d = self.socket.recvfrom(1024)
            data = d[0]
            addr = d[1]
            print data
            print "command=", data
            if data.startswith("percent"):
                command = data.split("#")
                percent = float(command[1])
                self.progress_window.set_fraction(percent / 100.0)

            if data.startswith("job_finished"):
                command = data.split("#")
                self.label.set_text(gui_print_path("Finished:  ", command[1], 60))
            if data.startswith("finished"):
                self.stop()
                sys.exit()
            if data.startswith("ok"):
                self.mylock = False
            if data.startswith("node_error"):
                command = data.split("#")
                print "Node error!!! " + command[1]
                # self.mylock.set()
            if data.startswith("load"):
                if data.count("#") > 1:
                    command = data.split("#")
                    items = len(command)
                    height = 50
                    for i in range(1, len(command)):
                        print command[i]
                        height = height + 15
                        percent = float(command[i])
                        if self.progress_window.progress_array[i].get_property("visible") == False:
                            self.progress_window.progress_array[i].show()
                        self.progress_window.progress_array[i].set_fraction(percent)

                    window_height = self.progress_window.get_size()
                    window_height = window_height[1]
                    if window_height != height:
                        self.progress_window.set_size_request(400, height)
            if data.startswith("server_quit"):
                self.stop()
                print "Server quit!"
Пример #3
0
    def listen(self):
        self.running = True
        self.stop_listening = False

        while (1):
            understood = False
            if self.stop_listening == True:
                break
            data = self.rx_packet()

            if data == None:
                break

            #print(data.id)
            if data.id == "gpvdmnodelist":
                self.process_node_list(data)
                self.load_update.emit()
                understood = True

            if data.id == "gpvdm_job_list":
                self.process_job_list(data)
                understood = True

            if data.id == "gpvdmfinished":
                self.stop()
                understood = True

            if data.id == "gpvdmheadquit":
                self.stop()
                print("Server quit!")
                understood = True

            if data.id == "gpvdm_message":
                self.new_message.emit(data.message)
                understood = True

            if data.id == "gpvdmfile":
                print("from here", data.id)
                self.rx_file(data)
                understood = True

            if data.id == "gpvdmpercent":
                lines = data.split("\n")
                percent = float(inp_search_token_value(lines, "#percent"))
                self.progress_window.set_fraction(percent / 100.0)
                understood = True

            if data.id == "gpvdmjobfinished":
                lines = data.split("\n")
                name = inp_search_token_value(lines, "#job_name")
                self.label.set_text(gui_print_path("Finished:  ", name, 60))
                understood = True

            if data.id == "gpvdmthingdone":
                wait_update(data.token)
                understood = True

            if data.id == "gpvdm_sync_packet_two":
                self.process_sync_packet_two(data)
                understood = True

            if data.id == "gpvdm_sync_packet_one":
                self.process_sync_packet_one(data)
                understood = True

            if understood == False:
                print("Command >", data, "<not understood")
Пример #4
0
    def listen(self):
        #print("thread !!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
        self.running = True

        while (1):
            understood = False
            data = self.recvall(512)

            if data == None:
                break

            #print("command=",data,len(data))
            if data.startswith(str.encode("gpvdmfile")):
                self.rx_file(data)
                understood = True

            if data.startswith(str.encode("gpvdmpercent")):
                lines = data.split("\n")
                percent = float(inp_search_token_value(lines, "#percent"))
                self.progress_window.set_fraction(percent / 100.0)
                understood = True

            if data.startswith(str.encode("gpvdmjobfinished")):
                lines = data.split("\n")
                name = inp_search_token_value(lines, "#job_name")
                self.label.set_text(gui_print_path("Finished:  ", name, 60))
                understood = True

            if data.startswith(str.encode("gpvdmfinished")):
                self.stop()
                understood = True

            if data.startswith(str.encode("gpvdmheadquit")):
                self.stop()
                print("Server quit!")
                understood = True

            if data.startswith(str.encode("gpvdmnodelist")):
                self.process_node_list(data)
                self.load_update.emit()
                understood = True

            if data.startswith(str.encode("gpvdm_sync_packet_two")):
                self.process_sync_packet_two(data)
                understood = True

            if data.startswith(str.encode("gpvdm_sync_packet_one")):
                self.process_sync_packet_one(data)
                understood = True

            if data.startswith(str.encode("gpvdm_job_list")):
                self.process_job_list(data)
                understood = True

            if data.startswith(str.encode("gpvdm_message")):
                try:
                    d = data.decode('UTF-8')
                except:
                    print(data)
                    sys.exit(0)
                d = d.split("\n")
                message = inp_search_token_value(d, "#message")
                self.new_message.emit(message)

                understood = True

            if understood == False:
                print("Command ", data, "not understood")