#NEWLINE# def RunPyCmd( cmd_py , arg_list = None ) : #NEWLINE# #INDENT# 'Helper to run cmd utilities.\n\n  Args:\n    cmd_py: String of cmd to run e.g. report_users_csv.py.\n    arg_list: List of string args to add to the command line.\n\n  Raises:\n    AdminAPIToolCmdError: if the executed command returns nonzero or the\n                           command cannot be found.\n  ' #NEWLINE# cmd_py = os . path . join ( setup_path . APP_BASE_PATH , 'cmds' , cmd_py ) #NEWLINE# if ( not os . path . isfile ( cmd_py ) ) : #NEWLINE# #INDENT# raise admin_api_tool_errors . AdminAPIToolCmdError ( ( 'Cannot find %s' % cmd_py ) ) #NEWLINE# #UNINDENT# cmd = [ 'python' , cmd_py ] #NEWLINE# if arg_list : #NEWLINE# #INDENT# cmd += arg_list #NEWLINE# #UNINDENT# log_utils . LogDebug ( ' ' . join ( cmd ) ) #NEWLINE# return_code = subprocess . call ( cmd ) #NEWLINE# if return_code : #NEWLINE# #INDENT# raise admin_api_tool_errors . AdminAPIToolCmdError ( ( 'Execution failed (%d).\n\t%s' % ( return_code , ' ' . join ( cmd ) ) ) )