Update files in windows directory so it compiles under python3 (print

statements and except and raise).
This commit is contained in:
kulath 2016-08-22 15:48:17 +01:00
parent 5e459e4541
commit 6204bbb8b1
5 changed files with 208 additions and 208 deletions

View File

@ -82,7 +82,7 @@ class buildbase(GObject.GObject):
self.repository_path = '.' #where the source comes from, either SVN root or a tarball self.repository_path = '.' #where the source comes from, either SVN root or a tarball
self.bBuildInstaller = True self.bBuildInstaller = True
self.tarbase3 = '.' self.tarbase3 = '.'
def getbuild_src(self): def getbuild_src(self):
return os.path.join(self.build_root, 'src') return os.path.join(self.build_root, 'src')
@ -100,7 +100,7 @@ class buildbase(GObject.GObject):
log.debug('========== getSVNRevision(%s)' % dir) log.debug('========== getSVNRevision(%s)' % dir)
cmd = 'svnversion -n %s' % dir cmd = 'svnversion -n %s' % dir
log.debug( "Running: %s" % cmd ) log.debug( "Running: %s" % cmd )
proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
(out, err) = proc.communicate() (out, err) = proc.communicate()
output = string.strip(out) output = string.strip(out)
@ -123,9 +123,9 @@ class buildbase(GObject.GObject):
log.debug('========== exportSVN(%s, %s)' % (svn_dir, destdir) ) log.debug('========== exportSVN(%s, %s)' % (svn_dir, destdir) )
# cmd = '"%s" export %s %s' % (SVN_exe ,svn_dir, destdir) # cmd = '"%s" export %s %s' % (SVN_exe ,svn_dir, destdir)
cmd = [SVN_exe, 'export' ,svn_dir, destdir] #'"%s" export %s %s' % (SVN_exe ,svn_dir, destdir) cmd = [SVN_exe, 'export' ,svn_dir, destdir] #'"%s" export %s %s' % (SVN_exe ,svn_dir, destdir)
log.info( "Running: %s" % cmd) log.info( "Running: %s" % cmd)
proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
(out, err) = proc.communicate() (out, err) = proc.communicate()
output = string.strip(out) output = string.strip(out)
@ -171,13 +171,13 @@ class buildbase(GObject.GObject):
elif sys.platform == 'linux2': elif sys.platform == 'linux2':
#assumption makensis is installed and on the path #assumption makensis is installed and on the path
cmd = '%s -V3 %s' % (MAKENSIS_exe, pth2nsis_script) cmd = '%s -V3 %s' % (MAKENSIS_exe, pth2nsis_script)
log.info( "Running: %s" % cmd) log.info( "Running: %s" % cmd)
# Need to define the following enviroment variables for NSIS script # Need to define the following enviroment variables for NSIS script
os.environ['GRAMPS_VER'] = self.gramps_version os.environ['GRAMPS_VER'] = self.gramps_version
os.environ['GRAMPS_BUILD_DIR'] = os.path.abspath(self.build_src) os.environ['GRAMPS_BUILD_DIR'] = os.path.abspath(self.build_src)
os.environ['GRAMPS_OUT_DIR'] = os.path.abspath(self.out_dir) os.environ['GRAMPS_OUT_DIR'] = os.path.abspath(self.out_dir)
proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
(out, err) = proc.communicate() (out, err) = proc.communicate()
output = string.strip(out) output = string.strip(out)
@ -191,7 +191,7 @@ class buildbase(GObject.GObject):
conf_lines = fin.readlines() conf_lines = fin.readlines()
fin.close() fin.close()
return self.getVersionFromLines(conf_lines) return self.getVersionFromLines(conf_lines)
def getVersionFromLines(self, conf_lines): def getVersionFromLines(self, conf_lines):
log.debug('========== getVersionFromLines()') log.debug('========== getVersionFromLines()')
for line in conf_lines: for line in conf_lines:
@ -225,11 +225,11 @@ class buildbase(GObject.GObject):
po_files = glob.glob(po_dir + "\*.po") po_files = glob.glob(po_dir + "\*.po")
# no longer using python msgfmt as it doesn't handle plurals (april 2010) # no longer using python msgfmt as it doesn't handle plurals (april 2010)
# msgfmtCmd = path.normpath(path.join(sys.prefix, "Tools/i18n/msgfmt.py") ) # msgfmtCmd = path.normpath(path.join(sys.prefix, "Tools/i18n/msgfmt.py") )
# GetText Win 32 obtained from http://gnuwin32.sourceforge.net/packages/gettext.htm # GetText Win 32 obtained from http://gnuwin32.sourceforge.net/packages/gettext.htm
# ....\gettext\bin\msgfmt.exe needs to be on the path # ....\gettext\bin\msgfmt.exe needs to be on the path
msgfmtCmd = 'msgfmt.exe' msgfmtCmd = 'msgfmt.exe'
#print 'msgfmtCmd = %s' % msgfmtCmd #print('msgfmtCmd = %s' % msgfmtCmd)
elif sys.platform == 'linux2': elif sys.platform == 'linux2':
po_files = glob.glob(po_dir + "/*.po") po_files = glob.glob(po_dir + "/*.po")
msgfmtCmd = "%s/bin/msgfmt" % sys.prefix msgfmtCmd = "%s/bin/msgfmt" % sys.prefix
@ -304,7 +304,7 @@ class buildbase(GObject.GObject):
try: try:
log.info('removing directory: %s' % self.build_root ) log.info('removing directory: %s' % self.build_root )
shutil.rmtree(self.build_root) shutil.rmtree(self.build_root)
except MY_EXCEPTION, e: except MY_EXCEPTION as e:
log.error( e ) log.error( e )
for file in ['gramps-%s.exe'%self.gramps_version ]: #, 'build.log']: for file in ['gramps-%s.exe'%self.gramps_version ]: #, 'build.log']:
@ -313,7 +313,7 @@ class buildbase(GObject.GObject):
try: try:
log.info('removing file: %s' % fname ) log.info('removing file: %s' % fname )
os.remove(fname) os.remove(fname)
except MY_EXCEPTION, e: except MY_EXCEPTION as e:
log.error( e ) log.error( e )
def getNSISVersionNumber(self): def getNSISVersionNumber(self):
@ -322,7 +322,7 @@ class buildbase(GObject.GObject):
# v2.42 # v2.42
cmd = '"%s" -VERSION' % (MAKENSIS_exe) cmd = '"%s" -VERSION' % (MAKENSIS_exe)
log.debug(cmd) log.debug(cmd)
proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
(out, err) = proc.communicate() (out, err) = proc.communicate()
output = string.strip(out) output = string.strip(out)
@ -333,15 +333,15 @@ class buildbase(GObject.GObject):
minor =0 minor =0
major =0 major =0
return (major, minor) return (major, minor)
#parse the output to get version number into tuple #parse the output to get version number into tuple
ver = output[1:].split('.') ver = output[1:].split('.')
major = int(ver[0]) major = int(ver[0])
try: try:
minor = int(ver[1]) minor = int(ver[1])
except ValueError, e: except ValueError as e:
m = ver[1] m = ver[1]
minor = int(m[:2]) minor = int(m[:2])
return (major, minor) return (major, minor)
def checkForBuildTools(self): def checkForBuildTools(self):
@ -356,12 +356,12 @@ class buildbase(GObject.GObject):
makensisexe = path.join( nsispath, 'makensis.exe') makensisexe = path.join( nsispath, 'makensis.exe')
if path.isfile( makensisexe ): if path.isfile( makensisexe ):
MAKENSIS_exe = makensisexe MAKENSIS_exe = makensisexe
except WindowsError, e: except WindowsError as e:
log.warning('NSIS not found, in registory') log.warning('NSIS not found, in registory')
log.warning('..Testing if makensis is on the path') log.warning('..Testing if makensis is on the path')
MAKENSIS_exe = 'makensis' MAKENSIS_exe = 'makensis'
#cmd = os.path.join(nsis_dir, MAKENSIS_exe) #cmd = os.path.join(nsis_dir, MAKENSIS_exe)
cmd = '%s /VERSION' % MAKENSIS_exe cmd = '%s /VERSION' % MAKENSIS_exe
proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
(out, err) = proc.communicate() (out, err) = proc.communicate()
@ -376,7 +376,7 @@ class buildbase(GObject.GObject):
# Find msgfmt on system # Find msgfmt on system
cmd = os.path.join(msg_dir, 'msgfmt.exe') cmd = os.path.join(msg_dir, 'msgfmt.exe')
proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) proc = subprocess.Popen( cmd, shell = True, stdout=subprocess.PIPE, stderr=subprocess.PIPE )
(out, err) = proc.communicate() (out, err) = proc.communicate()
output = string.strip(out) output = string.strip(out)
@ -386,7 +386,7 @@ class buildbase(GObject.GObject):
log.error('msgfmt.exe not found on path') log.error('msgfmt.exe not found on path')
log.error(' try the -m DIR , --msgdir=DIR option to specify the directory or put it on the path') log.error(' try the -m DIR , --msgdir=DIR option to specify the directory or put it on the path')
sys.exit(0) sys.exit(0)
# Find SVN on system - optional, if building from tarball # Find SVN on system - optional, if building from tarball
if not bTarball: if not bTarball:
try: try:
@ -394,11 +394,11 @@ class buildbase(GObject.GObject):
svnpath = winreg.QueryValue(key, '') svnpath = winreg.QueryValue(key, '')
if path.isfile(svnpath): if path.isfile(svnpath):
SVN_exe = svnpath SVN_exe = svnpath
except WindowsError, e: except WindowsError as e:
log.warning('SVN not found, in registory') log.warning('SVN not found, in registory')
log.warning('... Hoping svn is on the path') log.warning('... Hoping svn is on the path')
SVN_exe = 'svn' SVN_exe = 'svn'
elif sys.platform == 'linux2': elif sys.platform == 'linux2':
#ASSUMPTION: these tools are on the path #ASSUMPTION: these tools are on the path
#TODO: check for svn on Linux #TODO: check for svn on Linux
@ -407,7 +407,7 @@ class buildbase(GObject.GObject):
#TODO: check for nsis on Linux #TODO: check for nsis on Linux
log.info( 'TODO: Check for nsis' ) log.info( 'TODO: Check for nsis' )
MAKENSIS_exe = 'makensis' MAKENSIS_exe = 'makensis'
# Check if we are running a compatible vesion of NSIS # Check if we are running a compatible vesion of NSIS
vers = self.getNSISVersionNumber() vers = self.getNSISVersionNumber()
if vers < MIN_NSIS_VERSION: if vers < MIN_NSIS_VERSION:
@ -417,7 +417,7 @@ class buildbase(GObject.GObject):
else: else:
self.bBuildInstaller = True self.bBuildInstaller = True
log.info( "NSIS version %d.%d" % vers ) log.info( "NSIS version %d.%d" % vers )
def expandTarBall(self, tarball, expand_dir): def expandTarBall(self, tarball, expand_dir):
# gramps-3.1.0.tar.gz # gramps-3.1.0.tar.gz
log.info( 'expandTarBall(%s, %s)' % (tarball, expand_dir) ) log.info( 'expandTarBall(%s, %s)' % (tarball, expand_dir) )
@ -429,15 +429,15 @@ class buildbase(GObject.GObject):
extractDir = os.path.join(self.out_dir, self.tarbase3 ) extractDir = os.path.join(self.out_dir, self.tarbase3 )
try: try:
os.rename( extractDir, self.build_root) os.rename( extractDir, self.build_root)
except WindowsError, e: except WindowsError as e:
log.error("FAILED: \n\t extractDir=%s \n\t build_root=%s" % (extractDir, self.build_root)) log.error("FAILED: \n\t extractDir=%s \n\t build_root=%s" % (extractDir, self.build_root))
raise WindowsError, e raise WindowsError(e)
else: else:
log.error( "Sorry %s is not a tar file" % self.repository_path ) log.error( "Sorry %s is not a tar file" % self.repository_path )
def getVersionFromTarBall(self, tarball): def getVersionFromTarBall(self, tarball):
log.debug( 'getVersionFromTarBall(%s)' % (tarball)) log.debug( 'getVersionFromTarBall(%s)' % (tarball))
if tarfile.is_tarfile(self.repository_path): if tarfile.is_tarfile(self.repository_path):
tar = tarfile.open(self.repository_path) tar = tarfile.open(self.repository_path)
members = tar.getnames() members = tar.getnames()
@ -449,11 +449,11 @@ class buildbase(GObject.GObject):
vers = self.getVersionFromLines(lines) vers = self.getVersionFromLines(lines)
if 'TODO' in member: #need to get path this will extract too, grab it of one of the files if 'TODO' in member: #need to get path this will extract too, grab it of one of the files
self.tarbase3, rest = member.split('/', 1) self.tarbase3, rest = member.split('/', 1)
print '==ExtractPath', self.tarbase3 print('==ExtractPath', self.tarbase3)
tar.close() tar.close()
log.debug( 'Version (%s)' % (vers) ) log.debug( 'Version (%s)' % (vers) )
return vers return vers
def copyPatchTreeToDest(self, src, dst): def copyPatchTreeToDest(self, src, dst):
'''Patch a tarball build with alternate files as required. '''Patch a tarball build with alternate files as required.
At this stage do not allow new directories to be made or At this stage do not allow new directories to be made or
@ -474,15 +474,15 @@ class buildbase(GObject.GObject):
self.copyPatchTreeToDest(srcname, dstname) self.copyPatchTreeToDest(srcname, dstname)
else: else:
log.error('UNDEFINED: %s -> %s' % (srcname, dstname)) log.error('UNDEFINED: %s -> %s' % (srcname, dstname))
except (IOError, os.error), why: except (IOError, os.error) as why:
errors.append((srcname, dstname, str(why))) errors.append((srcname, dstname, str(why)))
# catch the Error from the recursive copytree so that we can # catch the Error from the recursive copytree so that we can
# continue with other files # continue with other files
except Error, err: except Error as err:
errors.extend(err.args[0]) errors.extend(err.args[0])
if errors: if errors:
raise Error(errors) raise Error(errors)
def buildGRAMPS( base, out_dir, bTarball): def buildGRAMPS( base, out_dir, bTarball):
bo = buildbase() bo = buildbase()
@ -490,7 +490,7 @@ def buildGRAMPS( base, out_dir, bTarball):
bo.out_dir = out_dir bo.out_dir = out_dir
bo.bTarball = bTarball bo.bTarball = bTarball
bo.bBuildInstaller = bBuildInstaller bo.bBuildInstaller = bBuildInstaller
if not bo.bTarball and not bo.isGrampsRoot(bo.repository_path): if not bo.bTarball and not bo.isGrampsRoot(bo.repository_path):
log.error( '$$$$ BAD Gramps Root specified $$$$') log.error( '$$$$ BAD Gramps Root specified $$$$')
else: else:
@ -513,7 +513,7 @@ def buildGRAMPS( base, out_dir, bTarball):
bo.exportSVN(os.path.join(base, 'example'), os.path.join(bo.build_root, 'examples') ) bo.exportSVN(os.path.join(base, 'example'), os.path.join(bo.build_root, 'examples') )
bo.generateConstPy( ) bo.generateConstPy( )
bo.copyExtraFilesToBuildDir(base) bo.copyExtraFilesToBuildDir(base)
if bPatchBuild: if bPatchBuild:
bo.copyPatchTreeToDest( patch_dir, bo.build_root ) bo.copyPatchTreeToDest( patch_dir, bo.build_root )
if bBuildAll: if bBuildAll:
@ -568,7 +568,7 @@ Options:
for o, a in opts: for o, a in opts:
if o in ("-h", "--help"): if o in ("-h", "--help"):
print usage print(usage)
sys.exit(0) sys.exit(0)
if o in ("-o", "--out"): if o in ("-o", "--out"):
@ -576,20 +576,20 @@ Options:
if o in ("--nsis_only"): if o in ("--nsis_only"):
bBuildAll = False bBuildAll = False
if o in ('-t', "--tarball"): if o in ('-t', "--tarball"):
print 'This is a tarball build' print('This is a tarball build')
bTarball = True bTarball = True
if o in ("-m", "--msgdir"): if o in ("-m", "--msgdir"):
if os.path.isdir( a ): if os.path.isdir( a ):
msg_dir = a msg_dir = a
else: else:
raise getopt.GetoptError, '\nERROR: msgfmt dir does not exist' raise getopt.GetoptError('\nERROR: msgfmt dir does not exist')
if o in ("-p", "--patch"): if o in ("-p", "--patch"):
if os.path.isdir( a ): if os.path.isdir( a ):
patch_dir = a patch_dir = a
bPatchBuild = True bPatchBuild = True
else: else:
raise getopt.GetoptError, '\nERROR: Patch directory does not exist' raise getopt.GetoptError('\nERROR: Patch directory does not exist')
if args: #got args use first one as base dir if args: #got args use first one as base dir
repository_path = path.normpath(args[0]) repository_path = path.normpath(args[0])
else: # no base dir passed in, work out one from current working dir else: # no base dir passed in, work out one from current working dir
@ -601,21 +601,21 @@ Options:
# raise getopt.GetoptError, '\nERROR: No base directory specified' # raise getopt.GetoptError, '\nERROR: No base directory specified'
if len(args) > 1: if len(args) > 1:
raise getopt.GetoptError, '\nERROR: Too many arguments' raise getopt.GetoptError('\nERROR: Too many arguments')
except getopt.GetoptError, msg: except getopt.GetoptError as msg:
print msg print(msg)
print '\n %s' % usage print('\n %s' % usage)
sys.exit(2) sys.exit(2)
if bTarball: if bTarball:
if not tarfile.is_tarfile(repository_path): if not tarfile.is_tarfile(repository_path):
print "Tarball %s not a valid Tarball" % repository_path print("Tarball %s not a valid Tarball" % repository_path)
sys.exit(1) sys.exit(1)
else: else:
if not os.path.isdir(repository_path): if not os.path.isdir(repository_path):
print "WC root directory not found; %s " % repository_path print("WC root directory not found; %s " % repository_path)
sys.exit(1) sys.exit(1)
if out_dir == None: if out_dir == None:
@ -624,13 +624,13 @@ Options:
else: else:
out_dir = path.normpath(os.path.join(repository_path, 'windows')) out_dir = path.normpath(os.path.join(repository_path, 'windows'))
log.info("Setting outdir to %s", out_dir) log.info("Setting outdir to %s", out_dir)
s_args = '' s_args = ''
for value in sys.argv[1:]: for value in sys.argv[1:]:
s_args = s_args + ' %s'%value s_args = s_args + ' %s'%value
print "======= build_GrampsWin32.py %s ========" % s_args print("======= build_GrampsWin32.py %s ========" % s_args)
log.debug('Using %s to find python tools' % sys.prefix) log.debug('Using %s to find python tools' % sys.prefix)
log.info('Platform: %s' % sys.platform) log.info('Platform: %s' % sys.platform)
#========================== #==========================

