""" $Id: //guest/jeffery_g_smith/perforce/utils/sttop4/python/params.py#1 $ StarTeam to Perforce Converter, Parameter module Copyright 1998 Perforce Software. All rights reserved. Based on VSStoP4: Written by James Strickland, April 1998 Maintained by Robert Cowham, since 2000 Updated to support StarTeam conversions and converted to Python: Jeffery G. Smith, MedPlus, Inc. 2004-2005 """ __revision__ = '$Id: //guest/jeffery_g_smith/perforce/utils/sttop4/python/params.py#1 $' __metaclass__ = type import sys import os import re import datetime from win32con import * from win32api import * minpyver = (2, 4, 0) if sys.version_info[:3] < minpyver: raise 'Minum Python version ' + str(minpyver) + ' required, found ' + str(sys.version_info) """ This is a list of the parameters which can be set in the INI file along with their default values. If a value is required, the default value should be set to 'required_but_not_set' """ parameters = { 'source' : { # Pre-conversion server info 'type': 'required_but_not_set', 'server': 'required_but_not_set', 'port': 'required_but_not_set', 'user': 'required_but_not_set', 'passwd': 'required_but_not_set', 'progid': 'required_but_not_set', 'projects': 'required_but_not_set', 'exclude': ''}, 'perforce': { # Perforce server info 'p4port': 'required_but_not_set', 'p4user': 'required_but_not_set', 'p4client': 'required_but_not_set', 'p4passwd': '', 'depot': 'depot', 'root': 'main'}, 'conversion': { # Basic conversion definitions 'root': os.curdir, 'logfile': 'convert.log', 'confirm': 1, 'debug': 0, 'lcpaths': 0, 'lcfiles': 0, 'lcextensions': 0, 'lcusers': 0, 'verify': 0}, 'labels': { # Label conversion definitions 'prefix': '', 'usecase': 0, 'ignore': ''}, 'changelists': { # Changelist import definitions 'start': '', 'interval': 600} } class Converter: def __init__(self, ini_file): self._parameters = dict() self._inifile = os.path.join(os.curdir, ini_file) for (section, params) in parameters.iteritems(): for (param, default) in params.iteritems(): val = GetProfileVal(section, param, default, self._inifile) if val == 'required_but_not_set': raise ValueError, 'unable to locate required parameter:' +\ '\n\tINI file: ' + self._inifile +\ '\n\tINI section: [' + section + ']' +\ '\n\tparameter: ' + param self.setparam(section, param, val) self.setparam('conversion', 'metadata', os.path.join(self.getparam('conversion', 'root'),'metadata')) self.setparam('perforce', 'clientroot', os.path.join(self.getparam('conversion', 'root'),'data')) # If start is specified then convert to timestamp start_param = self.getparam('changelists', 'start') if start_param: self.setparam('changelists', 'start', mktimestamp(start_param)) # Set up by date and time formats from registry (date_format, time_format) = read_date_time_format_from_registry() self.setparam('changelists', 'dateformat', date_format) self.setparam('changelists', 'timeformat', time_format) # Construct the user mapping table for mapping in GetProfileSection('usermap', self._inifile): self.setparam('usermap', *mapping.split('=')) def setparam(self, psec, pname, value): if psec not in self._parameters: self._parameters[psec] = dict() self._parameters[psec][pname] = value def getparam(self, psec, pname): return self._parameters[psec][pname] # Convert from "yyyy/mm/dd hh:mm:ss" to datetime object def mktimestamp(dtstr): (dstr, tstr) = dtstr.split() return datetime.datetime(*map(int, dstr.split('/') + tstr.split(':'))) # Read current date/time format settings from Registry and parse appropriately def read_date_time_format_from_registry(): rkey = RegOpenKeyEx(HKEY_CURRENT_USER, r'Control Panel\International', 0, KEY_READ) sShortDate = RegQueryValueEx(rkey, 'sShortDate')[0].lower() # Date format, e.g. dd/MM/yyyy iTime = RegQueryValueEx(rkey, 'iTime')[0] # 0 = 12 hour, 1 = 24 hour format sTime = RegQueryValueEx(rkey, 'sTime')[0] # time seperator (usually ":") sDate = RegQueryValueEx(rkey, 'sDate')[0] # Date seperator (usually "/") s1159 = RegQueryValueEx(rkey, 's1159')[0] # AM indicator (if required) s2359 = RegQueryValueEx(rkey, 's2359')[0] # PM indicator (if required) RegCloseKey(rkey) # Remove duplicates of d/M/y and change to lowercase sShortDate = re.sub('d+', 'd', sShortDate) sShortDate = re.sub('m+', 'm', sShortDate) sShortDate = re.sub('y+', 'y', sShortDate) time_format = 'H' + sTime + 'M' if iTime == 0: time_format += 'p' return (sShortDate, time_format)
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 5265 | Jeffery G. Smith |
Rename/Move: //guest/jeffery_g_smith/perforce/utils/sttop4/main/sysutil.py To: //guest/jeffery_g_smith/perforce/utils/sttop4/python/sysutil.py Rename/Move: //guest/jeffery_g_smith/perforce/utils/sttop4/main/params.py To: //guest/jeffery_g_smith/perforce/utils/sttop4/python/params.py |
||
//guest/jeffery_g_smith/perforce/utils/sttop4/main/params.py | |||||
#7 | 4932 | Jeffery G. Smith | These files didn't et checked in with last changeset for some reason. | ||
#6 | 4912 | Jeffery G. Smith | Convert to using P4Python. | ||
#5 | 4910 | Jeffery G. Smith | Continue conversion to Python. | ||
#4 | 4908 | Jeffery G. Smith | Finished update of INI file. | ||
#3 | 4907 | Jeffery G. Smith | Continued conversion to Python. | ||
#2 | 4901 | Jeffery G. Smith | Started Python conversion. | ||
#1 | 4898 | Jeffery G. Smith | Convert to Python. | ||
//guest/jeffery_g_smith/perforce/utils/sttop4/main/convert.pm | |||||
#7 | 4818 | Jeffery G. Smith |
Finished extracting metadata. Improved logging subsystem. |
||
#6 | 4795 | Jeffery G. Smith | Worked on first phase of metadata collection. | ||
#5 | 4793 | Jeffery G. Smith | Updated sources to more closely match VSStoP4 baseline. | ||
#4 | 4710 | Jeffery G. Smith | Initial changes for StarTeam support after combining PVCS and VSS converters. | ||
#3 | 4703 | Jeffery G. Smith | Merge with the VSS converter. | ||
#2 | 4701 | Jeffery G. Smith | Initial converion to StarTeam. | ||
#1 | 4700 | Jeffery G. Smith | Initialize branch from PVCS converter. | ||
//guest/perforce_software/utils/pvcstop4/main/convert.pm | |||||
#1 | 4664 | Robert Cowham | Branch into permanent location. | ||
//guest/robert_cowham/perforce/utils/pvcstop4/main/convert.pm | |||||
#1 | 4647 | Robert Cowham |
Rename //guest/robert_cowham/perforce/utils/pvcstop4/... To //guest/robert_cowham/perforce/utils/pvcstop4/main/... |
||
//guest/robert_cowham/perforce/utils/pvcstop4/convert.pm | |||||
#4 | 3721 | Robert Cowham |
Various changes (tested at a client): - Use PCLI to read file location info (e.g. if moved) - Use P4Perl for speed - Removed DB_File as it has a bug - Do labels differently for vastly improved speed |
||
#3 | 3638 | Robert Cowham |
Renamed some files with windows extensions. Imported changes from Vsstop4 scripts: - Use P4Perl if installed - Use DB_File if installed - Rework labelling algorithm for speed Net result should be much improved performance. Next step is to use pcli. |
||
#2 | 2290 | Robert Cowham |
Merged in some changes from the VSStoP4 scripts: - allow specification of depot and path within depot - cope with repository already existing - cope with multiple concurrent updates to server - slightly improved error detection Note this hasn't been tested with a branch configuration. |
||
#1 | 2289 | Robert Cowham | Initial version from Perforce web page |