vss.py :  » Windows » pyExcelerator » pywin32-214 » pythonwin » pywin » framework » editor » 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 » pythonwin » pywin » framework » editor » vss.py
# vss.py -- Source Control using Microsoft VSS.

# Provides routines for checking files out of VSS.
#
# Uses an INI file very similar to how VB integrates with VSS - even
# as far as using the same name.

# The file must be named "Mssccprj.scc", and be in the format of
# an INI file.  This file may be in a parent directory, in which
# case the project name will be built from what is specified in the
# ini file, plus the path from the INI file to the file itself.
#
# The INI file should have a [Python] section, and a
# Project=Project Name
#  and optionally
# Database=??


import win32ui, win32api, win32con, os, string, sys

import traceback

g_iniName = "Mssccprj.scc" # Use the same INI name as VB!

g_sourceSafe = None

def FindVssProjectInfo(fullfname):
  """Looks up the file system for an INI file describing the project.
  
  Looking up the tree is for ni style packages.
  
  Returns (projectName, pathToFileName) where pathToFileName contains
  the path from the ini file to the actual file.
  """
  path, fnameonly = os.path.split(fullfname)
  origPath = path
  project = ""
  retPaths = [fnameonly]
  while not project:
    iniName = os.path.join(path, g_iniName)
    database = win32api.GetProfileVal("Python","Database", "", iniName)
    project = win32api.GetProfileVal("Python","Project", "", iniName)
    if project:
      break;
    # No valid INI file in this directory - look up a level.
    path, addpath = os.path.split(path)
    if not addpath: # Root?
      break
    retPaths.insert(0, addpath)
  if not project:
    win32ui.MessageBox("%s\r\n\r\nThis directory is not configured for Python/VSS" % origPath)
    return
  return project, "/".join(retPaths), database
    
  
def CheckoutFile(fileName):
  global g_sourceSafe
  import pythoncom
  ok = 0
  # Assumes the fileName has a complete path,
  # and that the INI file can be found in that path
  # (or a parent path if a ni style package)
  try:
    import win32com.client, win32com.client.gencache
    mod = win32com.client.gencache.EnsureModule('{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}', 0, 5, 0)
    if mod is None:
      win32ui.MessageBox("VSS does not appear to be installed.  The TypeInfo can not be created")
      return ok

    rc = FindVssProjectInfo(fileName)
    if rc is None:
      return
    project, vssFname, database = rc
    if g_sourceSafe is None:
      g_sourceSafe=win32com.client.Dispatch("SourceSafe")
      # SS seems a bit wierd.  It defaults the arguments as empty strings, but
      # then complains when they are used - so we pass "Missing"
      if not database:
        database = pythoncom.Missing
      g_sourceSafe.Open(database, pythoncom.Missing, pythoncom.Missing)
    item = g_sourceSafe.VSSItem("$/%s/%s" % (project, vssFname))
    item.Checkout(None, fileName)
    ok = 1
  except pythoncom.com_error, exc:
    win32ui.MessageBox(exc.strerror, "Error checking out file")
  except:
    typ, val, tb = sys.exc_info()
    traceback.print_exc()
    win32ui.MessageBox("%s - %s" % (str(typ), str(val)),"Error checking out file")
    tb = None # Cleanup a cycle
  return ok


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