def goto(keyword): shortcut = Shortcut.find_by_keyword(keyword) if shortcut: #posix.chdir(shortcut.path) # posix.system('eval echo cd /') # popen = subprocess.Popen('cd {0}'.format(shortcut.path), stdout=subprocess.PIPE, shell=True) # output = popen.communicate()[0] print(output) # os.environ.update(output) else: raise Exception('Keyword not found!')
def list(): shortcuts = Shortcut.all() for keyword, path in shortcuts: print("Keyword: {0}, Path: {1}".format(keyword, path))
def delete(keyword): shortcut = Shortcut.find_by_keyword(keyword) if shortcut: shortcut.delete() else: raise Exception('Keyword not found!')
def find(keyword): shortcut = Shortcut.find_by_keyword(keyword) if shortcut: return shortcut.path else: raise Exception('Keyword not found!')
def add(keyword, path): shortcut = Shortcut(keyword, path) shortcut.save()