You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
805 B

  1. import subprocess
  2. from binaryornot.check import is_binary
  3. import os
  4. EDITOR_PATH =
  5. def edit(path,params=[]):
  6. call_chain = [EDITOR_PATH] + params
  7. if not is_binary(path):
  8. call_chain.append(path)
  9. subprocess.call(call_chain)
  10. def standalone(path,params=[],windowless =False,cwd = None):
  11. path2windowless = os.path.join(os.path.dirname(__file__),'windowless.vbs')
  12. params = list(map(os.path.expandvars,params))
  13. if not cwd:
  14. cwd = os.path.dirname(path)
  15. else:
  16. cwd = os.path.expandvars(cwd)
  17. if windowless:
  18. cmd = ' '.join('~{}~'.format(arg) if ' ' in arg else arg for arg in [fullpath]+params)
  19. print(cmd)
  20. subprocess.check_output(["cscript.exe",path2windowless,cmd,cwd])
  21. else:
  22. subprocess.Popen([fullpath]+params,cwd=cwd)