def setHostStatBasInfo(self,host_info): hostname = re.findall(r'\s*\bHost:\s*(.*)\n',host_info) if hostname: self.hostname =hostname[0] host_stat_param_dict=get_command_param(host_info,"jhosts -l") self.hostType=get_value("type",host_stat_param_dict) self.hostModel=get_value("model",host_stat_param_dict)
def getJobRusageInfo(job, resName): ''' resName = { MEM | SWAP | PGID | PIDs } ''' if job.jobResUsg: print job.jobResUsg print get_value(resName, job.jobResUsg) return bit_change(get_value(resName, job.jobResUsg)) else: return ""
def del_textbrowser(self): count = gl.get_value('count') print("第一次:" + str(count)) if count > 100: self.textBrowser.clear() gl.set_value('count',0)
def get( self,msg1,msg2): print("QSlot get msg => " + msg1+' '+msg2) global win_main win_main.outputWritten(msg1+"----"+msg2+"\n") count=gl.get_value('count') gl.set_value('count', count+1)
def getHostReserved(host,resName): ''' resName = { r15s | r1m | r15m | ut | pg | io | ls | it | tmp | swp | mem | cpuspeed } ''' if host.hostResvRusage: return bit_change(get_value(resName,host.hostResvRusage)) else: return ""
def _volume_control(self): ser = serial.Serial("COM3", 9600) common.wait_for_start(ser) while True: line = ser.readline() if common.first_button(line): potentiometer = common.get_value(line) #volume = self._calculate_volume_1(potentiometer) volume = self._calculate_volume_2_alt(potentiometer) self.set_volume_1(volume) elif common.second_button(line): potentiometer = common.get_value(line) #volume = self._calculate_volume_2(potentiometer) volume = self._calculate_volume_2_alt(potentiometer) self.set_volume_2(volume)
def get_statistics(self,stock_list,timestamp): stock_lists=stock_list # print stock_lists if len(stock_list)>200: tframe_list=[] for i in range(len(stock_list)/200+1): if 200*i > len(stock_list): break tframe=common.get_value(stock_lists[200*i:200*(i+1)],timestamp) tframe_list.append(tframe) tframe=pd.concat(tframe_list,axis=0) else: tframe=common.get_value(stock_lists,timestamp) up_10=0 dn_10=0 pos=len(tframe[tframe.change_rate > 0]) pos_rate=round(float(pos)/len(tframe),2) mean=tframe['change_rate'].mean() pos_rate=round(pos_rate,2) mean=round(mean,2) return (up_10,dn_10,pos_rate,mean,tframe)
def ansible_inventory_host(node): host = {} for (node_key, inv_key) in topo_to_host.items(): value = common.get_value(node, node_key.split('.')) if value: host[inv_key] = value for (k, v) in node.items(): if not k in topo_to_host_skip: host[k] = v return host
def get_statistics(self, stock_list, timestamp): stock_lists = stock_list # print stock_lists if len(stock_list) > 200: tframe_list = [] for i in range(len(stock_list) / 200 + 1): if 200 * i > len(stock_list): break tframe = common.get_value(stock_lists[200 * i:200 * (i + 1)], timestamp) tframe_list.append(tframe) tframe = pd.concat(tframe_list, axis=0) else: tframe = common.get_value(stock_lists, timestamp) up_10 = 0 dn_10 = 0 pos = len(tframe[tframe.change_rate > 0]) pos_rate = round(float(pos) / len(tframe), 2) mean = tframe['change_rate'].mean() pos_rate = round(pos_rate, 2) mean = round(mean, 2) return (up_10, dn_10, pos_rate, mean, tframe)
def setUsrBasicInfo(self,user_info): #para 'user_info' is the output of "jusers username" UsrName=re.findall(r'\bUser/Group:\s*(.+)\s*\n',user_info) if UsrName: self.UsrName=UsrName[0] user_parm_dict=get_command_param(user_info,"jusers") self.UsrMax = get_value("Max",user_parm_dict) self.UsrNjobs = get_value("JobsNum",user_parm_dict) self.UsrPend = get_value("Pend",user_parm_dict) self.UsrRun = get_value("Run",user_parm_dict) self.UsrSsusp = get_value("SSUSP",user_parm_dict) self.UsrUsusp = get_value("USUSP",user_parm_dict) self.UsrRsv = get_value("Rsv",user_parm_dict) self.UsrJLP = get_value("JL/P",user_parm_dict)
def add_node_interface(node, ifdata, defaults={}): node_links = node.get('links') if node_links is None: node_links = [] ifindex_offset = common.get_value( \ data=defaults, \ path=['devices',node['device'],'ifindex_offset'], \ default=1) ifindex = len(node_links) + ifindex_offset ifname_format = common.get_value( \ data=defaults, path=['devices',node['device'],'interface_name'], \ default=None) ifdata['ifindex'] = ifindex if ifname_format is not None: ifdata['ifname'] = ifname_format % ifindex node_links.append(ifdata) node['links'] = node_links return ifdata
def setHostBasicInfo(self,host_info): hostname = re.findall(r'\s*\bHost:\s*(.*)\s*\n',host_info) if hostname: self.hostname =hostname[0].strip() host_param_dict=get_command_param(host_info,"jhosts -l") self.hostcpuf=get_value("Cpuf",host_param_dict) self.hoststatus = get_value("Status",host_param_dict) self.hostslots = get_value("Max",host_param_dict) self.hostNjobs = get_value("JobsNum",host_param_dict) self.hostRunjob = get_value("Run",host_param_dict) self.hostSSUSPjob = get_value("SSUSP",host_param_dict) self.hostUSUSPjob = get_value("USUSP",host_param_dict) self.hostRSV = get_value("Rsv",host_param_dict) self.hostDISPATCH_WINDOW = get_value("DISPATCH_WINDOW",host_param_dict) self.hostSchedload = get_res_use_or_threshold(host_info,"jhosts -l","sched") self.hostStopload = get_res_use_or_threshold(host_info,"jhosts -l","stop") self.hostTotalRusage = get_res_use_or_threshold(host_info,"jhosts -l","total") self.hostResvRusage = get_res_use_or_threshold(host_info,"jhosts -l","resvd")
def augment_nodes(topology, defaults, pools): id = 0 ndict = {} for n in topology['nodes']: id = id + 1 if 'id' in n: common.error( "ERROR: static node IDs are not supported, overwriting with %d: %s" % (id, str(n))) n['id'] = id if not n.get('name'): common.error("ERROR: node does not have a name %s" % str(n)) continue if 'loopback' in pools: n['loopback'] = {} prefix_list = addressing.get(pools, ['loopback']) for af in prefix_list: if af == 'ipv6': n['loopback'][af] = get_addr_mask(prefix_list[af], 1) else: n['loopback'][af] = str(prefix_list[af]) if not 'device' in n: n['device'] = defaults.get('device') device_data = common.get_value( \ data=defaults, path=['devices',n['device']]) if not device_data: common.error("ERROR: Unsupported device type %s: %s" % (n['device'], n)) continue augment_mgmt_if(n, device_data, topology['addressing'].get('mgmt')) if 'box' in device_data: n['box'] = device_data['box'] ndict[n['name']] = n topology['nodes_map'] = ndict return ndict
def deloy_war(docker_deploy): result = {"success": False, "message": ""} uploadFile = os.path.join(common.get_value("uploadDir"), docker_deploy.fileName) print docker_deploy print "currentFilePath :" + uploadFile get_container_info = linux.DOCKER_CONTAINER_INSPECT % ( docker_deploy.appName) print "get docker info :" + get_container_info get_app_volumn_path = os.path.join( "/var/lib/docker/volumes/my-tomcat/_data", docker_deploy.appTargetPath) print "get docker volumn :" + get_app_volumn_path rmFile = linux.RM_FILE % ( os.path.join(get_app_volumn_path, docker_deploy.fileName), os.path.join(get_app_volumn_path, docker_deploy.fileName.split(".")[0])) print "start rm file : " + rmFile mvFile = linux.MV_FILE % ( uploadFile, os.path.join(get_app_volumn_path, docker_deploy.fileName)) print "start mv file: " + mvFile result["success"] = True return result
def checkHostResTotal(host,resName,num,timeout=30): host=str(host) res_name=str(resName) timeout=int(timeout) num=int(num) try: while timeout>0: stdout0, stderr0, exitcode0=execCommand("ps -ef|grep $JHSCHEDULER_TOP") print stdout0, stderr0, exitcode0 print timeout host_info=QueryHostInfo(host) if host_info: res_value=get_value(res_name,host_info.hostTotalRusage) if res_value and res_value != "-" and int(res_value)==num: print "%s:%s"%(res_name,res_value) return res_value else: print "%s:%s"%(res_name,res_value) timeout=timeout-1 try: time.sleep(2) except KeyboardInterrupt: print '' raise RuntimeError else: print "hostinfo:%s"%host_info timeout=timeout-1 try: time.sleep(2) except KeyboardInterrupt: print '' raise RuntimeError except KeyboardInterrupt: print '' raise RuntimeError if timeout==0: raise RuntimeError
def setBasicQueueInfo(self, queues_command_result): queue_name = re.findall(r'\bQUEUE:\s*(.+)\s*\n', queues_command_result) if queue_name: self.QueName = queue_name[0].strip() queue_parm_dict = get_command_param(queues_command_result, "jqueues -l") self.QueUsers = get_value("Users", queue_parm_dict) if self.QueUsers and self.QueUsers.replace(" ", "") != "allusers": self.QueUsers = self.QueUsers.split() self.QueHosts = get_value("Hosts", queue_parm_dict) if self.QueHosts and self.QueHosts.replace( " ", "") != "allhostsusedbytheschedulersystem": self.QueHosts = self.QueHosts.split() self.QuePrmt = get_value("Preemption", queue_parm_dict) self.QuePrmt = self.QuePrmt.split() self.QueStatus = get_value("stat.Status", queue_parm_dict) self.QueMax = get_value("stat.Max", queue_parm_dict) self.QuePRIO = get_value("stat.Prio", queue_parm_dict) self.QueThredload = {} self.QueUjoblimit = get_value("stat.JL/U", queue_parm_dict) self.QuePendjobnum = get_value("stat.Pend", queue_parm_dict) self.QueRunjobnum = get_value("stat.Run", queue_parm_dict) self.QueSsuspjobnum = get_value("stat.SSUSP", queue_parm_dict) self.QueUsuspjobnum = get_value("stat.USUSP", queue_parm_dict) self.QueRSVSlotnum = get_value("stat.Rsv", queue_parm_dict) self.QueExclu = get_value("SchedulingPolicies", queue_parm_dict) self.QueFairShare = get_value("FairShare", queue_parm_dict) self.QueRunWdw = get_value("RunWindow", queue_parm_dict) self.QueCpuLmt = get_value("CpuLimit", queue_parm_dict) self.QuePre = get_value("PreExec", queue_parm_dict) self.QuePost = get_value("PostExec", queue_parm_dict) self.QueResSched = get_res_use_or_threshold(queues_command_result, "jqueues -l", "sched") self.QueResStop = get_res_use_or_threshold(queues_command_result, "jqueues -l", "stop")
common.wait_for_start(ser) pygame.midi.init() player = pygame.midi.Output(0) player.set_instrument(20) last_value_1 = 0 last_value_2 = 0 RANGE_MAX = 127.0 RANGE_MIN = 40.0 while True: line = ser.readline() if common.first_button(line): potentiometer = common.get_value(line) step = int((potentiometer - 0.0) * (RANGE_MAX - RANGE_MIN) / (1023.0 - 0.0) + RANGE_MIN) if last_value_1 != step: player.note_off(last_value_1, 127) player.note_on(step, 127) last_value_1 = step print(step) if potentiometer == 0: player.note_off(step, 127) elif common.second_button(line): potentiometer = common.get_value(line) step = int((potentiometer - 0.0) * (RANGE_MAX - RANGE_MIN) / (1023.0 - 0.0) + RANGE_MIN)
def getHostThredStop(host,resName): if host.hostStopload: return bit_change(get_value(resName,host.hostStopload)) else: return ""
ser = serial.Serial("COM3", 9600) common.wait_for_start(ser) fig = plt.gcf() fig.show() fig.canvas.draw() x = [] y = [] i = 0 while True: for _ in range(10): line = ser.readline() d = common.get_value(line) print(d) x.append(i) y.append(d) i += 1 plt.plot(x, y, 'b') # plot something # update canvas immediately plt.xlim([0, 1000]) plt.ylim([0, 1024]) # plt.pause(0.01) # I ain't needed!!! fig.canvas.draw() if i == 1000:
def getQueResSched(que, resName): if que.QueResSched: return get_value(resName, que.QueResSched) else: return ""
def getQueResStop(que, resName): if que.QueResStop: return get_value(resName, que.QueResStop) else: return ""
def setGrUserBasicInfo(self, user_group_info): self.uGroup = get_command_param(user_group_info, "jusergroup") self.uGroupMem = get_value("Users", self.uGroup).split() self.uGroupAdmin = get_value("Group Admin", self.uGroup).split()