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

make_distrib.py

By: dpasca on May 7th, 2012  |  syntax: Python  |  size: 1.56 KB  |  hits: 38  |  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. #!/usr/bin/env python
  2.  
  3. import os, shutil, glob
  4. import datetime
  5.  
  6. #=======================================================
  7. def copyDir( destPath, dirName, pattern="*" ) :
  8.  
  9.         destPath2 = destPath
  10.  
  11.         if False == os.path.exists( destPath2 ) :
  12.                 os.mkdir( destPath2 )
  13.  
  14.         for f in glob.glob( dirName + "/" + pattern ):
  15.                 shutil.copy( f, destPath2 )  
  16.  
  17.         return
  18.  
  19. #=======================================================
  20. class TempDir:
  21.         def __init__(self,name) :
  22.                 self.name = name
  23.  
  24.                 if False == os.path.exists( name ) :
  25.                         os.mkdir( name )
  26.  
  27.         def __del__(self) :
  28.                 shutil.rmtree( self.name )
  29.  
  30.  
  31. #=======================================================
  32. now = datetime.datetime.now()
  33.  
  34. destPath = "FinalFreeway2R_PressKit"
  35. destPathDir = TempDir( destPath )
  36.  
  37. copyDir( destPath, "source", "*.png" )
  38. copyDir( destPath, "source", "*.jpg" )
  39. copyDir( destPath, "source", "*.txt" )
  40. copyDir( destPath, "../app_store/sshots", "*960*" )
  41.  
  42. docBaseName = "FinalFreeway2R_PressRel"
  43.  
  44. tmpDocsDir = TempDir( 'tmpdocs' )
  45.  
  46. os.system(\
  47.         'python rst2latex.py source/' + docBaseName + '.txt ' +\
  48.         'tmpdocs/' + docBaseName + '.tex ' + \
  49.         '--latex-preamble="\usepackage{geometry} \geometry{hmargin={2.5cm,2.5cm},height=10in} \usepackage{parskip}" --font-encoding=""')
  50.  
  51. os.system(\
  52.         'pdflatex -aux-directory="tmpdocs" -include-directory="source" -output-directory="' + destPath + '" ' +\
  53.         'tmpdocs/' + docBaseName + '.tex' )
  54.  
  55.  
  56. archiveName = destPath # + "_" + now.strftime("%Y.%m.%d")
  57. #now.strftime("%Y.%m.%d_%H.%M")
  58.  
  59. shutil.make_archive( archiveName, "zip", ".", destPath )