Update of /cvsroot/pywin32/pywin32/win32/scripts
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20331/win32/scripts
Modified Files:
Tag: py3k
backupEventLog.py killProcName.py rasutil.py regsetup.py
setup_d.py
Log Message:
many more upgrades to py3k syntax
Index: regsetup.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/scripts/regsetup.py,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -C2 -d -r1.15 -r1.15.2.1
*** regsetup.py 30 May 2008 23:14:17 -0000 1.15
--- regsetup.py 26 Nov 2008 09:03:30 -0000 1.15.2.1
***************
*** 13,17 ****
os.stat(fname)
return 1
! except os.error, details:
return 0
--- 13,17 ----
os.stat(fname)
return 1
! except os.error as details:
return 0
***************
*** 54,58 ****
ret = os.path.abspath(pathLook)
return ret, ret
! raise error, "The package %s can not be located" % packageName
def FindHelpPath(helpFile, helpDesc, searchPaths):
--- 54,58 ----
ret = os.path.abspath(pathLook)
return ret, ret
! raise error("The package %s can not be located" % packageName)
def FindHelpPath(helpFile, helpDesc, searchPaths):
***************
*** 78,82 ****
if FileExists(os.path.join( pathLook, helpFile)):
return os.path.abspath(pathLook)
! raise error, "The help file %s can not be located" % helpFile
def FindAppPath(appName, knownFileName, searchPaths):
--- 78,82 ----
if FileExists(os.path.join( pathLook, helpFile)):
return os.path.abspath(pathLook)
! raise error("The help file %s can not be located" % helpFile)
def FindAppPath(appName, knownFileName, searchPaths):
***************
*** 98,102 ****
# Found it
return os.path.abspath(pathLook)
! raise error, "The file %s can not be located for application %s" % (knownFileName, appName)
def FindPythonExe(exeAlias, possibleRealNames, searchPaths):
--- 98,102 ----
# Found it
return os.path.abspath(pathLook)
! raise error("The file %s can not be located for application %s" % (knownFileName, appName))
def FindPythonExe(exeAlias, possibleRealNames, searchPaths):
***************
*** 161,165 ****
import win32ui, win32con
except ImportError:
! raise error, "Need to locate the file %s, but the win32ui module is not available\nPlease run the program again, passing as a parameter the path to this file." % fileName
# Display a common dialog to locate the file.
flags=win32con.OFN_FILEMUSTEXIST
--- 161,165 ----
import win32ui, win32con
except ImportError:
! raise error("Need to locate the file %s, but the win32ui module is not available\nPlease run the program again, passing as a parameter the path to this file." % fileName)
# Display a common dialog to locate the file.
flags=win32con.OFN_FILEMUSTEXIST
***************
*** 169,173 ****
dlg.SetOFNTitle("Locate " + fileName)
if dlg.DoModal() <> win32con.IDOK:
! raise KeyboardInterrupt, "User cancelled the process"
retPath = dlg.GetPathName()
return os.path.abspath(retPath)
--- 169,173 ----
dlg.SetOFNTitle("Locate " + fileName)
if dlg.DoModal() <> win32con.IDOK:
! raise KeyboardInterrupt("User cancelled the process")
retPath = dlg.GetPathName()
return os.path.abspath(retPath)
***************
*** 215,219 ****
libPath = LocatePath("os.py", searchPaths)
if libPath is None:
! raise error, "The core Python library could not be located."
corePath = None
--- 215,219 ----
libPath = LocatePath("os.py", searchPaths)
if libPath is None:
! raise error("The core Python library could not be located.")
corePath = None
***************
*** 226,230 ****
corePath = LocatePath("unicodedata%s.pyd" % suffix, searchPaths)
if corePath is None:
! raise error, "The core Python path could not be located."
installPath = os.path.abspath(os.path.join(libPath, ".."))
--- 226,230 ----
corePath = LocatePath("unicodedata%s.pyd" % suffix, searchPaths)
if corePath is None:
! raise error("The core Python path could not be located.")
installPath = os.path.abspath(os.path.join(libPath, ".."))
***************
*** 242,246 ****
"""
import regutil, string
! if not packageName: raise error, "A package name must be supplied"
corePaths = string.split(regutil.GetRegisteredNamedPath(None),";")
if not searchPaths: searchPaths = corePaths
--- 242,246 ----
"""
import regutil, string
! if not packageName: raise error("A package name must be supplied")
corePaths = string.split(regutil.GetRegisteredNamedPath(None),";")
if not searchPaths: searchPaths = corePaths
***************
*** 253,261 ****
regutil.RegisterNamedPath(registryAppName, pathAdd)
return pathLook
! except error, details:
! print "*** The %s package could not be registered - %s" % (packageName, details)
! print "*** Please ensure you have passed the correct paths on the command line."
! print "*** - For packages, you should pass a path to the packages parent directory,"
! print "*** - and not the package directory itself..."
--- 253,261 ----
regutil.RegisterNamedPath(registryAppName, pathAdd)
return pathLook
! except error as details:
! print("*** The %s package could not be registered - %s" % (packageName, details))
! print("*** Please ensure you have passed the correct paths on the command line.")
! print("*** - For packages, you should pass a path to the packages parent directory,")
! print("*** - and not the package directory itself...")
***************
*** 275,280 ****
if pathLook:
paths.append(pathLook)
! except error, details:
! print "*** ", details
return
--- 275,280 ----
if pathLook:
paths.append(pathLook)
! except error as details:
! print("*** ", details)
return
***************
*** 298,303 ****
try:
pathLook = FindHelpPath(helpFile, helpDesc, searchPaths)
! except error, details:
! print "*** ", details
return
# print "%s found at %s" % (helpFile, pathLook)
--- 298,303 ----
try:
pathLook = FindHelpPath(helpFile, helpDesc, searchPaths)
! except error as details:
! print("*** ", details)
return
# print "%s found at %s" % (helpFile, pathLook)
***************
*** 322,326 ****
installPath, corePaths = LocatePythonCore(searchPaths)
# Register the core Pythonpath.
! print corePaths
regutil.RegisterNamedPath(None, string.join(corePaths,";"))
--- 322,326 ----
installPath, corePaths = LocatePythonCore(searchPaths)
# Register the core Pythonpath.
! print(corePaths)
regutil.RegisterNamedPath(None, string.join(corePaths,";"))
***************
*** 440,444 ****
if __name__=='__main__':
if len(sys.argv)>1 and sys.argv[1] in ['/?','-?','-help','-h']:
! print usage
elif len(sys.argv)==1 or not sys.argv[1][0] in ['/','-']:
# No args, or useful args.
--- 440,444 ----
if __name__=='__main__':
if len(sys.argv)>1 and sys.argv[1] in ['/?','-?','-help','-h']:
! print(usage)
elif len(sys.argv)==1 or not sys.argv[1][0] in ['/','-']:
# No args, or useful args.
***************
*** 460,464 ****
searchPath.append("..\\..\\pcbuild")
! print "Attempting to setup/repair the Python core"
SetupCore(searchPath)
--- 460,464 ----
searchPath.append("..\\..\\pcbuild")
! print("Attempting to setup/repair the Python core")
SetupCore(searchPath)
***************
*** 466,470 ****
FindRegisterHelpFile("PyWin32.chm", searchPath, "Pythonwin Reference")
# Check the registry.
! print "Registration complete - checking the registry..."
import regcheck
regcheck.CheckRegistry()
--- 466,470 ----
FindRegisterHelpFile("PyWin32.chm", searchPath, "Pythonwin Reference")
# Check the registry.
! print("Registration complete - checking the registry...")
import regcheck
regcheck.CheckRegistry()
***************
*** 478,502 ****
for o,a in opts:
if o=='--description':
! print description
if o=='--examples':
! print examples
if o=='--shell':
! print "Registering the Python core."
RegisterShellInfo(searchPaths)
if o=='-p':
! print "Registering package", a
FindRegisterPackage(a,None,searchPaths)
if o in ['--upackage', '--uapp']:
import regutil
! print "Unregistering application/package", a
regutil.UnregisterNamedPath(a)
if o=='-a':
import regutil
path = string.join(searchPaths,";")
! print "Registering application", a,"to path",path
regutil.RegisterNamedPath(a,path)
if o=='-c':
if not len(searchPaths):
! raise error, "-c option must provide at least one additional path"
import win32api, regutil
currentPaths = string.split(regutil.GetRegisteredNamedPath(None),";")
--- 478,502 ----
for o,a in opts:
if o=='--description':
! print(description)
if o=='--examples':
! print(examples)
if o=='--shell':
! print("Registering the Python core.")
RegisterShellInfo(searchPaths)
if o=='-p':
! print("Registering package", a)
FindRegisterPackage(a,None,searchPaths)
if o in ['--upackage', '--uapp']:
import regutil
! print("Unregistering application/package", a)
regutil.UnregisterNamedPath(a)
if o=='-a':
import regutil
path = string.join(searchPaths,";")
! print("Registering application", a,"to path",path)
regutil.RegisterNamedPath(a,path)
if o=='-c':
if not len(searchPaths):
! raise error("-c option must provide at least one additional path")
import win32api, regutil
currentPaths = string.split(regutil.GetRegisteredNamedPath(None),";")
***************
*** 506,511 ****
currentPaths.append(newPath)
if len(currentPaths)<>oldLen:
! print "Registering %d new core paths" % (len(currentPaths)-oldLen)
regutil.RegisterNamedPath(None,string.join(currentPaths,";"))
else:
! print "All specified paths are already registered."
--- 506,511 ----
currentPaths.append(newPath)
if len(currentPaths)<>oldLen:
! print("Registering %d new core paths" % (len(currentPaths)-oldLen))
regutil.RegisterNamedPath(None,string.join(currentPaths,";"))
else:
! print("All specified paths are already registered.")
Index: setup_d.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/scripts/setup_d.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** setup_d.py 4 Jun 2001 05:58:38 -0000 1.1
--- setup_d.py 26 Nov 2008 09:03:30 -0000 1.1.4.1
***************
*** 11,43 ****
def usage_and_die(rc):
! print
! print "This script is designed to copy and register the Python debug"
! print "binaries. It looks for pythonxx_d.dll, pythoncomxx_d.dll etc,"
! print "and installs them to work correctly with Python debug builds."
! print
! print "You will generally find this script in the. zip file that"
! print "included these _d files. Please run this script from"
! print "that directory"
sys.exit(rc)
if win32api.__file__.find("_d") > 0:
! print "This scripts appears to be running a DEBUG version of Python."
! print "Please run it using a normal release build (python.exe)"
usage_and_die(1)
try:
import pythoncom
! except ImportError, details:
! print "Could not import the release version of pythoncom"
! print "The error details are: %s" % (details,)
! print "Please correct this error and rerun the script"
usage_and_die(2)
try:
import pywintypes
! except ImportError, details:
! print "Could not import the release version of pywintypes"
! print "The error details are: %s" % (details,)
! print "Please correct this error and rerun the script"
usage_and_die(2)
--- 11,43 ----
def usage_and_die(rc):
! print()
! print("This script is designed to copy and register the Python debug")
! print("binaries. It looks for pythonxx_d.dll, pythoncomxx_d.dll etc,")
! print("and installs them to work correctly with Python debug builds.")
! print()
! print("You will generally find this script in the. zip file that")
! print("included these _d files. Please run this script from")
! print("that directory")
sys.exit(rc)
if win32api.__file__.find("_d") > 0:
! print("This scripts appears to be running a DEBUG version of Python.")
! print("Please run it using a normal release build (python.exe)")
usage_and_die(1)
try:
import pythoncom
! except ImportError as details:
! print("Could not import the release version of pythoncom")
! print("The error details are: %s" % (details,))
! print("Please correct this error and rerun the script")
usage_and_die(2)
try:
import pywintypes
! except ImportError as details:
! print("Could not import the release version of pywintypes")
! print("The error details are: %s" % (details,))
! print("Please correct this error and rerun the script")
usage_and_die(2)
***************
*** 46,58 ****
if not os.path.isfile(src):
src = os.path.join( os.path.split(sys.argv[0])[0], src)
! print "Can not find %s or %s to copy" % (os.path.abspath(orig_src), os.path.abspath(src))
return 0
try:
shutil.copy(src, dest)
! print "Copied %s -> %s" % (src, dest)
return 1
except:
! print "Error copying '%s' -> '%s'" % (src, dest)
! print str(sys.exc_info[1])
usage_and_die(3)
--- 46,58 ----
if not os.path.isfile(src):
src = os.path.join( os.path.split(sys.argv[0])[0], src)
! print("Can not find %s or %s to copy" % (os.path.abspath(orig_src), os.path.abspath(src)))
return 0
try:
shutil.copy(src, dest)
! print("Copied %s -> %s" % (src, dest))
return 1
except:
! print("Error copying '%s' -> '%s'" % (src, dest))
! print(str(sys.exc_info[1]))
usage_and_die(3)
***************
*** 65,74 ****
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, mod_name))
except _winreg.error:
! print "Could not find the existing '%s' module registered in the registry" % (mod_name,)
usage_and_die(4)
# Create the debug key.
sub_key = _winreg.CreateKey(key, "Debug")
_winreg.SetValue(sub_key, None, _winreg.REG_SZ, dll_name)
! print "Registered '%s' in the registry" % (dll_name,)
def _domodule(mod_name, release_mod_filename):
--- 65,74 ----
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, mod_name))
except _winreg.error:
! print("Could not find the existing '%s' module registered in the registry" % (mod_name,))
usage_and_die(4)
# Create the debug key.
sub_key = _winreg.CreateKey(key, "Debug")
_winreg.SetValue(sub_key, None, _winreg.REG_SZ, dll_name)
! print("Registered '%s' in the registry" % (dll_name,))
def _domodule(mod_name, release_mod_filename):
***************
*** 89,91 ****
_domodule("pywintypes", pywintypes.__file__)
! print "System _d files were setup."
\ No newline at end of file
--- 89,91 ----
_domodule("pywintypes", pywintypes.__file__)
! print("System _d files were setup.")
Index: rasutil.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/scripts/rasutil.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** rasutil.py 16 Oct 2000 05:33:04 -0000 1.2
--- rasutil.py 26 Nov 2008 09:03:30 -0000 1.2.4.1
***************
*** 20,33 ****
for info in win32ras.EnumConnections():
if string.lower(info[1])==string.lower(rasEntryName):
! print "Already connected to", rasEntryName
return 0, info[0]
dial_params, have_pw = win32ras.GetEntryDialParams(None, rasEntryName)
if not have_pw:
! print "Error: The password is not saved for this connection"
! print "Please connect manually selecting the 'save password' option and try again"
sys.exit(1)
! print "Connecting to", rasEntryName, "..."
retryCount = numRetries
while retryCount > 0:
--- 20,33 ----
for info in win32ras.EnumConnections():
if string.lower(info[1])==string.lower(rasEntryName):
! print("Already connected to", rasEntryName)
return 0, info[0]
dial_params, have_pw = win32ras.GetEntryDialParams(None, rasEntryName)
if not have_pw:
! print("Error: The password is not saved for this connection")
! print("Please connect manually selecting the 'save password' option and try again")
sys.exit(1)
! print("Connecting to", rasEntryName, "...")
retryCount = numRetries
while retryCount > 0:
***************
*** 36,40 ****
bValid = 1
break
! print "Retrying..."
win32api.Sleep(5000)
retryCount = retryCount - 1
--- 36,40 ----
bValid = 1
break
! print("Retrying...")
win32api.Sleep(5000)
retryCount = retryCount - 1
***************
*** 66,71 ****
def Usage(why):
! print why
! print usage
sys.exit(1)
--- 66,71 ----
def Usage(why):
! print(why)
! print(usage)
sys.exit(1)
***************
*** 74,78 ****
try:
opts, args = getopt.getopt(sys.argv[1:], "r:c:d:")
! except getopt.error, why:
Usage(why)
retries = 5
--- 74,78 ----
try:
opts, args = getopt.getopt(sys.argv[1:], "r:c:d:")
! except getopt.error as why:
Usage(why)
retries = 5
Index: backupEventLog.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/scripts/backupEventLog.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** backupEventLog.py 2 Sep 1999 00:19:32 -0000 1.1
--- backupEventLog.py 26 Nov 2008 09:03:30 -0000 1.1.4.1
***************
*** 23,35 ****
try:
hlog = win32evtlog.OpenEventLog(None, logType)
! except win32evtlogutil.error, details:
! print "Could not open the event log", details
return
try:
if win32evtlog.GetNumberOfEventLogRecords(hlog)==0:
! print "No records in event log %s - not backed up" % logType
return
win32evtlog.ClearEventLog(hlog, fname)
! print "Backed up %s log to %s" % (logType, fname)
finally:
win32evtlog.CloseEventLog(hlog)
--- 23,35 ----
try:
hlog = win32evtlog.OpenEventLog(None, logType)
! except win32evtlogutil.error as details:
! print("Could not open the event log", details)
return
try:
if win32evtlog.GetNumberOfEventLogRecords(hlog)==0:
! print("No records in event log %s - not backed up" % logType)
return
win32evtlog.ClearEventLog(hlog, fname)
! print("Backed up %s log to %s" % (logType, fname))
finally:
win32evtlog.CloseEventLog(hlog)
Index: killProcName.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/scripts/killProcName.py,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -C2 -d -r1.2 -r1.2.4.1
*** killProcName.py 21 Nov 1999 02:47:03 -0000 1.2
--- killProcName.py 26 Nov 2008 09:03:30 -0000 1.2.4.1
***************
*** 48,56 ****
result = killProcName(procname)
if result:
! print result
! print "Dumping all processes..."
win32pdhutil.ShowAllProcesses()
else:
! print "Killed %s" % procname
else:
! print "Usage: killProcName.py procname ..."
--- 48,56 ----
result = killProcName(procname)
if result:
! print(result)
! print("Dumping all processes...")
win32pdhutil.ShowAllProcesses()
else:
! print("Killed %s" % procname)
else:
! print("Usage: killProcName.py procname ...")
|