def ipython_qstat(self, arg): """ Prints jobs of current user. """ from subprocess import Popen, PIPE from IPython.utils.text import SList # get user jobs ids jobs = SList(Popen(['qstat', '-f'], stdout=PIPE).communicate()[0].split('\n')) names = [u[u.find('=')+1:].lstrip().rstrip() for u in jobs.grep('Job_Name')] mpps = [int(u[u.find('=')+1:]) for u in jobs.grep('Resource_List.ncpus')] states = [u[u.find('=')+1:].lstrip().rstrip() for u in jobs.grep('job_state')] ids = [u[u.find(':')+1:].lstrip().rstrip() for u in jobs.grep('Job Id')] return SList([ "{0:>10} {1:>4} {2:>3} -- {3}".format(id, mpp, state, name) \ for id, mpp, state, name in zip(ids, mpps, states, names)])
def ipython_qstat(self, arg): """ Prints jobs of current user. """ from subprocess import Popen, PIPE from IPython.utils.text import SList # get user jobs ids jobs = SList(Popen(["qstat", "-f"], stdout=PIPE).communicate()[0].split("\n")) names = [u[u.find("=") + 1 :].lstrip().rstrip() for u in jobs.grep("Job_Name")] mpps = [int(u[u.find("=") + 1 :]) for u in jobs.grep("Resource_List.ncpus")] states = [u[u.find("=") + 1 :].lstrip().rstrip() for u in jobs.grep("job_state")] ids = [u[u.find(":") + 1 :].lstrip().rstrip() for u in jobs.grep("Job Id")] return SList( [ "{0:>10} {1:>4} {2:>3} -- {3}".format(id, mpp, state, name) for id, mpp, state, name in zip(ids, mpps, states, names) ] )
def ipython_qstat(self, arg): """ squeue --user=`whoami` -o "%7i %.3C %3t -- %50j" """ from subprocess import Popen, PIPE from IPython.utils.text import SList from getpass import getuser # finds user name. whoami = getuser() squeue = Popen(["squeue", "--user="******"-o", "\"%7i %.3C %3t %j\""], stdout=PIPE) result = squeue.stdout.read().rstrip().split('\n') result = SList([u[1:-1] for u in result[1:]]) return result.grep(str(arg[1:-1]))
def ipython_qstat(self, arg): """ squeue --user=`whoami` -o "%7i %.3C %3t -- %50j" """ from subprocess import Popen, PIPE from IPython.utils.text import SList from getpass import getuser # finds user name. whoami = getuser() squeue = Popen( ["squeue", "--user="******"-o", "\"%7i %.3C %3t %j\""], stdout=PIPE) result = squeue.stdout.read().rstrip().split('\n') result = SList([u[1:-1] for u in result[1:]]) return result.grep(str(arg[1:-1]))
def ipython_qstat(self, arg): """ squeue --user=`whoami` -o "%7i %.3C %3t -- %50j" """ from six import PY3 from subprocess import Popen, PIPE from IPython.utils.text import SList from getpass import getuser whoami = getuser() squeue = Popen(["squeue", "--user="******"-o", "\"%7i %.3C %3t %j\""], stdout=PIPE) result = squeue.stdout.read().rstrip().splitlines() if PY3: result = SList([u[1:-1].decode("utf-8") for u in result[1:]]) else: result = SList([u[1:-1] for u in result[1:]]) return result if str(arg) == '' else result.grep(str(arg[1:-1]))
def ipython_qstat(self, arg): """ squeue --user=`whoami` -o "%7i %.3C %3t -- %50j" """ from six import PY3 from subprocess import Popen, PIPE from IPython.utils.text import SList from getpass import getuser whoami = getuser() squeue = Popen( ["squeue", "--user="******"-o", "\"%7i %.3C %3t %j\""], stdout=PIPE) result = squeue.stdout.read().rstrip().splitlines() if PY3: result = SList([u[1:-1].decode("utf-8") for u in result[1:]]) else: result = SList([u[1:-1] for u in result[1:]]) return result if str(arg) == '' else result.grep(str(arg[1:-1]))