def clone(link, destination, delete_existing=False, recursive=False, ignore_existing=False): if delete_existing: if has_changes(destination): Debug.throw("Can not delete repository with changes at path: " + destination) else: File.rm(destination) if File.exists(destination): if ignore_existing: Debug.info(destination + " exists") return Debug.throw("Git repository: " + link + " already exists for path: " + File.full_path(destination)) command = ["git", "clone", link, destination] if recursive: command += ["--recursive"] Shell.run(command)
def run(generator=default_generator()): if Args.android: return args = ["cmake", "..", "-G", generator] args += ["-DCMAKE_BUILD_TYPE=Release" if Args.release else "-DCMAKE_BUILD_TYPE=Debug"] if Args.ios: platform = "SIMULATOR64" if Args.device: platform = "OS64" args += ["-DCMAKE_TOOLCHAIN_FILE=" + iOS.toolchain_file] args += ["-DPLATFORM=" + platform] args += ["-DDEPLOYMENT_TARGET=" + Args.ios_version] if Args.device: args += ["-DARCHS=arm64"] else: args += ["-DARCHS=x86_64"] if Args.no_bitcode: args += ["-DENABLE_BITCODE=FALSE"] Shell.run(args)
def decompress(filePath, **options): command = u'arkzip --interface none' if u'output_dir' in options: buffer = Shell.quote(options['output_dir']) command += u' --output-dir ' + buffer if u'key' in options: buffer = Shell.quote(options['key']) command += u' --key ' + buffer if u'skip_pass' in options: if options['skip_pass']: command += u' --skip-pass' buffer = Shell.quote(filePath) command += u' -- ' + buffer status = commands.getstatusoutput(command)[0] if status == 0: return elif status == 36: raise PasswordWrong() raise status
def get_job_nprocs(s_cmd, job_id, node_domain_suffix='dccn.nl', debug=False): """get processor allocation of given job""" hprocs = {} re_hostlist = re.compile( '^req_information\.hostlist\.[0-9]+\s+=\s+(\S+):ppn=([0-9]+)$') s = Shell(debug=False) cmd = "qstat -f " + job_id rc, output, m = s.cmd1(cmd, allowed_exit=[0, 255], timeout=300) for l in output.split('\n'): l.strip() m = re_hostlist.match(l) if not m: continue host = m.group(1) nproc = int(m.group(2)) if host not in hprocs.keys(): hprocs[host] = 0 hprocs[host] += nproc return hprocs
def get(): if not Shell.check(["clang", "-dumpversion"]): return Compiler("clang") version_output = Shell.get(["clang", "-v"]) full_version = Regex.version(version_output) major_version = Regex.first_number(full_version) conan_version = full_version[:3] if System.is_mac and major_version > 9: conan_version = full_version[:4] name = "clang" if System.is_mac and not Args.android: name = "apple-clang" return Compiler(name = "clang", is_available = True, libcxx = "libc++", conan_name = name, full_version = full_version, major_version = major_version, conan_version = conan_version, CC = "clang", CXX = "clang++")
def get_matlab_license_usage(s_cmd, node_domain_suffix='dccn.nl', debug=False): """get matlab license usage of DCCN""" licenses = [] re_pkg_header = re.compile('^package\s+(\S+):\s+.*') re_lic = re.compile('^\|\s+([a-z]+)\s+\|\s+(\S+)\s+\|.*') s = Shell(debug=False) rc, output, m = s.cmd1(s_cmd, allowed_exit=[0, 255], timeout=300) pkg = None i = 0 for l in output.split('\n'): l.strip() m = re_pkg_header.match(l) if m: pkg = m.group(1) continue m = re_lic.match(l) if not m: continue u = m.group(1) h = '%s.%s' % (m.group(2).split('.')[0], node_domain_suffix) licenses.append(Job(jid=i, package=pkg, host=h, uid=u)) i += 1 return licenses
def get_fs(s_cmd, debug=False): '''run cluster-faireshare to get current fairshare per USER/GROUP/CLASS/QoS''' logger = getMyLogger(os.path.basename(__file__)) if debug: logger.setLevel(logging.DEBUG) fs = {} s = Shell(debug=False) rc, output, m = s.cmd1(s_cmd, allowed_exit=[0, 255], timeout=300) if rc != 0: logger.error('command %s return non-exit code: %d' % (cmd, rc)) else: re_user_beg = re.compile('^USER$') re_group_beg = re.compile('^GROUP$') re_class_beg = re.compile('^CLASS$') idx = {'user': [], 'group': [], 'class': []} k = None output = output.split('\n') for i in xrange(len(output)): if re_user_beg.match(output[i].strip()): k = 'user' idx[k].append(i + 2) continue if re_group_beg.match(output[i].strip()): k = 'group' idx[k].append(i + 2) continue if re_group_beg.match(output[i].strip()): k = 'class' idx[k].append(i + 2) continue if k and output[i].strip() == '': idx[k].append(i) k = None continue logger.debug('line indices on %s output for USER/GROUP/CLASS' % s_cmd) logger.debug(' |_ %s ' % repr(idx)) re_skip = re.compile('^DEFAULT') for k, v in idx.iteritems(): fs[k] = {} if v: for line in output[v[0]:v[1]]: data = line.strip().split() if not re_skip.match(data[0]): ## remove the '*' at the tail of userid fs[k][re.sub('\*$', '', data[0])] = float(data[1]) return fs
def get_fs(s_cmd, debug=False): '''run cluster-faireshare to get current fairshare per USER/GROUP/CLASS/QoS''' logger = getMyLogger(os.path.basename(__file__)) if debug: logger.setLevel(logging.DEBUG) fs = {} s = Shell(debug=False) rc, output, m = s.cmd1(s_cmd, allowed_exit=[0,255], timeout=300) if rc != 0: logger.error('command %s return non-exit code: %d' % (cmd, rc)) else: re_user_beg = re.compile('^USER$') re_group_beg = re.compile('^GROUP$') re_class_beg = re.compile('^CLASS$') idx = {'user':[],'group':[],'class':[]} k = None output = output.split('\n') for i in xrange(len(output)): if re_user_beg.match(output[i].strip()): k = 'user' idx[k].append(i+2) continue if re_group_beg.match(output[i].strip()): k = 'group' idx[k].append(i+2) continue if re_group_beg.match(output[i].strip()): k = 'class' idx[k].append(i+2) continue if k and output[i].strip() == '': idx[k].append(i) k = None continue logger.debug('line indices on %s output for USER/GROUP/CLASS' % s_cmd ) logger.debug(' |_ %s ' % repr(idx)) re_skip = re.compile('^DEFAULT') for k,v in idx.iteritems(): fs[k] = {} if v: for line in output[v[0]:v[1]]: data = line.strip().split() if not re_skip.match( data[0] ): ## remove the '*' at the tail of userid fs[k][re.sub('\*$','',data[0])] = float(data[1]) return fs
def run(): _project_name = "sand" if File.exists(build_dir + "/../source/sand") else project_name build() bin_dir = File.full_path(build_dir) + "/" if File.exists(bin_dir + "bin"): bin_dir += "bin/" Shell.run([bin_dir + _project_name])
def __init__(self): # Construct window Gtk.Window.__init__(self, title="Proprietary Notes") self.set_border_width(10) winShell = Shell() winShell.
def remote(path): if not File.exists(path): return "No folder" return Shell.get([ "git", "-C", File.full_path(path), "config", "--get", "remote.origin.url" ])
def drawWindow(): win.blit(bg, (0, 0)) for shell in shells: if shell.x < 500 and shell.x > 0: shell.x += shell.vel else: shells.pop(shells.index(shell)) keys = pygame.key.get_pressed() global start_time if keys[pygame.K_f]: if player.lastMove == 'right': facing = 1 else: facing = -1 current_time = time() if current_time - start_time > 0.1: if len(shells) < 50: shells.append( Shell.shell(round(player.x + Player.WIDTH / 2), round(player.y + Player.HEIGHT / 2), 5, (255, 000, 100), facing)) start_time = current_time for e in entities: win.blit(e.image, (e.x, e.y)) player.motion(blocks) for shell in shells: shell.draw(win) shell.motion(blocks) player.draw(win) pygame.display.update()
def test_delivery_csv(): item = { "order_number": 1, "carrier": "foodora", "address": "27 King's College Cir, Toronto, ON M5S" } details = str({ "subtotal": 1.88, "total": 2.12, "water": { "price": 1.88, "quantity": 1 } }) fullitem = item fullitem["order_details"] = details csv_columns = ['order_number', "carrier", 'address', 'order_details'] csvfile = io.StringIO() writer = csv.DictWriter(csvfile, fieldnames=csv_columns) writer.writeheader() writer.writerow(fullitem) csv_string = csvfile.getvalue() assert s.delivery_helper( item, details) == ("postdata", "http://127.0.0.1:5000/checkout/foodora", csv_string)
def test_shell_add_drink(): assert s.add_helper(["1", "drink", "coke"]) == ("post", "http://127.0.0.1:5000/order/1/drink", { "name": "coke", "price": drinkPrices["coke"] })
def test_shell_add_preset_pizza(): assert s.add_helper(["1", "pizza", "margherita", "small"]) == ("post", "http://127.0.0.1:5000/order/1/pizza", { "name": "margherita", "price": pizzaPrices["margherita"], "size": "small" })
def test_checkout_delivery(): item = { "order_number": 1, "carrier": "ubereats", "address": "27 King's College Cir, Toronto, ON M5S" } assert s.checkout_helper([ "1", "delivery", "ubereats", "27 King's College Cir, Toronto, ON M5S" ]) == ("get", "http://127.0.0.1:5000/order/1", item)
def main(self): #load panels self.music = Music.Music(self) self.music.start() self.shell = Shell.Shell(self) self.shell.start() self.toogle(self.PANE_SHELL) #start event loop self.eventThread = EventThread(self) self.eventThread.start()
def root_dir(path='.'): _path = path while not File.is_root(_path): if File.exists(_path + '/.projectile'): super_project = Shell.get( ["git", "rev-parse", "--show-superproject-working-tree"]) if super_project: return super_project return File.full_path(_path) _path = _path + "/.." return ""
def addSubwindow(self,nombre): """Añade una subventana al MDIAREA de la ventana principal. Parámetros: (nombre:str) Retorno: void """ proc = Proceso.Proceso(int(t.time()+3)%1000,nombre,tiempo = 0,edo = "R") proc.nom = nombre+str(proc.ide) bandAgregado = self.administradorMemoria.agregarProceso(proc) if bandAgregado == True: if nombre == "Shell": terminal = Shell.Shell(planifi=self.planificador) terminal.ide = proc.ide terminal.setWindowTitle(nombre+str(proc.ide)) ventanitaActual = self.ui.mdiArea.addSubWindow(terminal) self.dicWindowMDI.append(ventanitaActual.widget().windowTitle()) QtCore.QObject.connect(ventanitaActual,QtCore.SIGNAL("destroyed()"),self.cerrarSubventana) terminal.show() elif nombre == "Navegador": navegador = Navegador.Navegador() navegador.ide = proc.ide navegador.setWindowTitle(nombre+str(proc.ide)) ventanitaActual = self.ui.mdiArea.addSubWindow(navegador) self.dicWindowMDI.append(ventanitaActual.widget().windowTitle()) QtCore.QObject.connect(ventanitaActual,QtCore.SIGNAL("destroyed()"),self.cerrarSubventana) navegador.show() elif nombre == "ValidadorTarjetas": principalWindow = CheckTarjetas.CheckTarjetas() principalWindow.ide = proc.ide principalWindow.setWindowTitle(nombre+str(proc.ide)) ventanitaActual = self.ui.mdiArea.addSubWindow(principalWindow) #ventanitaActual.windowStateChanged self.dicWindowMDI.append(ventanitaActual.widget().windowTitle()) QtCore.QObject.connect(ventanitaActual,QtCore.SIGNAL("destroyed()"),self.cerrarSubventana) principalWindow.show() else: principalWindow = controlHardware.ventanaPrincipal() principalWindow.ide = proc.ide principalWindow.setWindowTitle(nombre+str(proc.ide)) ventanitaActual = self.ui.mdiArea.addSubWindow(principalWindow) #ventanitaActual.windowStateChanged self.dicWindowMDI.append(ventanitaActual.widget().windowTitle()) QtCore.QObject.connect(ventanitaActual,QtCore.SIGNAL("destroyed()"),self.cerrarSubventana) principalWindow.show() self.planificador.planificarProceso(proc) self.manejadorGUI.actualizarMemorias(self.administradorMemoria) else: ret = QtGui.QMessageBox.critical(self, "Las memorias esta llenas", '''Memorias llenas ''', QtGui.QMessageBox.Ok, QtGui.QMessageBox.Cancel)
def test_shell_add_custom_pizza(): assert s.add_helper(["1", "custompizza", "small", "beef" ]) == ("post", "http://127.0.0.1:5000/order/1/custompizza", { "size": { "name": "small", "price": pizzaPrices["small"] }, "toppings": [{ "name": "beef", "price": toppingPrices["beef"] }] })
def getpw(self, section, option): key = self._makekey(section, option) pw = self.pws.get(key) if (pw != None): return pw pw = self.get(section, option) if (pw == None): pw = "" if (len(pw) == 0): while (len(pw) == 0): pw = Shell.password(PW_TMPL % (key)) LOG.debug("Password for %s will be %s" % (key, pw)) self.pws[key] = pw return pw
def getpw(self, section, option): key = self._makekey(section, option) pw = self.pws.get(key) if(pw != None): return pw pw = self.get(section, option) if(pw == None): pw = "" if(len(pw) == 0): while(len(pw) == 0): pw = Shell.password(PW_TMPL % (key)) LOG.debug("Password for %s will be %s" % (key, pw)) self.pws[key] = pw return pw
def get(): if not Shell.check(["gcc", "-dumpversion"]): return Compiler("gcc") supported_versions = [7, 8, 9, 10] default_version = Shell.get(["gcc", "-dumpversion"]) default_major_version = Regex.first_number(default_version) if default_major_version in supported_versions: return Compiler(name="gcc", is_available=True, full_version=default_version, major_version=default_major_version, conan_version=default_version[:3], CXX="g++") version = None for ver in supported_versions: if Shell.check(["gcc-" + str(ver), "-dumpversion"]): version = ver break if not version: return Compiler("gcc") full_version = Shell.get(["gcc-" + str(version), "-dumpversion"]) major_version = Regex.first_number(full_version) return Compiler(name="gcc", is_available=True, full_version=full_version, major_version=Regex.first_number(full_version), conan_version=full_version[:3], CC="gcc-" + str(version), CXX="g++-" + str(version))
def build(): File.write(simulation_flag_file_name, "") Shell.run_string("yosys -q -p \"synth_ice40 -top top -blif " + project_name + ".blif\" " + top_module) Shell.run_string("arachne-pnr -d 8k -p " + project_name + ".pcf " + project_name + ".blif -o " + project_name + ".asc") Shell.run_string("icepack " + project_name + ".asc " + project_name + ".bin")
def __init__(self): pygame.init() pygame.display.init() self.quit = False self.rover = Shell() self.fps = 48 # Camera Frame Rate self.windowSize = [740, 280] self.imageRect = (0, 0, 320, 280) self.displayCaption = "Machine Perception and Cognitive Robotics" pygame.display.set_caption(self.displayCaption) self.screen = pygame.display.set_mode( self.windowSize, HWSURFACE | DOUBLEBUF | RESIZABLE) self.clock = pygame.time.Clock() self.run()
def test_delivery_json(): item = { "order_number": 1, "carrier": "ubereats", "address": "27 King's College Cir, Toronto, ON M5S" } details = { "coke": { "price": 1.66, "quantity": 1 }, "subtotal": 1.66, "total": 1.88 } assert s.delivery_helper( item, details) == ("post", "http://127.0.0.1:5000/checkout/ubereats", item)
def run(self, inputfile, outputfile): inputpath = os.path.abspath(inputfile) outputpath = os.path.abspath(outputfile) # Save the start directory startdir = os.getcwd() # Change dir to the GRD codes print "Changing dir to %s" % (self.workdir) os.chdir(self.workdir) # Execute GRD codes if (self.lrdir != None): cmd = ['./%s' % (self.executable), '-v', '-d', self.hrdir,\ '-b', self.lrdir, \ inputpath, outputpath,] else: cmd = ['./%s' % (self.executable), '-v', '-d', self.hrdir,\ inputpath, outputpath,] print "Executing cmd: %s" % (str(cmd)) shell = Shell(cmd) shell.runCommand() retcode = shell.getReturnCode() output = shell.getOutput() # Change dir to start dir print "Changing dir back to %s" % (startdir) os.chdir(startdir) if (output != None): output = output.splitlines() if (retcode != 0): print "Failed to generate GRD outputfile" print "Output: %s" % (str(output)) return 1 return 0
def test_menu_by_item_pizza(): assert s.menu_helper([ "pizza", "vegetarian" ]) == ("get", "http://127.0.0.1:5000/menu/pizzas/vegetarian")
def test_menu_by_item_topping(): assert s.menu_helper(["topping", "olives" ]) == ("get", "http://127.0.0.1:5000/menu/toppings/olives")
def test_menu_by_category_toppings(): assert s.menu_helper(["topping" ]) == ("get", "http://127.0.0.1:5000/menu/toppings")
def test_menu_by_item_drink(): assert s.menu_helper(["drink", "coke" ]) == ("get", "http://127.0.0.1:5000/menu/drinks/coke")
def test_menu_by_category_pizzas(): assert s.menu_helper(["pizza"]) == ("get", "http://127.0.0.1:5000/menu/pizzas")
def test_menu_by_category_drinks(): assert s.menu_helper(["drink"]) == ("get", "http://127.0.0.1:5000/menu/drinks")
def get_cluster_node_properties(debug=False): '''parse pbsnodes -a to get node properties''' logger = getMyLogger(os.path.basename(__file__)) if debug: logger.setLevel(logging.DEBUG) s = Shell(debug=False) ## get scale factor for node speed cmd = 'cluster-torqueconfig | grep NODECFG | grep SPEED | awk "{print $1 $2}"' rc, output, m = s.cmd1(cmd, allowed_exit=[0,255], timeout=300) speeds = {} re_node_speed = re.compile('^NODECFG\[(.*)\]\s+SPEED=(\S+)$') if rc == 0: for l in output.split('\n'): l = l.strip() m = re_node_speed.match(l) if m: speeds[m.group(1)] = float(m.group(2)) ## get node information nodes = [] cmd = 'pbsnodes -a' s = Shell(debug=False) rc, output, m = s.cmd1(cmd, allowed_exit=[0,255], timeout=300) if rc != 0: logger.error('command %s return non-exit code: %d' % (cmd, rc)) else: re_host = re.compile('^(\S+)$') re_stat = re.compile('^\s+state\s+\=\s+(\S+)$') re_np = re.compile('^\s+np\s+\=\s+(\d+)$') re_prop = re.compile('^\s+properties\s+\=\s+(\S+)$') re_mem = re.compile('^ram(\d+)gb$') re_net = re.compile('^network(\S+)$') output = output.split('\n') n = None for l in output: l = l.rstrip() m = re_host.match(l) if m: n = Node(host = m.group(1), # hostname stat = 'free', # state ncores = 1, # ncores ncores_idle = 1, # ncores idling ncores_inter = 0, # ncores running interactive jobs ncores_matlab = 0, # ncores running batch-mode matlab jobs ncores_vgl = 0, # ncores running vgl jobs ncores_batch = 0, # ncores running batch jobs cpu_type = '', # CPU type cpu_speed = 1.0, # CPU speed scale mem = 1, # memory total memleft = 1, # memory left memleft_c = 1, # avg. memory left per core net = '', # network connectivity interactive = False, # node allowing interactive jobs matlab = False, # node allowing matlab batch jobs vgl = False, # node allowing VirtualGL jobs batch = False, # node allowing batch jobs props = []) # other queue properties continue m = re_stat.match(l) if m: n.stat = m.group(1) continue m = re_np.match(l) if m: n.ncores = int(m.group(1)) n.ncores_idle = n.ncores continue m = re_prop.match(l) if m: data = m.group(1).split(',') ## TODO: find a better way to get CPU type n.cpu_type = ' '.join(data[0:2]) ## try to get the CPU speed factor if available try: n.cpu_speed = speeds[n.host] except KeyError, e: pass for d in data[2:]: mm = re_mem.match(d) if mm: n.mem = int( mm.group(1) ) n.memleft = n.mem continue mm = re_net.match(d) if mm: n.net = mm.group(1) continue n.props.append(d) ## update job type support according to node properties n.interactive = 'interactive' in n.props n.matlab = 'matlab' in n.props n.vgl = 'vgl' in n.props n.batch = 'batch' in n.props continue if l == '': if n not in nodes: ## avoid duplicat node entry n.memleft_c = float( n.mem / n.ncores ) nodes.append( n ) continue
def get_qstat_jobs(s_cmd, node_domain_suffix='dccn.nl', debug=False): '''run cluster-qstat to get all job status and convert the output into job info dictionary''' def __proc_walltime__(mytime): '''convert walltime to sum of minutes''' minutes = int(mytime.split(':')[0]) * 60 + int(mytime.split(':')[1]) return minutes logger = getMyLogger(os.path.basename(__file__)) if debug: logger.setLevel(logging.DEBUG) jlist = {} s = Shell(debug=False) rc, output, m = s.cmd1(s_cmd, allowed_exit=[0,255], timeout=300) re_jinfo = re.compile ( '^(\S+)\s+' + # job id '(\w+)\s+' + # user id '(\w+)\s+' + # queue name '(\S+)\s+' + # job name '([-,\d]+)\s+' + # session id '([-,\d]+)\s+' + # NDS '([-,\d,\S+]+)\s+' + # TSK '(\d+)gb\s+' + # requested physical memory '(\d+:\d+:\d+)\s+' + # requested wall-clock time '([A-Z]+)\s+' + # job status (expecting Q,R,C,H,E only) '(\d+:\d+:\d+|-{2,})\s+' + # wall-clock time consumption '(.*)$' ) # computer node and session #'((((dccn-c\d+)/(\d+\+?))|-{2,}){1,})$' ) # computer node and session if rc != 0: logger.error('command %s return non-exit code: %d' % (s_cmd, rc)) else: def __apply_domain_suffix__(node_hostname): host = node_hostname.split('/')[0] if host != '--': host += '.' + node_domain_suffix return host for l in output.split('\n'): l = l.strip() m = re_jinfo.match(l) if m: nodelist = [''] if m.group(12) != '==': nodelist = map( lambda x:__apply_domain_suffix__(x), m.group(12).split('+')) j = Job( jid = m.group(1) , uid = m.group(2) , queue = m.group(3) , jname = m.group(4) , sid = m.group(5) , nds = m.group(6) , tsk = m.group(7) , rmem = int(m.group(8)) , rtime = __proc_walltime__(m.group(9)), jstat = m.group(10) , ctime = m.group(11) , node = nodelist ) if j.jstat not in jlist.keys(): jlist[j.jstat] = [] jlist[j.jstat].append(j) return jlist
def get_mentat_node_properties(debug=False): '''get memtat node properties (memory, ncores, network, no. active VNC sessions)''' logger = getMyLogger(os.path.basename(__file__)) if debug: logger.setLevel(logging.DEBUG) conv_mem_gb = { 'kB': 1024**2, 'mB': 1024 } s = Shell(debug=False) ## get memtat node properties ## - node name ## - number of cores ## - total memory ## - number of VNC sessions ## - top 5 processes according to CPU utilization cmd = 'cluster-ssh -m "grep processor /proc/cpuinfo | wc -l | xargs echo \'ncores: \'; grep MemTotal /proc/meminfo; ps aux | grep Xvnc | grep -v grep | wc -l | xargs echo \'VNC sessions: \'; cat /proc/loadavg | xargs echo \'Load average: \'; ps -eo pcpu,pmem,pid,user,etime,args | grep -v \'ps -eo pcpu,pmem,pid,user,etime,args\' | sort -n -k 1 -r | grep -v \'%CPU\' | head -5"' rc, output, m = s.cmd1(cmd, allowed_exit=[0,255], timeout=300) re_node_name = re.compile('^\-*\s+(\S+)\s+\-*$') re_ncores = re.compile('^ncores:\s+(\d+)$') re_memory = re.compile('^MemTotal:\s+((\d+)\s+(\S+))$') re_nxvnc = re.compile('^VNC sessions:\s+(\d+)$') re_loadavg = re.compile('^Load average:\s+([\d|\.]+)\s+([\d|\.]+)\s+([\d|\.]+)\s+([\d|/]+)\s+.*$') re_top_ps = re.compile('^[\d|\.]+\s+[\d|\.]+\s+[\d]+.*$') nodes = [] if rc not in [0,255]: logger.error('command \'%s\' return non-exit code: %d' % (cmd, rc)) else: for l in output.split('\n'): logger.debug(l) l = l.strip() m = re_node_name.match(l) if m: n = Node(host = m.group(1), ## hostname ncores = 0, ## number of CPU cores mem = 0., ## total physical memory nxvnc = 0, ## number of Xvnc session load_1m = 0, ## 1 min. load average load_5m = 0, ## 5 min. load average load_10m = 0, ## 10 min. load average total_ps = 0, ## total processes top_ps = []) ## top processes nodes.append( n ) continue m = re_ncores.match(l) if m: nodes[-1].ncores = int( m.group(1) ) continue m = re_memory.match(l) if m: nodes[-1].mem = math.ceil( float( m.group(2) ) / conv_mem_gb[ m.group(3) ] ) continue m = re_nxvnc.match(l) if m: nodes[-1].nxvnc = int( m.group(1) ) continue m = re_loadavg.match(l) if m: nodes[-1].load_1m = float( m.group(1) ) nodes[-1].load_5m = float( m.group(2) ) nodes[-1].load_10m = float( m.group(3) ) nodes[-1].total_ps = int( m.group(4).split('/')[1] ) continue m = re_top_ps.match(l) if m: nodes[-1].top_ps.append(l) continue return nodes