def ls1(all, **kwargs): """ lists running simulations in the current project """ server = VIRLServer() sim_dict = server.list_simulations() if not all: # only sims for this project dirpath = find_virl() foldername = os.path.basename(dirpath) for k in list(sim_dict): if not k.startswith(foldername): sim_dict.pop(k) sim_list_table(sim_dict)
def get_prop(prop_name): """ Gets a variable using the following order * Check for .virlrc in current directory * recurse up directory tree for .virlrc * Check environment variables * Check ~/.virlrc * Prompt user """ # check for .virlrc in current directory cwd = os.getcwd() virlrc = os.path.join(cwd, ".virlrc") prop = _get_from_file(virlrc, prop_name) if prop: return prop # search up directory tree for a .virlrc virl_dir = find_virl() if virl_dir: virlrc = os.path.join(virl_dir, ".virlrc") prop = _get_from_file(virlrc, prop_name) if prop: return prop # try environment next prop = os.getenv(prop_name, None) if prop: return prop # check for .virlrc in home directory path = os.path.expanduser("~") virlrc = os.path.join(path, ".virlrc") prop = _get_from_file(virlrc, prop_name) return prop or None