Advertisement
Guest User

Untitled

a guest
Jun 6th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None | 0 0
  1. # -*- mode: Python; -*-
  2. import os, platform, subprocess, re, time, ConfigParser, shutil, sys, signal, fileinput
  3.  
  4. MYAPP_VER_MAJOR = '0'
  5. MYAPP_VER_MINOR = '01'
  6. MYAPP_VER_COMPILATION = '0'
  7. MYAPP_VER_INSTALL = '1'
  8.  
  9. #odczytuje wersje kompilacji z wersji repozytorium
  10. ver_repository = subprocess.Popen('hg sum', shell=True, stdout=subprocess.PIPE).communicate()[0]
  11. try:
  12. MYAPP_VER_COMPILATION = re.search('(?<=parent: )\d+', ver_repository).group()
  13. except BaseException:
  14. pass
  15.  
  16. MYAPP_VER_STRING = str(MYAPP_VER_MAJOR) + '.' + str(MYAPP_VER_MINOR) + '.' + MYAPP_VER_COMPILATION
  17.  
  18. #web
  19. WWW_BROWSER_WINDOWS='firefox'
  20. WWW_BROWSER_LINUX='firefox'
  21. WEB_SRV_PREFIX = 'srvmyapp'
  22. WEB_SRV_HOST = '127.0.0.1'
  23. WEB_SRV_PORT = '50007'
  24. WEB_CLIENT_HOST = '127.0.0.1'
  25. WEB_CLIENT_PORT = '9000'
  26.  
  27. #database
  28. DB_NAME='mydb'
  29. DB_USER='mydb'
  30. DB_PASSWORD='mydb'
  31.  
  32. Export('MYAPP_VER_MAJOR MYAPP_VER_MINOR MYAPP_VER_COMPILATION MYAPP_VER_INSTALL')
  33. Export('WWW_BROWSER_WINDOWS WWW_BROWSER_LINUX')
  34. Export('WEB_SRV_PREFIX WEB_SRV_HOST WEB_SRV_PORT WEB_CLIENT_HOST WEB_CLIENT_PORT')
  35. Export('DB_NAME DB_USER DB_PASSWORD')
  36.  
  37. vars = Variables('custom.py')
  38. vars.Add(EnumVariable('r','Run the application, l: local lighttpd at \''+ WEB_CLIENT_HOST + ':' + WEB_CLIENT_PORT +'\''\
  39. ', d: django internal at \''+ WEB_CLIENT_HOST + ':' + WEB_CLIENT_PORT +'\'',
  40. 'no', allowed_values = ('l', 'd', 'no'), map={}, ignorecase=2) )
  41. vars.Add(EnumVariable('t','Run the unit tests, \'w\' Python web, \'j\' Javascript client, \'c\' C++ library ',
  42. 'no', allowed_values = ('w', 'j', 'c', 'no'), map={}, ignorecase=2) )
  43. vars.Add(BoolVariable('cov','Set to 1 to run the coverage reports for python server',0) )
  44. vars.Add(BoolVariable('syncdb','Set to 1 to clean application files and recreate tables in database',0) )
  45. vars.Add(BoolVariable('zip','Set to 1 to build zip package',0) )
  46. vars.Add(BoolVariable('doxygen', 'Set 1 to generate documentation. The file Doxyfile_in is required',0) )
  47. additional_help_text = ""
  48.  
  49. env = Environment(variables=vars)
  50.  
  51. Help("""
  52. type 'scons' to build the program and libraries. Settings specific for this project are listed below.
  53. """
  54. +
  55. vars.GenerateHelpText(env)
  56. +
  57. additional_help_text)
  58.  
  59. if (platform.system() == "Linux"):
  60. WWW_BROWSER = WWW_BROWSER_LINUX
  61. BROWSER_CMD = WWW_BROWSER_LINUX + ' http://' + WEB_CLIENT_HOST + ':' + WEB_CLIENT_PORT + ' &'
  62. else:
  63. WWW_BROWSER = WWW_BROWSER_WINDOWS
  64. BROWSER_CMD = 'start "" ' + WWW_BROWSER_WINDOWS + ' http://' + WEB_CLIENT_HOST + ':' + WEB_CLIENT_PORT
  65.  
  66. def addToLD(path):
  67. if "LD_LIBRARY_PATH" in os.environ:
  68. os.environ["LD_LIBRARY_PATH"]= os.environ["LD_LIBRARY_PATH"] + ':' + os.path.abspath(path)
  69. else:
  70. os.environ["LD_LIBRARY_PATH"]= os.path.abspath(path)
  71.  
  72. if env['r'] == 'l':
  73. os.system(BROWSER_CMD)
  74. os.system('lighttpd -f client/lighttpd.develop')
  75. os.system('python build/manage.py runfcgi daemonize=false method=threaded host=' + WEB_SRV_HOST + ' port=' + WEB_SRV_PORT)
  76. if (platform.system() == "Linux"):
  77. os.system('kill `cat client/lighttpd.pid`')
  78. else:
  79. os.system('taskkill /F /T /IM lighttpd.exe')
  80. elif env['r'] == 'd':
  81. os.system(BROWSER_CMD)
  82. os.system('python build/manage.py runserver ' + WEB_CLIENT_HOST + ':' + WEB_CLIENT_PORT)
  83. elif env['t'] == 'w':
  84. if(platform.system() == "Linux"):
  85. os.system('python build/manage.py test version current draughtzpy')
  86. pass
  87. elif env['t'] == 'j':
  88. child_process = subprocess.Popen('python client/tests/srv.py ', shell=True, stdout=subprocess.PIPE)
  89. os.system( WWW_BROWSER + ' ' + os.getcwd() + ' client/unit_test_out.html --disable-web-security')
  90. if(platform.system() == "Linux"):
  91. os.system("kill " + str(child_process.pid))
  92. else:
  93. os.system('taskkill /F /T /PID %d' % child_process.pid)
  94. elif env['cov'] == 1:
  95. if(platform.system() == "Linux"):
  96. os.system("coverage run --source build/ build/manage.py test version current draughtzpy")
  97. print("\n")
  98. os.system("coverage report -m")
  99. print("\n")
  100. elif env['t'] == 'c':
  101. if(platform.system() == "Linux"):
  102. addToLD('./draughtz')
  103. os.system('draughtz/draughtz_test')
  104. elif(platform.system() == "Windows"):
  105. os.system('draughtz\draughtz_test.exe')
  106.  
  107. elif env['syncdb'] == 1:
  108. os.system('python build/manage.py syncdb')
  109. elif env['zip'] == 1:
  110. dir_name = os.path.split(os.getcwd())[-1]
  111. package_name = 'bioweb_' + MYAPP_VER_STRING + '_' + MYAPP_VER_INSTALL + '_' + str(dir_name)
  112. os.system('zip ' + package_name + '.zip * -r -x client/bower_components/\*')
  113. elif env['doxygen'] == 1:
  114. f = open('Doxyfile_in', "r")
  115. w = open('Doxyfile', "w")
  116. for line in f:
  117. m = re.match(r'^PROJECT_NUMBER.*$', line)
  118. if m:
  119. w.write('PROJECT_NUMBER = ' + MYAPP_VER_STRING + '\n')
  120. else:
  121. w.write(line)
  122. os.system('doxygen')
  123. env.SideEffect('Doxygen', 'Doxygen_in')
  124. else: #build app
  125. SConscript(['draughtz/SConscript', 'web/SConscript', 'client/SConscript'], exports=['env'] )
  126.  
  127. env.Clean('.','../doc/doxygen')
  128. env.Clean('.','Doxyfile')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement