home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Shareware / Comunicatii / jyte / jyte.exe / BrandProject.py < prev    next >
Text File  |  2000-03-08  |  3KB  |  82 lines

  1. # BrandProject.py
  2. #
  3. # Brand a VSS project with a "build number", then optionally
  4. # stamp DLL/EXE files with version information.
  5.  
  6. import win32api, os, string, sys
  7. import vssutil
  8. import bulkstamp
  9.  
  10.  
  11. def BrandProject(vssProjectName, descFile, stampPath, filesToSubstitute, buildDesc = None, auto=0, bRebrand = 0):
  12.     # vssProjectName -- The name of the VSS project to brand.
  13.     # descFile -- A test file containing descriptions of the files in the release.
  14.     # stampPath -- The full path to where the files referenced in descFile can be found.
  15.     path=win32api.GetFullPathName(stampPath)
  16.     
  17.     build = vssutil.MakeNewBuildNo(vssProjectName, buildDesc, auto, bRebrand)
  18.     if build is None:
  19.         print "Cancelled"
  20.         return
  21.  
  22.     bulkstamp.scan( build, stampPath, descFile )
  23.     for infile, outfile in filesToSubstitute:
  24.         SubstituteVSSInFile(vssProjectName, infile, outfile)
  25.     return 1
  26.  
  27. def usage(msg):
  28.     print msg
  29.     print """\
  30. %s Usage:
  31. %s [options] vssProject descFile stampPath
  32.  
  33. Automatically brand a VSS project with an automatically incremented
  34. build number, and stamp DLL/EXE files with the build number.
  35.  
  36. Checks that no files are checked out in the project, and finds the last
  37. build number, and suggests the next number.
  38.  
  39. Options:
  40. -a     - Auto increment the build number, and brand (otherwise prompt
  41.          for the build number after looking for the previous)
  42. -r     - Restamp the files with the existing build number.
  43. -d     - A description for the VSS Label.
  44. -f infile=outfile - Substitute special VSS labels in the specified text
  45.                     file with the text extracted from VSS.
  46. """ % (os.path.basename(sys.argv[0]), os.path.basename(sys.argv[0]))
  47.     sys.exit(1)
  48.  
  49. if __name__=='__main__':
  50.     try:
  51.         import getopt
  52.         opts, args = getopt.getopt(sys.argv[1:], "af:d:r")
  53.     except getopts.error, msg:
  54.         usage(msg)
  55.     bAuto = bRebrand = 0
  56.     stampFiles = []
  57.     desc = None
  58.     for opt, val in opts:
  59.         if opt == '-a':
  60.             bAuto = 1
  61.         if opt == '-f':
  62.             infile, outfile = string.split(val, "=", 2)
  63.             stampFiles.append((infile, outfile))
  64.         if opt == '-d':
  65.             desc = val
  66.         if opt == '-r':
  67.             bRebrand = 1
  68.     if len(args)<3:
  69.         usage("You must specify the required arguments")
  70.     vssProjectName = "$\\" + args[0]
  71.     descFile = args[1]
  72.     path = args[2]
  73.     try:
  74.         os.stat(descFile)
  75.     except IOError:
  76.         usage("The description file '%s' can not be found" % (descFile))
  77.     if not os.path.isdir(path):
  78.         usage("The path to the files to stamp '%s' does not exist" % (path))
  79.  
  80.     BrandProject(vssProjectName, descFile, path, stampFiles, desc, bAuto, bRebrand)
  81.  
  82.