示例#1
0
文件: main.py 项目: Artie18/goto
 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!')
示例#2
0
文件: main.py 项目: Artie18/goto
 def list():
     shortcuts = Shortcut.all()
     for keyword, path in shortcuts:
         print("Keyword: {0}, Path: {1}".format(keyword, path))
示例#3
0
文件: main.py 项目: Artie18/goto
 def delete(keyword):
     shortcut = Shortcut.find_by_keyword(keyword)
     if shortcut:
         shortcut.delete()
     else:
         raise Exception('Keyword not found!')
示例#4
0
文件: main.py 项目: Artie18/goto
 def find(keyword):
     shortcut = Shortcut.find_by_keyword(keyword)
     if shortcut:
         return shortcut.path
     else:
         raise Exception('Keyword not found!')
示例#5
0
文件: main.py 项目: Artie18/goto
 def add(keyword, path):
     shortcut = Shortcut(keyword, path)
     shortcut.save()