View File

@ -48,15 +48,15 @@ explain_safe = ''' **********************************************************
def RunExeCommand( app, args ): def RunExeCommand( app, args ):
cmd = app + ' ' + args cmd = app + ' ' + args
#print "Running: ", cmd #print("Running: ", cmd)
stdin, stdout, stderr = os.popen3( cmd ) stdin, stdout, stderr = os.popen3( cmd )
output = string.strip(stdout.read()) output = string.strip(stdout.read())
#print output #print(output)
err = stderr.read() err = stderr.read()
if err: if err:
print err print(err)
return output return output
def CheckGtkInReg(): def CheckGtkInReg():
global gtkPathInRegistry, gtkVersionInRegistry, dllPathInRegistry, dllPathShort global gtkPathInRegistry, gtkVersionInRegistry, dllPathInRegistry, dllPathShort
log.info( '\n==== Checking Registry for GTK =====' ) log.info( '\n==== Checking Registry for GTK =====' )
@ -68,8 +68,8 @@ def CheckGtkInReg():
log.info( ' Version : %s'% gtkVersionInRegistry ) log.info( ' Version : %s'% gtkVersionInRegistry )
log.info( ' Path : %s'% gtkPathInRegistry ) log.info( ' Path : %s'% gtkPathInRegistry )
log.info( ' DllPath : %s'% dllPathInRegistry ) log.info( ' DllPath : %s'% dllPathInRegistry )
except WindowsError, e: except WindowsError as e:
log.info( '\n GTK registry key not found in registry' ) log.info( '\n GTK registry key not found in registry' )
log.info( ''' ******************************************************************** log.info( ''' ********************************************************************
* This might not be an error, but means I don't know the directory to * This might not be an error, but means I don't know the directory to
@ -78,7 +78,7 @@ def CheckGtkInReg():
log.info( '-' * 60 ) log.info( '-' * 60 )
log.info( usage ) log.info( usage )
sys.exit(0) sys.exit(0)
def WorkOutShortDosPath(): def WorkOutShortDosPath():
global dllPathShort global dllPathShort
log.info( '\n==== Use win32Api to query short path name for GTK =====' ) log.info( '\n==== Use win32Api to query short path name for GTK =====' )
@ -99,11 +99,11 @@ def FindLibsWithCtypes():
dllpathvalid = False dllpathvalid = False
cpath = find_library(dll) cpath = find_library(dll)
if cpath: if cpath:
#print cpath #print(cpath)
if cpath == os.path.join(dllPathInRegistry, dll) \ if cpath == os.path.join(dllPathInRegistry, dll) \
or cpath == os.path.join(dllPathShort, dll): or cpath == os.path.join(dllPathShort, dll):
dllpathvalid = True dllpathvalid = True
if not dllpathvalid: if not dllpathvalid:
pp = os.path.dirname(cpath) pp = os.path.dirname(cpath)
if pp not in other_paths: if pp not in other_paths:
@ -140,17 +140,17 @@ def ScanDependencyFileForErrors(fname):
if dirname.startswith(os.path.join(sysroot, 'winsxs').lower()) \ if dirname.startswith(os.path.join(sysroot, 'winsxs').lower()) \
or dirname.startswith(os.path.join(sys.prefix, 'lib\site-packages\gtk-2.0').lower()): or dirname.startswith(os.path.join(sys.prefix, 'lib\site-packages\gtk-2.0').lower()):
OK = True OK = True
for pth in acceptablePaths: for pth in acceptablePaths:
if dirname == pth.lower(): if dirname == pth.lower():
OK = True OK = True
if 'MSVCR90.DLL' in filename: if 'MSVCR90.DLL' in filename:
if parts[0] == 'Error': if parts[0] == 'Error':
runtimedlls[filename] = "Error dll not found" runtimedlls[filename] = "Error dll not found"
else: else:
runtimedlls[filename] = parts[16] runtimedlls[filename] = parts[16]
if OK == False: if OK == False:
if parts[0] == 'Error': if parts[0] == 'Error':
log.info( " %s \tError dll not found" %( filename)) log.info( " %s \tError dll not found" %( filename))
@ -163,7 +163,7 @@ def ScanDependencyFileForErrors(fname):
log.info( '\n MS runtime Version %s loaded from' % runtimedlls[rtdll] ) log.info( '\n MS runtime Version %s loaded from' % runtimedlls[rtdll] )
log.info( " %s" %rtdll ) log.info( " %s" %rtdll )
log.info( '') log.info( '')
def CheckWithDependencyWalker(): def CheckWithDependencyWalker():
log.info( '\n==== Checking with Dependency Walker ====' ) log.info( '\n==== Checking with Dependency Walker ====' )
log.info( ' Please be patient takes some time' ) log.info( ' Please be patient takes some time' )
@ -180,7 +180,7 @@ def CheckWithDependencyWalker():
#delete the output file before running command #delete the output file before running command
try: try:
os.remove(fout) os.remove(fout)
except WindowsError, e: except WindowsError as e:
pass pass
log.info( ' Testing file %s' % ftest ) log.info( ' Testing file %s' % ftest )
out = RunExeCommand(exe, '/c /f1 /ot "%s" "%s"' % (fout, ftest) ) out = RunExeCommand(exe, '/c /f1 /ot "%s" "%s"' % (fout, ftest) )
@ -192,7 +192,7 @@ def CheckWithDependencyWalker():
log.info( ' Cannot check with dependency walker, not installed in local directory' ) log.info( ' Cannot check with dependency walker, not installed in local directory' )
log.info( ' get dependency walker from http://www.dependencywalker.com/' ) log.info( ' get dependency walker from http://www.dependencywalker.com/' )
log.info( ' and unzip into this directory for it to work.' ) log.info( ' and unzip into this directory for it to work.' )
def CheckPathForOtherGtkInstalls(): def CheckPathForOtherGtkInstalls():
log.info( '\n====Checking environment path for other gtk installations====' ) log.info( '\n====Checking environment path for other gtk installations====' )
ePath = os.environ['path'] ePath = os.environ['path']
@ -201,7 +201,7 @@ def CheckPathForOtherGtkInstalls():
other_paths = [] other_paths = []
explain_level = 0 explain_level = 0
for i, d in enumerate(dirs): for i, d in enumerate(dirs):
#print '==%s==' %d #print('==%s==' %d)
if d == gtkPathInRegistry or d == dllPathInRegistry\ if d == gtkPathInRegistry or d == dllPathInRegistry\
or d == dllPathShort: or d == dllPathShort:
gtkpth_idx = i gtkpth_idx = i
@ -209,7 +209,7 @@ def CheckPathForOtherGtkInstalls():
for fname in testdlls: for fname in testdlls:
f = os.path.join(d, fname) f = os.path.join(d, fname)
if os.path.isfile( f ): if os.path.isfile( f ):
#print ' Found Erronous gtk DLL %s' % f #print(' Found Erronous gtk DLL %s' % f)
if d not in other_paths: if d not in other_paths:
other_paths.append(d) other_paths.append(d)
if i < gtkpth_idx: # path appears BEFORE runtime path if i < gtkpth_idx: # path appears BEFORE runtime path
@ -228,7 +228,7 @@ def CheckPathForOtherGtkInstalls():
log.info( explain_safe ) log.info( explain_safe )
if len(other_paths) == 0: if len(other_paths) == 0:
log.info( ' No other gtk installatons found\n' ) log.info( ' No other gtk installatons found\n' )
# ==== report what python thinks it's using ===== # ==== report what python thinks it's using =====
MIN_PYTHON_VER = (2,5,1) MIN_PYTHON_VER = (2,5,1)
UNTESTED_PYTHON_VER = (3,0,0) UNTESTED_PYTHON_VER = (3,0,0)
@ -258,7 +258,7 @@ def PrintVersionResult(appl, minVersion, actualVersion, untestedVersion):
else: else:
result = '...FAILED' result = '...FAILED'
log.info( '%s version %s or above.....\tfound %s %s' % (appl, minStr , actStr, result) ) log.info( '%s version %s or above.....\tfound %s %s' % (appl, minStr , actStr, result) )
def Import_pyGtkIntoPython(): def Import_pyGtkIntoPython():
log.info( '\n==== Test import into python ====' ) log.info( '\n==== Test import into python ====' )
#py_str = 'found %d.%d.%d' % sys.version_info[:3] #py_str = 'found %d.%d.%d' % sys.version_info[:3]
@ -267,22 +267,22 @@ def Import_pyGtkIntoPython():
# Test the GTK version # Test the GTK version
try: try:
import gtk import gtk
PrintVersionResult(' GTK+ ', MIN_GTK_VER, Gtk.gtk_version, UNTESTED_GTK_VER ) PrintVersionResult(' GTK+ ', MIN_GTK_VER, Gtk.gtk_version, UNTESTED_GTK_VER )
#test the pyGTK version (which is in the gtk namespace) #test the pyGTK version (which is in the gtk namespace)
PrintVersionResult(' pyGTK ', MIN_PYGTK_VER, Gtk.pygtk_version, UNTESTED_PYGTK_VER ) PrintVersionResult(' pyGTK ', MIN_PYGTK_VER, Gtk.pygtk_version, UNTESTED_PYGTK_VER )
except ImportError: except ImportError:
PrintFailedImport(' GTK+ ', MIN_GTK_VER, NOT_FOUND_STR) PrintFailedImport(' GTK+ ', MIN_GTK_VER, NOT_FOUND_STR)
PrintFailedImport(' pyGTK ', MIN_PYGTK_VER, 'Cannot test, ...GTK+ missing') PrintFailedImport(' pyGTK ', MIN_PYGTK_VER, 'Cannot test, ...GTK+ missing')
#test the gobject version #test the gobject version
try: try:
import gobject import gobject
PrintVersionResult(' gobject', MIN_GOBJECT_VER, GObject.pygobject_version, UNTESTED_GOBJECT_VER) PrintVersionResult(' gobject', MIN_GOBJECT_VER, GObject.pygobject_version, UNTESTED_GOBJECT_VER)
except ImportError: except ImportError:
PrintFailedImport(' gobject', MIN_GOBJECT_VER, NOT_FOUND_STR) PrintFailedImport(' gobject', MIN_GOBJECT_VER, NOT_FOUND_STR)
@ -291,7 +291,7 @@ def Import_pyGtkIntoPython():
try: try:
import cairo import cairo
PrintVersionResult(' cairo ', MIN_CAIRO_VER, cairo.version_info, UNTESTED_CAIRO_VER ) PrintVersionResult(' cairo ', MIN_CAIRO_VER, cairo.version_info, UNTESTED_CAIRO_VER )
except ImportError: except ImportError:
PrintFailedImport(' cairo ', MIN_CAIRO_VER, NOT_FOUND_STR) PrintFailedImport(' cairo ', MIN_CAIRO_VER, NOT_FOUND_STR)
@ -301,7 +301,7 @@ def Import_pyGtkIntoPython():
try: try:
import Gtk.glade import Gtk.glade
log.info( ' Glade tesing import of libglade .......\tOK\n' ) log.info( ' Glade tesing import of libglade .......\tOK\n' )
except ImportError, e: except ImportError as e:
log.info( ' Glade importError: %s\n' % e ) log.info( ' Glade importError: %s\n' % e )
if __name__ == '__main__': if __name__ == '__main__':
@ -311,7 +311,7 @@ Usage:
Arguments: Arguments:
gtkPath Path to your GTK installation directory (not the bin dir) gtkPath Path to your GTK installation directory (not the bin dir)
Options: Options:
None None
''' %(os.path.basename(__file__) ) ''' %(os.path.basename(__file__) )
@ -332,14 +332,14 @@ Options:
sys.exit(0) sys.exit(0)
if len(args) > 1: if len(args) > 1:
raise getopt.GetoptError, '\nERROR: Too many arguments' raise getopt.GetoptError('\nERROR: Too many arguments')
for arg in args: for arg in args:
if os.path.isdir(arg): if os.path.isdir(arg):
gtkPath = arg gtkPath = arg
else: else:
raise getopt.GetoptError, '\nERROR: Not a valid GTK path %s' % arg raise getopt.GetoptError('\nERROR: Not a valid GTK path %s' % arg)
except getopt.GetoptError, msg: except getopt.GetoptError as msg:
log.info( msg ) log.info( msg )
log.info( '\n %s' % usage ) log.info( '\n %s' % usage )
sys.exit(2) sys.exit(2)
@ -354,7 +354,7 @@ Options:
OS type : %s''' % winver) OS type : %s''' % winver)
else: else:
os.info( winver ) os.info( winver )
if gtkPath: if gtkPath:
gtkPathInRegistry = gtkPath gtkPathInRegistry = gtkPath
dllPathInRegistry = os.path.join(gtkPath, 'bin') dllPathInRegistry = os.path.join(gtkPath, 'bin')
@ -367,6 +367,6 @@ Options:
FindLibsWithCtypes() FindLibsWithCtypes()
CheckPathForOtherGtkInstalls() CheckPathForOtherGtkInstalls()
Import_pyGtkIntoPython() Import_pyGtkIntoPython()
CheckWithDependencyWalker() CheckWithDependencyWalker()

View File

@ -86,28 +86,28 @@ def GetGtkPath():
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\GTK\\2.0') as key: with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\GTK\\2.0') as key:
dllPathInRegistry = _winreg.QueryValueEx(key, 'DllPath')[0] dllPathInRegistry = _winreg.QueryValueEx(key, 'DllPath')[0]
# check a few key files exist at this location # check a few key files exist at this location
gtkfiles = ['libgdk-win32-2.0-0.dll', 'libglib-2.0-0.dll', 'libgobject-2.0-0.dll', 'libcairo-2.dll'] gtkfiles = ['libgdk-win32-2.0-0.dll', 'libglib-2.0-0.dll', 'libgobject-2.0-0.dll', 'libcairo-2.dll']
for file in gtkfiles: for file in gtkfiles:
if not os.path.isfile(os.path.join(dllPathInRegistry, file)): if not os.path.isfile(os.path.join(dllPathInRegistry, file)):
dllPathInRegistry = None # one of the files not present, so assume path is wrong dllPathInRegistry = None # one of the files not present, so assume path is wrong
break break
except WindowsError, e: except WindowsError as e:
dllPathInRegistry = None dllPathInRegistry = None
log.debug(' DLLPATH=%s'%dllPathInRegistry) log.debug(' DLLPATH=%s'%dllPathInRegistry)
return dllPathInRegistry return dllPathInRegistry
def GetGrampsPath(): def GetGrampsPath():
GrampsPathInRegistry = None GrampsPathInRegistry = None
try: try:
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\GRAMPS') as key: with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\GRAMPS') as key:
GrampsPathInRegistry = _winreg.QueryValue(key, '') GrampsPathInRegistry = _winreg.QueryValue(key, '')
# check a few key files exist at this location # check a few key files exist at this location
except WindowsError, e: except WindowsError as e:
GrampsPathInRegistry = None GrampsPathInRegistry = None
log.debug(' GRAMPSPATH=%s'%GrampsPathInRegistry) log.debug(' GRAMPSPATH=%s'%GrampsPathInRegistry)
return GrampsPathInRegistry return GrampsPathInRegistry
def GetLanguageFromLocale(): def GetLanguageFromLocale():
lang = ' ' lang = ' '
try: try:
@ -124,18 +124,18 @@ def GetLanguageFromLocale():
def writeLauncher(language, langcode, runtimepath, grampspath): def writeLauncher(language, langcode, runtimepath, grampspath):
lines = [] lines = []
lines.append('''@rem Setting the working language lines.append('''@rem Setting the working language
@rem ============================ @rem ============================
@rem GRAMPS looks during the start-up-phase for an environment variable (called LANG) @rem GRAMPS looks during the start-up-phase for an environment variable (called LANG)
@rem to switch to a special language. It's better to use a ".CMD" or ".BAT" file to @rem to switch to a special language. It's better to use a ".CMD" or ".BAT" file to
@rem control this environment variable instead a permanent setting in the windows registry, @rem control this environment variable instead a permanent setting in the windows registry,
@rem to have the possibility to go back to the GRAMPS standard language (English) in the @rem to have the possibility to go back to the GRAMPS standard language (English) in the
@rem case you want to report about a problem or a bug. @rem case you want to report about a problem or a bug.
''') ''')
lines.append('\n@rem Set GRAMPS environment settings to %s \n' % language) lines.append('\n@rem Set GRAMPS environment settings to %s \n' % language)
lines.append('SET LANG=$LANG$ \nSET LANGUAGE=$LANG$\n'.replace("$LANG$", langcode) ) lines.append('SET LANG=$LANG$ \nSET LANGUAGE=$LANG$\n'.replace("$LANG$", langcode) )
lines.append('''\n\n@rem Setting the configuration path lines.append('''\n\n@rem Setting the configuration path
@rem ============================== @rem ==============================
@rem During the boot process of GRAMPS there is a check for an environment variable @rem During the boot process of GRAMPS there is a check for an environment variable
@rem called GRAMPSHOME. Without this environment variable GRAMPS uses the default @rem called GRAMPSHOME. Without this environment variable GRAMPS uses the default
@rem windows path as the location to save all configuration files: @rem windows path as the location to save all configuration files:
@ -158,7 +158,7 @@ def writeLauncher(language, langcode, runtimepath, grampspath):
lines.append(path) lines.append(path)
lines.append('''\n\n@rem Start GRAMPS application lines.append('''\n\n@rem Start GRAMPS application
@rem ========================= @rem =========================
@rem Start GRAMPS with pythonw.exe (Python interpreter that runs without a command line console) @rem Start GRAMPS with pythonw.exe (Python interpreter that runs without a command line console)
''') ''')
lines.append('\n@rem start Gramps') lines.append('\n@rem start Gramps')
lines.append('\n"%s" "%s"\n' % (os.path.join(sys.prefix, 'pythonw.exe') , os.path.join(grampspath, 'gramps.py' ) )) lines.append('\n"%s" "%s"\n' % (os.path.join(sys.prefix, 'pythonw.exe') , os.path.join(grampspath, 'gramps.py' ) ))
@ -166,7 +166,7 @@ def writeLauncher(language, langcode, runtimepath, grampspath):
fout.writelines(lines) fout.writelines(lines)
fout.close() fout.close()
for line in lines: for line in lines:
print line print(line)
gtkpath = GetGtkPath() gtkpath = GetGtkPath()
grampspath = GetGrampsPath() grampspath = GetGrampsPath()
@ -174,10 +174,10 @@ lang = GetLanguageFromLocale()
if lang: if lang:
try: try:
lang_text = langLookup[lang.split('_', 1)[0]] lang_text = langLookup[lang.split('_', 1)[0]]
except KeyError, e: except KeyError as e:
try: try:
lang_text = langLookup[lang] lang_text = langLookup[lang]
except KeyError, e: except KeyError as e:
lang_text = "Unknown" lang_text = "Unknown"
writeLauncher(lang_text, "%s.utf-8"%lang, gtkpath, grampspath) writeLauncher(lang_text, "%s.utf-8"%lang, gtkpath, grampspath)

View File

@ -44,7 +44,7 @@ try:
gobjectver_str = 'found %d.%d.%d' % GObject.pygobject_version gobjectver_str = 'found %d.%d.%d' % GObject.pygobject_version
except :# any failure to 'get' the version except :# any failure to 'get' the version
gobjectver_str = 'unknown version' gobjectver_str = 'unknown version'
except ImportError: except ImportError:
gobjectver_str = 'not found' gobjectver_str = 'not found'
@ -55,12 +55,12 @@ try:
cairover_str = 'found %d.%d.%d' % cairo.version_info cairover_str = 'found %d.%d.%d' % cairo.version_info
except :# any failure to 'get' the version except :# any failure to 'get' the version
cairover_str = 'unknown version' cairover_str = 'unknown version'
except ImportError: except ImportError:
cairover_str = 'not found' cairover_str = 'not found'
print 'python:%s;'%py_str print('python:%s;'%py_str)
print 'gtk++:%s;'%gtkver_str print('gtk++:%s;'%gtkver_str)
print 'pygtk:%s;'%pygtkver_str print('pygtk:%s;'%pygtkver_str)
print 'gobject:%s;'%gobjectver_str print('gobject:%s;'%gobjectver_str)
print 'cairo:%s;'%cairover_str print('cairo:%s;'%cairover_str)

View File

@ -34,83 +34,83 @@ explain_exposed = ''' *******************************************************
* to the operating system as they are in the environment * to the operating system as they are in the environment
* path variable BEFORE the runtime directory. * path variable BEFORE the runtime directory.
* You should reorder the path variable to put your GTK * You should reorder the path variable to put your GTK
* runtime path before these other installations on the path''' * runtime path before these other installations on the path'''
explain_safe = ''' *************************************************************** explain_safe = ''' ***************************************************************
* While there are other installations of GTK DLL's on the path, * While there are other installations of GTK DLL's on the path,
* it should be safe as they are on the path AFTER the runtime * it should be safe as they are on the path AFTER the runtime
* directory. ''' * directory. '''
def RunExeCommand( app, args ): def RunExeCommand( app, args ):
cmd = app + ' ' + args cmd = app + ' ' + args
#print "Running: ", cmd #print("Running: ", cmd)
stdin, stdout, stderr = os.popen3( cmd ) stdin, stdout, stderr = os.popen3( cmd )
output = string.strip(stdout.read()) output = string.strip(stdout.read())
#print output #print(output)
err = stderr.read() err = stderr.read()
if err: if err:
print err print(err)
return output return output
def CheckGtkInReg(): def CheckGtkInReg():
global gtkPathInRegistry, gtkVersionInRegistry, dllPathInRegistry, dllPathShort global gtkPathInRegistry, gtkVersionInRegistry, dllPathInRegistry, dllPathShort
print '\n==== Checking Registry for GTK =====' print('\n==== Checking Registry for GTK =====')
try: try:
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\GTK\\2.0') as key: with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\GTK\\2.0') as key:
gtkVersionInRegistry = _winreg.QueryValueEx(key, 'Version')[0] gtkVersionInRegistry = _winreg.QueryValueEx(key, 'Version')[0]
gtkPathInRegistry = _winreg.QueryValueEx(key, 'Path')[0] gtkPathInRegistry = _winreg.QueryValueEx(key, 'Path')[0]
dllPathInRegistry = _winreg.QueryValueEx(key, 'DllPath')[0] dllPathInRegistry = _winreg.QueryValueEx(key, 'DllPath')[0]
print ' Version :', gtkVersionInRegistry print(' Version :', gtkVersionInRegistry)
print ' Path :', gtkPathInRegistry print(' Path :', gtkPathInRegistry)
print ' DllPath :', dllPathInRegistry print(' DllPath :', dllPathInRegistry)
except WindowsError, e: except WindowsError as e:
print '\n GTK registry key not found in registry' print('\n GTK registry key not found in registry')
print ''' ******************************************************************** print(''' ********************************************************************
* This might not be an error, but means I don't know the directory to * This might not be an error, but means I don't know the directory to
* your preferred GTK installation. * your preferred GTK installation.
* - try passing in your GTK installation path.\n''' * - try passing in your GTK installation path.\n''')
print '-' * 60 print('-' * 60)
print usage print(usage)
sys.exit(0) sys.exit(0)
def WorkOutShortDosPath(): def WorkOutShortDosPath():
global dllPathShort global dllPathShort
print '\n==== Use win32Api to query short path name for GTK =====' print('\n==== Use win32Api to query short path name for GTK =====')
try: try:
import win32api import win32api
dllPathShort = win32api.GetShortPathName(dllPathInRegistry) dllPathShort = win32api.GetShortPathName(dllPathInRegistry)
print ' DllPath8.3:', dllPathShort print(' DllPath8.3:', dllPathShort)
except ImportError: except ImportError:
print ' **Cant query short path name, Win32Api not installed' print(' **Cant query short path name, Win32Api not installed')
print ' install from http://python.net/crew/mhammond/win32/' print(' install from http://python.net/crew/mhammond/win32/')
print ' if you want this function to work' print(' if you want this function to work')
def FindLibsWithCtypes(): def FindLibsWithCtypes():
# use ctypes to check where windows finds it's DLL's # use ctypes to check where windows finds it's DLL's
print '\n==== Use ctypes to find dlls ====' print('\n==== Use ctypes to find dlls ====')
other_paths = [] other_paths = []
for dll in testdlls: for dll in testdlls:
dllpathvalid = False dllpathvalid = False
cpath = find_library(dll) cpath = find_library(dll)
if cpath: if cpath:
#print cpath #print(cpath)
if cpath == os.path.join(dllPathInRegistry, dll) \ if cpath == os.path.join(dllPathInRegistry, dll) \
or cpath == os.path.join(dllPathShort, dll): or cpath == os.path.join(dllPathShort, dll):
dllpathvalid = True dllpathvalid = True
if not dllpathvalid: if not dllpathvalid:
pp = os.path.dirname(cpath) pp = os.path.dirname(cpath)
if pp not in other_paths: if pp not in other_paths:
other_paths.append(pp) other_paths.append(pp)
else: else:
print " ERROR:... ctypes failed to find %s" % dll print(" ERROR:... ctypes failed to find %s" % dll)
if other_paths: if other_paths:
for pth in other_paths: for pth in other_paths:
print " ERROR: ctypes loaded some gtk dll's from %s" % pth print(" ERROR: ctypes loaded some gtk dll's from %s" % pth)
else: else:
print " OK ... ctypes found dll's in %s" % os.path.dirname(cpath) print(" OK ... ctypes found dll's in %s" % os.path.dirname(cpath))
def ScanDependencyFileForErrors(fname): def ScanDependencyFileForErrors(fname):
fin = open(fname, 'r') fin = open(fname, 'r')
lines = fin.readlines() lines = fin.readlines()
@ -135,36 +135,36 @@ def ScanDependencyFileForErrors(fname):
if dirname.startswith(os.path.join(sysroot, 'winsxs').lower()) \ if dirname.startswith(os.path.join(sysroot, 'winsxs').lower()) \
or dirname.startswith(os.path.join(sys.prefix, 'lib\site-packages\gtk-2.0').lower()): or dirname.startswith(os.path.join(sys.prefix, 'lib\site-packages\gtk-2.0').lower()):
OK = True OK = True
for pth in acceptablePaths: for pth in acceptablePaths:
if dirname == pth.lower(): if dirname == pth.lower():
OK = True OK = True
if 'MSVCR90.DLL' in filename: if 'MSVCR90.DLL' in filename:
if parts[0] == 'Error': if parts[0] == 'Error':
runtimedlls[filename] = "Error dll not found" runtimedlls[filename] = "Error dll not found"
else: else:
runtimedlls[filename] = parts[16] runtimedlls[filename] = parts[16]
if OK == False: if OK == False:
if parts[0] == 'Error': if parts[0] == 'Error':
print " %s \tError dll not found" %( filename) print(" %s \tError dll not found" %( filename))
else: else:
print " ERROR: %s \tVersion %s" %( filename, parts[16]) print(" ERROR: %s \tVersion %s" %( filename, parts[16]))
for rtdll in runtimedlls: for rtdll in runtimedlls:
if runtimedlls[rtdll].startswith("Error"): if runtimedlls[rtdll].startswith("Error"):
print '\n ERROR: MS runtime %s not found'%rtdll print('\n ERROR: MS runtime %s not found'%rtdll)
else: else:
print '\n MS runtime Version %s loaded from' % runtimedlls[rtdll] print('\n MS runtime Version %s loaded from' % runtimedlls[rtdll])
print " %s" %rtdll print(" %s" %rtdll)
print print()
def CheckWithDependencyWalker(): def CheckWithDependencyWalker():
print '\n==== Checking with Dependency Walker ====' print('\n==== Checking with Dependency Walker ====')
print ' Please be patient takes some time' print(' Please be patient takes some time')
exe = os.path.join(scriptpath, 'depends.exe') exe = os.path.join(scriptpath, 'depends.exe')
fout = os.path.join(scriptpath, 'depres.txt') fout = os.path.join(scriptpath, 'depres.txt')
f2check = [ f2check = [
os.path.join(sys.prefix, 'Lib/site-packages/gtk-2.0/gtk/_Gtk.pyd' ), os.path.join(sys.prefix, 'Lib/site-packages/gtk-2.0/gtk/_Gtk.pyd' ),
os.path.join(sys.prefix, 'Lib/site-packages/gtk-2.0/gobject/_GObject.pyd' ), os.path.join(sys.prefix, 'Lib/site-packages/gtk-2.0/gobject/_GObject.pyd' ),
os.path.join(sys.prefix, 'Lib/site-packages/gtk-2.0/pangocairo.pyd' ), os.path.join(sys.prefix, 'Lib/site-packages/gtk-2.0/pangocairo.pyd' ),
@ -175,28 +175,28 @@ def CheckWithDependencyWalker():
#delete the output file before running command #delete the output file before running command
try: try:
os.remove(fout) os.remove(fout)
except WindowsError, e: except WindowsError as e:
pass pass
print ' Testing file %s' % ftest print(' Testing file %s' % ftest)
out = RunExeCommand(exe, '/c /f1 /ot "%s" "%s"' % (fout, ftest) ) out = RunExeCommand(exe, '/c /f1 /ot "%s" "%s"' % (fout, ftest) )
if os.path.isfile(fout): if os.path.isfile(fout):
ScanDependencyFileForErrors(fout) ScanDependencyFileForErrors(fout)
else: else:
print " ERROR: file %d does not exist", ftest print(" ERROR: file %d does not exist", ftest)
else: else:
print ' Cannot check with dependency walker, not installed in local directory' print(' Cannot check with dependency walker, not installed in local directory')
print ' get dependency walker from http://www.dependencywalker.com/' print(' get dependency walker from http://www.dependencywalker.com/')
print ' and unzip into this directory for it to work.' print(' and unzip into this directory for it to work.')
def CheckPathForOtherGtkInstalls(): def CheckPathForOtherGtkInstalls():
print '\n====Checking environment path for other gtk installations====' print('\n====Checking environment path for other gtk installations====')
ePath = os.environ['path'] ePath = os.environ['path']
dirs = ePath.split(';') dirs = ePath.split(';')
gtkpth_idx = 9999 gtkpth_idx = 9999
other_paths = [] other_paths = []
explain_level = 0 explain_level = 0
for i, d in enumerate(dirs): for i, d in enumerate(dirs):
#print '==%s==' %d #print('==%s==' %d)
if d == gtkPathInRegistry or d == dllPathInRegistry\ if d == gtkPathInRegistry or d == dllPathInRegistry\
or d == dllPathShort: or d == dllPathShort:
gtkpth_idx = i gtkpth_idx = i
@ -204,26 +204,26 @@ def CheckPathForOtherGtkInstalls():
for fname in testdlls: for fname in testdlls:
f = os.path.join(d, fname) f = os.path.join(d, fname)
if os.path.isfile( f ): if os.path.isfile( f ):
#print ' Found Erronous gtk DLL %s' % f #print(' Found Erronous gtk DLL %s' % f)
if d not in other_paths: if d not in other_paths:
other_paths.append(d) other_paths.append(d)
if i < gtkpth_idx: # path appears BEFORE runtime path if i < gtkpth_idx: # path appears BEFORE runtime path
print ' ERROR: %s should not appear before runtime path' % d print(' ERROR: %s should not appear before runtime path' % d)
explain_level = 2 explain_level = 2
else: else:
print ' FOUND: %s, Probably OK as appears AFTER runtime path' % d print(' FOUND: %s, Probably OK as appears AFTER runtime path' % d)
if explain_level <= 1: if explain_level <= 1:
explain_level = 1 explain_level = 1
if gtkpth_idx == 9999: if gtkpth_idx == 9999:
print '\n ERROR: Runtime directory not on enviroment path' print('\n ERROR: Runtime directory not on enviroment path')
print " ** Runtime needs to be on path to load DLL's from\n" print(" ** Runtime needs to be on path to load DLL's from\n")
if explain_level == 2: if explain_level == 2:
print explain_exposed print(explain_exposed)
elif explain_level == 1: elif explain_level == 1:
print explain_safe print(explain_safe)
if len(other_paths) == 0: if len(other_paths) == 0:
print ' No other gtk installatons found\n' print(' No other gtk installatons found\n')
# ==== report what python thinks it's using ===== # ==== report what python thinks it's using =====
MIN_PYTHON_VER = (2,5,1) MIN_PYTHON_VER = (2,5,1)
UNTESTED_PYTHON_VER = (3,0,0) UNTESTED_PYTHON_VER = (3,0,0)
@ -241,45 +241,45 @@ MIN_CAIRO_VER = (1,2,6)
UNTESTED_CAIRO_VER = (1,4,13) UNTESTED_CAIRO_VER = (1,4,13)
def PrintFailedImport(appl, minVersion, result): def PrintFailedImport(appl, minVersion, result):
print appl, print(appl,)
print 'version %d.%d.%d or above.....\t' % minVersion , print('version %d.%d.%d or above.....\t' % minVersion ,)
print result print(result)
def PrintVersionResult(appl, minVersion, actualVersion, untestedVersion): def PrintVersionResult(appl, minVersion, actualVersion, untestedVersion):
print appl, print(appl,)
print 'version %d.%d.%d or above.....\t' % minVersion , print('version %d.%d.%d or above.....\t' % minVersion ,)
print 'found %d.%d.%d' % actualVersion , print('found %d.%d.%d' % actualVersion ,)
if minVersion <= actualVersion < untestedVersion: if minVersion <= actualVersion < untestedVersion:
print '...OK' print('...OK')
elif actualVersion >= untestedVersion: elif actualVersion >= untestedVersion:
print '...UNTESTED VERSION' print('...UNTESTED VERSION')
else: else:
print '...FAILED' print('...FAILED')
def Import_pyGtkIntoPython(): def Import_pyGtkIntoPython():
print '\n==== Test import into python ====' print('\n==== Test import into python ====')
#py_str = 'found %d.%d.%d' % sys.version_info[:3] #py_str = 'found %d.%d.%d' % sys.version_info[:3]
PrintVersionResult(' Python ', MIN_PYTHON_VER, sys.version_info[:3], UNTESTED_PYTHON_VER) PrintVersionResult(' Python ', MIN_PYTHON_VER, sys.version_info[:3], UNTESTED_PYTHON_VER)
# Test the GTK version # Test the GTK version
try: try:
import gtk import gtk
PrintVersionResult(' GTK+ ', MIN_GTK_VER, Gtk.gtk_version, UNTESTED_GTK_VER ) PrintVersionResult(' GTK+ ', MIN_GTK_VER, Gtk.gtk_version, UNTESTED_GTK_VER )
#test the pyGTK version (which is in the gtk namespace) #test the pyGTK version (which is in the gtk namespace)
PrintVersionResult(' pyGTK ', MIN_PYGTK_VER, Gtk.pygtk_version, UNTESTED_PYGTK_VER ) PrintVersionResult(' pyGTK ', MIN_PYGTK_VER, Gtk.pygtk_version, UNTESTED_PYGTK_VER )
except ImportError: except ImportError:
PrintFailedImport(' GTK+ ', MIN_GTK_VER, NOT_FOUND_STR) PrintFailedImport(' GTK+ ', MIN_GTK_VER, NOT_FOUND_STR)
PrintFailedImport(' pyGTK ', MIN_PYGTK_VER, 'Cannot test, ...GTK+ missing') PrintFailedImport(' pyGTK ', MIN_PYGTK_VER, 'Cannot test, ...GTK+ missing')
#test the gobject version #test the gobject version
try: try:
import gobject import gobject
PrintVersionResult(' gobject', MIN_GOBJECT_VER, GObject.pygobject_version, UNTESTED_GOBJECT_VER) PrintVersionResult(' gobject', MIN_GOBJECT_VER, GObject.pygobject_version, UNTESTED_GOBJECT_VER)
except ImportError: except ImportError:
PrintFailedImport(' gobject', MIN_GOBJECT_VER, NOT_FOUND_STR) PrintFailedImport(' gobject', MIN_GOBJECT_VER, NOT_FOUND_STR)
@ -288,18 +288,18 @@ def Import_pyGtkIntoPython():
try: try:
import cairo import cairo
PrintVersionResult(' cairo ', MIN_CAIRO_VER, cairo.version_info, UNTESTED_CAIRO_VER ) PrintVersionResult(' cairo ', MIN_CAIRO_VER, cairo.version_info, UNTESTED_CAIRO_VER )
except ImportError: except ImportError:
PrintFailedImport(' cairo ', MIN_CAIRO_VER, NOT_FOUND_STR) PrintFailedImport(' cairo ', MIN_CAIRO_VER, NOT_FOUND_STR)
#test for glade #test for glade
print '\n==== See if libglade installed ====' print('\n==== See if libglade installed ====')
try: try:
import Gtk.glade import Gtk.glade
print ' Glade tesing import of libglade .......\tOK\n' print(' Glade tesing import of libglade .......\tOK\n')
except ImportError, e: except ImportError as e:
print ' Glade importError: %s\n' % e print(' Glade importError: %s\n' % e)
if __name__ == '__main__': if __name__ == '__main__':
usage = '''Check for common problems in GTK/pyGTK installation. usage = '''Check for common problems in GTK/pyGTK installation.
@ -308,7 +308,7 @@ Usage:
Arguments: Arguments:
gtkPath Path to your GTK installation directory (not the bin dir) gtkPath Path to your GTK installation directory (not the bin dir)
Options: Options:
None None
''' %(os.path.basename(__file__) ) ''' %(os.path.basename(__file__) )
@ -325,38 +325,38 @@ Options:
for o, a in opts: for o, a in opts:
if o in ("-h", "--help"): if o in ("-h", "--help"):
print usage print(usage)
sys.exit(0) sys.exit(0)
if len(args) > 1: if len(args) > 1:
raise getopt.GetoptError, '\nERROR: Too many arguments' raise getopt.GetoptError('\nERROR: Too many arguments')
for arg in args: for arg in args:
if os.path.isdir(arg): if os.path.isdir(arg):
gtkPath = arg gtkPath = arg
else: else:
raise getopt.GetoptError, '\nERROR: Not a valid GTK path %s' % arg raise getopt.GetoptError('\nERROR: Not a valid GTK path %s' % arg)
except getopt.GetoptError, msg: except getopt.GetoptError as msg:
print msg print(msg)
print '\n %s' % usage print('\n %s' % usage)
sys.exit(2) sys.exit(2)
import platform import platform
winver = platform.win32_ver() winver = platform.win32_ver()
if len(winver) == 4: if len(winver) == 4:
print '''\n==== platform.win32_ver() reports ==== print('''\n==== platform.win32_ver() reports ====
Operating System: %s Operating System: %s
Version : %s Version : %s
Service Pack : %s Service Pack : %s
OS type : %s''' % winver OS type : %s''' % winver)
else: else:
print winver print(winver)
if gtkPath: if gtkPath:
gtkPathInRegistry = gtkPath gtkPathInRegistry = gtkPath
dllPathInRegistry = os.path.join(gtkPath, 'bin') dllPathInRegistry = os.path.join(gtkPath, 'bin')
print ' Using %s as GTK install path' % gtkPathInRegistry print(' Using %s as GTK install path' % gtkPathInRegistry)
print ' Using %s as GTK dll path' % dllPathInRegistry print(' Using %s as GTK dll path' % dllPathInRegistry)
else: else:
CheckGtkInReg() CheckGtkInReg()
@ -364,6 +364,6 @@ Options:
FindLibsWithCtypes() FindLibsWithCtypes()
CheckPathForOtherGtkInstalls() CheckPathForOtherGtkInstalls()
Import_pyGtkIntoPython() Import_pyGtkIntoPython()
CheckWithDependencyWalker() CheckWithDependencyWalker()