def test_APP_JOBS(): """ jobs """ try: expected = sh.nproc() except: expected = 1 assert CFG.APP_JOBS == int(expected)
def APP_JOBS(self): """ jobs """ try: result = sh.nproc() except: result = 1 return int(result)
def build_rip(self: object) -> None: src_directory = "{0}/src".format(self.normalized_path) number_of_cores_string = sh.nproc(_tty_out=False).strip() autogen_path = "{0}/autogen.sh".format(src_directory) sh.Command(autogen_path)(_cwd=src_directory, _out=sys.stdout.buffer) configure_path = "{0}/configure".format(src_directory) sh.Command(configure_path)(_cwd=src_directory, _out=sys.stdout.buffer) sh.make("-j", number_of_cores_string, _cwd=src_directory, _out=sys.stdout.buffer) sh.sudo("-S", "make", "setuid", _in=self.sudo_password, _cwd=src_directory, _out=sys.stdout.buffer)
def get_top_stats(): nproc = int(sh.nproc('--all')) ctext = [l for l in sh.free().split('\n') if l.startswith('Mem:')][0] tkns = [t for t in ctext.split() if len(t)] mem_total, mem_used = map(int, tkns[1:3]) ctext = [l for l in sh.df().split('\n') if 'vg-root' in l][0] tkns = [t for t in ctext.split() if len(t)] hdd_used, hdd_avail = map(int, tkns[2:4]) ctext = sh.top('-b', '-n1').split('\n') lavg = float(ctext[0].split('load average:')[1].strip().split()[0][:-1]) ctext = ctext[7:] procs = [] for line in ctext: line = [t for t in line.split() if len(t)] if len(line) != 12: continue pid, uid, cpu, mem, cmd = line[0], line[1], float(line[8]), float(line[9]), line[11] if cpu < 50 and mem < 5: continue procs.append(dict(pid=pid, uid=uid, cpu=cpu, mem=mem, cmd=cmd)) return nproc, lavg, mem_total, mem_used, hdd_avail, hdd_used, procs
# Optional argument for path to Machinekit-HAL repository parser.add_argument("-p", "--path", action=helpers.PathExistsAction, dest="path", default=os.getcwd(), help="Path to root of Machinekit-HAL repository") # Optional argument for Debian host architecture parser.add_argument("-a", "--host-architecture", dest="host_architecture", action=HostArchitectureValidAction, default=sh.dpkg_architecture( "-qDEB_HOST_ARCH", _tty_out=False).strip(), metavar="ARCHITECTURE", help="Build packages for specific architecture") # Optional argument for many jobs to start parser.add_argument("-j", "--jobs", dest="jobs", action="store", type=int, metavar="PROCESSES", default=sh.nproc(_tty_out=False).strip(), help="Number of processes started at given time by the underlying buildsystem.") args = parser.parse_args() main(args)