| OLD | NEW |
| 1 import os | 1 import os |
| 2 import subprocess | 2 import subprocess |
| 3 import sys | 3 import sys |
| 4 | 4 |
| 5 def shellcmd(command, echo=True): | 5 def shellcmd(command, echo=True): |
| 6 if not isinstance(command, str): | 6 if not isinstance(command, str): |
| 7 command = ' '.join(command) | 7 command = ' '.join(command) |
| 8 | 8 |
| 9 if echo: print '[cmd]', command | 9 if echo: |
| 10 print >> sys.stderr, '[cmd]' |
| 11 print >> sys.stderr, command |
| 12 print >> sys.stderr |
| 10 | 13 |
| 11 stdout_result = subprocess.check_output(command, shell=True) | 14 stdout_result = subprocess.check_output(command, shell=True) |
| 12 if echo: sys.stdout.write(stdout_result) | 15 if echo: sys.stdout.write(stdout_result) |
| 13 return stdout_result | 16 return stdout_result |
| 14 | 17 |
| 15 def FindBaseNaCl(): | 18 def FindBaseNaCl(): |
| 16 """Find the base native_client/ directory.""" | 19 """Find the base native_client/ directory.""" |
| 17 nacl = 'native_client' | 20 nacl = 'native_client' |
| 18 path_list = os.getcwd().split(os.sep) | 21 path_list = os.getcwd().split(os.sep) |
| 19 """Use the executable path if cwd does not contain 'native_client' """ | 22 """Use the executable path if cwd does not contain 'native_client' """ |
| 20 path_list = path_list if nacl in path_list else sys.argv[0].split(os.sep) | 23 path_list = path_list if nacl in path_list else sys.argv[0].split(os.sep) |
| 21 if nacl not in path_list: | 24 if nacl not in path_list: |
| 22 print "Script must be executed from within 'native_client' directory" | 25 print "Script must be executed from within 'native_client' directory" |
| 23 exit(1) | 26 exit(1) |
| 24 last_index = len(path_list) - path_list[::-1].index(nacl) | 27 last_index = len(path_list) - path_list[::-1].index(nacl) |
| 25 return os.sep.join(path_list[:last_index]) | 28 return os.sep.join(path_list[:last_index]) |
| 26 | 29 |
| 27 def get_sfi_string(args, sb_ret, nonsfi_ret, native_ret): | 30 def get_sfi_string(args, sb_ret, nonsfi_ret, native_ret): |
| 28 """Return a value depending on args.sandbox and args.nonsfi.""" | 31 """Return a value depending on args.sandbox and args.nonsfi.""" |
| 29 if args.sandbox: | 32 if args.sandbox: |
| 30 assert(not args.nonsfi) | 33 assert(not args.nonsfi) |
| 31 return sb_ret | 34 return sb_ret |
| 32 if args.nonsfi: | 35 if args.nonsfi: |
| 33 return nonsfi_ret | 36 return nonsfi_ret |
| 34 return native_ret | 37 return native_ret |
| OLD | NEW |