Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 15th, 2012  |  syntax: None  |  size: 1.43 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. msbuild fails and returns 1 when when I assign stdout and stdout to os.devnull, returns 0 otherwise
  2. from subprocess import call
  3. import os
  4. import tempfile
  5. import sys
  6.  
  7.  
  8. def main():
  9.  
  10.     temp_repo_name = 'temprepo'
  11.     d = tempfile.mkdtemp()
  12.     os.chdir(os.path.normpath(d))
  13.  
  14.     command1 = ['hg', 'clone', r'C:temp1jxg_hcr', temp_repo_name]
  15.  
  16.     devnull = open(os.devnull,'w')
  17.  
  18.     rc1 = call(command1,stdout=devnull, stderr=devnull)
  19.  
  20.     if rc1 != 0:
  21.         print('could not clone repo into temporary directory.  Terminating Program')
  22.         sys.exit(1)
  23.  
  24.     devnull.close()
  25.  
  26.     devnull = open(os.devnull,'w')
  27.  
  28.     os.chdir(temp_repo_name)
  29.  
  30.     command2 = [r'msbuild', r'hcr_dll.sln', r'/t:Rebuild',r'/p:Configuration=Release']
  31.     rc2 = call(command2,stdout=devnull, stderr=devnull)
  32.  
  33.     print rc2
  34.     if rc2 != 0:
  35.         print('could not build repo.  Terminating Program')
  36.         sys.exit(1)
  37.  
  38.     devnull.close()
  39.  
  40. if __name__ == '__main__':
  41.     main()
  42.        
  43. C:programmingeclipse_workspacehcr_cli_build>python hcr_cli_build.py
  44. 0
  45. 1
  46. could not build repo.  Terminating Program
  47.        
  48. rc2 = call(command2)
  49.        
  50. 0
  51. <bunch of build output>
  52. 0
  53.        
  54. #!/bin/bash
  55. for i in 1 2 3 4
  56.  do
  57.   echo "doing $i"
  58.   msbuild.exe /c/temp/$i/jxg_hcr/hcr_dll.sln //t:Rebuild //p:Configuration=Release
  59.   echo $?
  60.  done
  61.        
  62. #!/bin/bash
  63. for i in 1 2 3 4
  64.  do
  65.   echo "doing $i"
  66.   msbuild.exe /c/temp/$i/jxg_hcr/hcr_dll.sln //t:Rebuild //p:Configuration=Release > /dev/null
  67.   echo $?
  68.  done