command.py 587 B

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