def get_qstat_as_df():
"""Get the current users output of qstat as a DataFrame.
"""
user = os.environ.get("USER")
try:
ret = subprocess.Popen(
["qstat", "-u", str(user)],
stdout=subprocess.PIPE,
)
df = pd.read_csv(ret.stdout, delimiter="\s+")
# drop the first line since it is just one long line
df = df.drop(df.index[0]).copy()
# convert objects to numeric otherwise numbers are strings
df["JOBID"] = pd.to_numeric(df["job-ID"], errors='coerce')
# df.set_index("JOBID")
df = df.drop('job-ID', 1)
except ValueError:
logger.exception("No jobs in queues for user {}".format(user))
df = pd.DataFrame()
return df
评论列表
文章目录