Don't just assume that the metadata files will be found
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30165 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -42,25 +42,39 @@ COMMON_FILES = [ '/usr/local/bin/*',
 | 
				
			|||||||
class AccessError(Exception):
 | 
					class AccessError(Exception):
 | 
				
			||||||
    pass
 | 
					    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ReceiptError(Exception):
 | 
				
			||||||
 | 
					    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class InstalledReceipt(object):
 | 
					class InstalledReceipt(object):
 | 
				
			||||||
    def __init__(self, rcptPath):
 | 
					    def __init__(self, rcptPath):
 | 
				
			||||||
        self.rcptPath = rcptPath
 | 
					        self.rcptPath = rcptPath
 | 
				
			||||||
        self.rsrcPath = os.path.join(rcptPath, RSRCDIR)
 | 
					        self.rsrcPath = os.path.join(rcptPath, RSRCDIR)
 | 
				
			||||||
        self.bomFile = glob.glob(os.path.join(self.rsrcPath, "*.bom"))[0]
 | 
					        bf = glob.glob(os.path.join(self.rsrcPath, "*.bom"))
 | 
				
			||||||
 | 
					        if bf:
 | 
				
			||||||
 | 
					            self.bomFile = bf[0]
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            print "WARNING: Unable to find %s/*.bom" % self.rsrcPath
 | 
				
			||||||
 | 
					            raise ReceiptError
 | 
				
			||||||
        self.findMetaData()
 | 
					        self.findMetaData()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def findMetaData(self):
 | 
					    def findMetaData(self):
 | 
				
			||||||
        # TODO: Make this be able to also look at Info.plist files
 | 
					        # TODO: Make this be able to also look at Info.plist files
 | 
				
			||||||
        infoFile = glob.glob(os.path.join(self.rsrcPath, "*.info"))[0]
 | 
					        infoFiles = glob.glob(os.path.join(self.rsrcPath, "*.info"))
 | 
				
			||||||
        self.mdata = {}
 | 
					        if infoFiles:
 | 
				
			||||||
        for line in open(infoFile, "r").readlines():
 | 
					            # there should be only one
 | 
				
			||||||
            line = line.strip()
 | 
					            infoFile = infoFiles[0]
 | 
				
			||||||
            if line and line[0] != '#':
 | 
					            self.mdata = {}
 | 
				
			||||||
                ls = line.split()
 | 
					            for line in open(infoFile, "r").readlines():
 | 
				
			||||||
                self.mdata[ls[0]] = line[len(ls[0])+1:]
 | 
					                line = line.strip()
 | 
				
			||||||
 | 
					                if line and line[0] != '#':
 | 
				
			||||||
 | 
					                    ls = line.split()
 | 
				
			||||||
 | 
					                    self.mdata[ls[0]] = line[len(ls[0])+1:]
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            print "WARNING: Unable to find %s/*.info" % self.rsrcPath
 | 
				
			||||||
 | 
					            raise ReceiptError
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def getFileList(self):
 | 
					    def getFileList(self):
 | 
				
			||||||
        p = os.popen("lsbom -s %s" % self.bomFile, "r")
 | 
					        p = os.popen("lsbom -s %s" % self.bomFile, "r")
 | 
				
			||||||
@@ -155,8 +169,11 @@ class InstalledReceipt(object):
 | 
				
			|||||||
def findInstalled():
 | 
					def findInstalled():
 | 
				
			||||||
    installed = []
 | 
					    installed = []
 | 
				
			||||||
    for name in glob.glob(os.path.join(RCPTDIR, "wxPython*")):
 | 
					    for name in glob.glob(os.path.join(RCPTDIR, "wxPython*")):
 | 
				
			||||||
        ir = InstalledReceipt(name)
 | 
					        try:
 | 
				
			||||||
        installed.append(ir)
 | 
					            ir = InstalledReceipt(name)
 | 
				
			||||||
 | 
					            installed.append(ir)
 | 
				
			||||||
 | 
					        except ReceiptError:
 | 
				
			||||||
 | 
					            pass  # just skip it...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return installed
 | 
					    return installed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user