예제 #1
0
	def installDatabaseUpdates(self):
		currVersion = globalConf.getValueI('dbVersion')
		files = self.getAvailableUpdates()
		pattern = re.compile(r'(#V)(\d*)$') #e.g. #V0001
		
		for f in files:
			with open('%s'%f, 'r') as content_file:
				lines = content_file.readlines()
			
			match = pattern.match(lines[0])
			if not match:
				raise UnversionedSQLFileError('No version found in %s'%f)
			
			groups = match.groups()
			if not groups:
				raise UnversionedSQLFileError('Versionstring "%s" invalid in file %s'%(lines[0], f))
			
			fileVersion = int(groups[1])
			
			
			if fileVersion <= currVersion:
				break
			
			self.runScript(lines)
		
		globalConf.setValueI('dbVersion', version.VERSION)
		
		return True
예제 #2
0
	def checkForDatabaseUpdates(self):
		currVersion = globalConf.getValueI('dbVersion')
		
		if currVersion < version.VERSION:
			updates = self.getAvailableUpdates()
			if len(updates):
				return True
		
		return False