command.py 498 B

12345678910111213141516171819202122
  1. # -*- coding: utf-8 -*-
  2. from subprocess import check_output, STDOUT
  3. def list_files_and_folders(path, hiddens=True):
  4. output = check_output(['ls', '-a', path], stderr=STDOUT)
  5. items = []
  6. for item in output.split('\n'):
  7. if item == '' or item == '.' or item == '..':
  8. continue
  9. if not hiddens and item.startswith('.'):
  10. continue
  11. items.append(item)
  12. return items
  13. def execute(command=[]):
  14. return check_output(command, stderr=STDOUT)