def main(): init_players() print("players initialized") sys.stdout.flush() poll() while True: sleep(0.1) cmd = poll() evaluate(tokenize(cmd)) sys.stdout.flush()
def wait_reboot(): logf = lambda : fastprint(".") puts("Waiting for shutdown",end="") fastprint("") up(env.host,22,logf) fastprint("\n") puts("Waiting for reboot",end="") fastprint("") poll(env.host,22,600,logf) fastprint("\n")
def poll2(timeout=0.0): import poll # timeout is in milliseconds timeout = int(timeout * 1000) if socket_map: l = [] for fd, obj in socket_map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append([fd, flags]) r = poll.poll(l, timeout) for fd, flags in r: try: obj = socket_map[fd] try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
def poll2(timeout=0.0, map=None): import poll if map is None: map = socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout * 1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append((fd, flags)) r = poll.poll(l, timeout) for fd, flags in r: try: obj = map[fd] except KeyError: continue try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll2(timeout=0.0): import poll # timeout is in milliseconds timeout = int(timeout * 1000) if socket_map: fd_map = {} for s in socket_map.keys(): fd_map[s.fileno()] = s l = [] for fd, s in fd_map.items(): flags = 0 if s.readable(): flags = poll.POLLIN if s.writable(): flags = flags | poll.POLLOUT if flags: l.append((fd, flags)) r = poll.poll(l, timeout) for fd, flags in r: s = fd_map[fd] try: if (flags & poll.POLLIN): s.handle_read_event() if (flags & poll.POLLOUT): s.handle_write_event() if (flags & poll.POLLERR): s.handle_expt_event() except: s.handle_error()
def run(self): poll_obj = poll() calculate_obj = Calculate() if len(self.names) > 0: for server in self.names: stopwatch = Stopwatch() comm = "openstack server delete " + server stopwatch.start() os.system(comm) SERVER_LIST.append(server) while True: delete_status = poll_obj.delete_server(server) if delete_status == 1: TIME_LIST.append(stopwatch.time_elapsed) stopwatch.stop() break elif delete_status == 0: pass elif delete_status == -1: print "Deletion Failed" break print "Deleted server..." + server min = calculate_obj.getMin(TIME_LIST) max = calculate_obj.getMax(TIME_LIST) avg = calculate_obj.getAverage(TIME_LIST) print "Min: " + str(min) print "Max: " + str(max) print "Average: " + str(avg) dict_return['server'] = SERVER_LIST dict_return['min'] = min dict_return['max'] = max dict_return['avg'] = avg dict_return['name'] = "nova.delete" disp_list.append(dict_return) return disp_list
def poll2 (timeout=0.0): import poll # timeout is in milliseconds timeout = int(timeout*1000) if socket_map: fd_map = {} for s in socket_map.keys(): fd_map[s.fileno()] = s l = [] for fd, s in fd_map.items(): flags = 0 if s.readable(): flags = poll.POLLIN if s.writable(): flags = flags | poll.POLLOUT if flags: l.append (fd, flags) r = poll.poll (l, timeout) print r for fd, flags in r: s = fd_map[fd] try: if (flags & poll.POLLIN): s.handle_read_event() if (flags & poll.POLLOUT): s.handle_write_event() if (flags & poll.POLLERR): s.handle_expt_event() except: apply (s.handle_error, sys.exc_info())
def poll2(timeout=0.0, map=None): import poll if map is None: map = socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout * 1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append((fd, flags)) r = poll.poll(l, timeout) for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
def poll2(timeout=0.0, map=None): import poll if map is None: map = socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append((fd, flags)) r = poll.poll(l, timeout) for fd, flags in r: obj = map.get(fd) if obj is None: continue readwrite(obj, flags)
def run(self): poll_obj = poll() calculate_obj = Calculate() for i in range(0, self.count): stopwatch = Stopwatch() comm = "openstack server list" stopwatch.start() os.system(comm) TIME_LIST.append(stopwatch.time_elapsed) stopwatch.stop() min = calculate_obj.getMin(TIME_LIST) max = calculate_obj.getMax(TIME_LIST) avg = calculate_obj.getAverage(TIME_LIST) print "Min: " + str(min) print "Max: " + str(max) print "Average: " + str(avg) dict_return['server'] = SERVER_LIST dict_return['min'] = min dict_return['max'] = max dict_return['avg'] = avg dict_return['name'] = "nova.list" disp_list.append(dict_return) return disp_list
def run(self): poll_obj = poll() calculate_obj = Calculate() for i in range(0,self.count): stopwatch = Stopwatch() random=getrandom(5) self.name="server-"+random.getSuffix() comm = "openstack server create "+self.name+" --image "+self.image+" --flavor "+self.flavor+" --nic net-id="+self.network subprocess.check_output(comm,shell=True) SERVER_LIST.append(self.name) stopwatch.start() while True: create_status = poll_obj.create_server(self.name) if create_status == 1: TIME_LIST.append(stopwatch.time_elapsed) stopwatch.stop() break elif create_status == 0: pass elif create_status == -1: print "Creation Failed" break print "Created Server... "+self.name min = calculate_obj.getMin(TIME_LIST) max = calculate_obj.getMax(TIME_LIST) avg = calculate_obj.getAverage(TIME_LIST) #print_output(min,max,avg,"nova.create",self.count) #print "Min: "+str(min) #print "Max: "+str(max) #print "Average: "+str(avg) dict_return['server']=SERVER_LIST dict_return['min']=min dict_return['max']=max dict_return['avg']=avg dict_return['name'] = "nova.create" disp_list.append(dict_return) return disp_list
# -*- Mode: Python -*-
def test_poll(self): """Run poll() with default arguments.""" ret = poll.poll(self.args) self.assertEqual(ret, poll.NOERROR)
# -*- Mode: Python -*-