BrandProject.py :  » Windows » pyExcelerator » pywin32-214 » win32 » scripts » VersionStamp » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Windows » pyExcelerator 
pyExcelerator » pywin32 214 » win32 » scripts » VersionStamp » BrandProject.py
# BrandProject.py
#
# Brand a VSS project with a "build number", then optionally
# stamp DLL/EXE files with version information.

import win32api, os, string, sys
import vssutil
import bulkstamp


def BrandProject(vssProjectName, descFile, stampPath, filesToSubstitute, buildDesc = None, auto=0, bRebrand = 0):
  # vssProjectName -- The name of the VSS project to brand.
  # descFile -- A test file containing descriptions of the files in the release.
  # stampPath -- The full path to where the files referenced in descFile can be found.
  path=win32api.GetFullPathName(stampPath)
  
  build = vssutil.MakeNewBuildNo(vssProjectName, buildDesc, auto, bRebrand)
  if build is None:
    print "Cancelled"
    return

  bulkstamp.scan( build, stampPath, descFile )
  for infile, outfile in filesToSubstitute:
    SubstituteVSSInFile(vssProjectName, infile, outfile)
  return 1

def usage(msg):
  print msg
  print """\
%s Usage:
%s [options] vssProject descFile stampPath

Automatically brand a VSS project with an automatically incremented
build number, and stamp DLL/EXE files with the build number.

Checks that no files are checked out in the project, and finds the last
build number, and suggests the next number.

Options:
-a     - Auto increment the build number, and brand (otherwise prompt
         for the build number after looking for the previous)
-r     - Restamp the files with the existing build number.
-d     - A description for the VSS Label.
-f infile=outfile - Substitute special VSS labels in the specified text
                    file with the text extracted from VSS.
""" % (os.path.basename(sys.argv[0]), os.path.basename(sys.argv[0]))
  sys.exit(1)

if __name__=='__main__':
  try:
    import getopt
    opts, args = getopt.getopt(sys.argv[1:], "af:d:r")
  except getopts.error, msg:
    usage(msg)
  bAuto = bRebrand = 0
  stampFiles = []
  desc = None
  for opt, val in opts:
    if opt == '-a':
      bAuto = 1
    if opt == '-f':
      infile, outfile = string.split(val, "=", 2)
      stampFiles.append((infile, outfile))
    if opt == '-d':
      desc = val
    if opt == '-r':
      bRebrand = 1
  if len(args)<3:
    usage("You must specify the required arguments")
  vssProjectName = "$\\" + args[0]
  descFile = args[1]
  path = args[2]
  try:
    os.stat(descFile)
  except IOError:
    usage("The description file '%s' can not be found" % (descFile))
  if not os.path.isdir(path):
    usage("The path to the files to stamp '%s' does not exist" % (path))

  BrandProject(vssProjectName, descFile, path, stampFiles, desc, bAuto, bRebrand)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.