Changeset bf48c8a in flex_extract.git for source/python/mods/tools.py
- Timestamp:
- Dec 14, 2018, 11:27:42 AM (5 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 1eca806
- Parents:
- 524ac32
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/mods/tools.py
r9aefaad rbf48c8a 743 743 744 744 return (ix, jy, it) 745 746 747 def execute_subprocess(cmd_list, error_msg='SUBPROCESS FAILED!'): 748 '''Executes a command line instruction via a subprocess. 749 750 Error handling is done if an error occures. 751 752 Parameters 753 ---------- 754 cmd_list : :obj:`list` of `:obj:`string` 755 A list of the components for the command line execution. Each 756 list entry is a single part of the command which is seperated from 757 the rest by a blank space. 758 E.g. ['mv', file1, file2] 759 760 Return 761 ------ 762 error_msg : :obj:`string`, optional 763 The possible error message if the subprocess failed. 764 By default it will just tell "SUBPROCESS FAILED!". 765 ''' 766 767 try: 768 subprocess.check_call(cmd_list) 769 except subprocess.CalledProcessError as e: 770 print('... ERROR CODE: ' + str(e.returncode)) 771 print('... ERROR MESSAGE:\n \t ' + str(e)) 772 773 sys.exit('... ' + error_msg) 774 except OSError as e: 775 print('... ERROR CODE: ' + str(e.errno)) 776 print('... ERROR MESSAGE:\n \t ' + str(e.strerror)) 777 778 sys.exit('... ' + error_msg) 779 780 return
Note: See TracChangeset
for help on using the changeset viewer.