Merge. wip
authorJon Chatten
Mon, 08 Mar 2010 12:49:20 +0000
branchwip
changeset 348 7e804508da51
parent 347 018461a64038 (current diff)
parent 346 d677c6f132ae (diff)
child 349 a5741f22d0a5
Merge.
--- a/sbsv2/raptor/bin/sbs_env.bat	Fri Mar 05 14:37:08 2010 +0000
+++ b/sbsv2/raptor/bin/sbs_env.bat	Mon Mar 08 12:49:20 2010 +0000
@@ -1,29 +1,29 @@
-@rem
-@rem Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-@rem All rights reserved.
-@rem This component and the accompanying materials are made available
-@rem under the terms of the License "Eclipse Public License v1.0"
-@rem which accompanies this distribution, and is available
-@rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
-@rem
-@rem Initial Contributors:
-@rem Nokia Corporation - initial contribution.
-@rem
-@rem Contributors:
-@rem
-@rem Description: 
-@rem
+@REM
+@REM Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+@REM All rights reserved.
+@REM This component and the accompanying materials are made available
+@REM under the terms of the License "Eclipse Public License v1.0"
+@REM which accompanies this distribution, and is available
+@REM at the URL "http://www.eclipse.org/legal/epl-v10.html".
+@REM
+@REM Initial Contributors:
+@REM Nokia Corporation - initial contribution.
+@REM
+@REM Contributors:
+@REM
+@REM Description: 
+@REM
 
 @SET HOSTPLATFORM=win 32
 @SET HOSTPLATFORM_DIR=win32
 
 @REM Automatically find SBS_HOME if it is not set
-@IF NOT "%SBS_HOME%"==""  goto foundhome
+@IF NOT "%SBS_HOME%"=="" GOTO foundhome
 @SET RAPTORBINDIR=%~dp0
-@SET WD=%cd%
-@cd /d %RAPTORBINDIR%\..
-@SET SBS_HOME=%cd%
-@cd /d %WD%
+@SET WD=%CD%
+@CD /d %RAPTORBINDIR%\..
+@SET SBS_HOME=%CD%
+@CD /d %WD%
 :foundhome 
 
 @REM The python and PYTHONPATH used by Raptor are determined by, in order of precedence:
@@ -52,17 +52,6 @@
 @SET __MINGW__=%SBS_MINGW%
 @IF "%__MINGW__%"=="" SET __MINGW__=%SBS_HOME%\win32\mingw
 
-@REM Use the cygwin set by the environment if possible
-@SET __CYGWIN__=%SBS_CYGWIN%
-@IF "%__CYGWIN__%"=="" SET __CYGWIN__=%SBS_HOME%\win32\cygwin
-
-@REM add to the search path
-@REM (make sure that we don't get into trouble if there are Path and PATH variables)
-@SET PATH_TEMP=%__MINGW__%\bin;%__CYGWIN__%\bin;%SBS_HOME%\win32\bin;%PATH%
-@SET PATH=
-@SET PATH=%PATH_TEMP%
-@SET PATH_TEMP=
-
 @REM Tell CYGWIN not to map unix security attributes to windows to
 @REM prevent raptor from potentially creating read-only files.
 @REM Assume Cygwin 1.5 CLI.
@@ -70,12 +59,23 @@
 @SET __UMOUNTOPTIONS__=-u
 @SET CYGWIN=nontsec nosmbntsec
 
+@REM If SBS_CYGWIN17 is set, we are using Cygwin 1.7, so change the mount/umount 
+@REM options to the 1.7 CLI and set SBS_CYGWIN to the value of SBS_CYGWIN17
+@IF NOT "%SBS_CYGWIN17%" == "" SET CYGWIN=nodosfilewarning && SET "SBS_CYGWIN=%SBS_CYGWIN17%" && SET __MOUNTOPTIONS__=-o noacl -o user && SET __UMOUNTOPTIONS__=
+
+@REM Use the Cygwin set by the environment (from SBS_CYGWIN or SBS_CYGWIN17) if possible
+@SET __CYGWIN__=%SBS_CYGWIN%
+@IF "%__CYGWIN__%"=="" SET __CYGWIN__=%SBS_HOME%\win32\cygwin
+
+@REM Add to the search path
+@REM (make sure that we don't get into trouble if there are Path and PATH variables)
+@SET PATH_TEMP=%__MINGW__%\bin;%__CYGWIN__%\bin;%SBS_HOME%\win32\bin;%PATH%
+@SET PATH=
+@SET PATH=%PATH_TEMP%
+@SET PATH_TEMP=
+
 @REM Make sure that /tmp is not set incorrectly for sbs. 
 @umount %__UMOUNTOPTIONS__% /tmp >NUL  2>NUL
-
-@REM If this fails, that means we are using Cygwin 1.7, so change the options and redo the first umount
-@IF %ERRORLEVEL% == 1 SET CYGWIN=nodosfilewarning && SET __MOUNTOPTIONS__=-o noacl -o user && SET __UMOUNTOPTIONS__=&& umount %__UMOUNTOPTIONS__% /tmp >NUL  2>NUL
-
 @mount %__MOUNTOPTIONS__% %TEMP% /tmp >NUL 2>NUL
 @umount %__UMOUNTOPTIONS__% / >NUL  2>NUL
 @mount %__MOUNTOPTIONS__% %__CYGWIN__% / >NUL 2>NUL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sbsv2/raptor/python/plugins/filter_bz2log.py	Mon Mar 08 12:49:20 2010 +0000
@@ -0,0 +1,88 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+# Compress the full Raptor log file using the BZip2 algorithm, maximum compression.
+# 
+#
+
+import os
+import sys
+import raptor
+import filter_interface
+import bz2
+
+class StringListCompressor(object):
+	def __init__(self, complevel=5, filename="file.log.bz2"):
+		self.compressor = bz2.BZ2Compressor(complevel)
+		self.stringlist = []
+		self.outputopenedok = False
+		self.filename = filename
+		try:
+			self.fh = open(self.filename, "wb")
+			self.outputopenedok = True
+		except:
+			self.outputopenedok = False
+	
+	def write(self, data):
+		if self.outputopenedok:
+			compresseddata = self.compressor.compress(data)
+			self.fh.write(compresseddata)
+	
+	def __del__(self):
+		if self.outputopenedok:
+			compresseddata = self.compressor.flush()
+			self.fh.write(compresseddata)
+			self.fh.close()
+
+class Bz2log(filter_interface.Filter):
+	def __init__(self):
+		self.__inRecipe = False
+		self.compressor = None
+
+	def open(self, raptor_instance):
+		"""Open a log file for the various I/O methods to write to."""
+		
+		if raptor_instance.logFileName == None:
+			self.out = sys.stdout # Default to stdout if no log file is given
+		else:
+			logname = str(raptor_instance.logFileName.path.replace("%TIME", raptor_instance.timestring))
+			
+			# Ensure that filename has the right extension; append ".bz2" if required
+			if not logname.lower().endswith(".bz2"):
+				logname += ".bz2"
+
+			try:
+				dirname = str(raptor_instance.logFileName.Dir())
+				if dirname and not os.path.isdir(dirname):
+					os.makedirs(dirname)
+			except:
+				self.formatError("cannot create directory %s", dirname)
+				return False
+			
+			# Use highest compression level 9 which corresponds to a 900KB dictionary
+			self.compressor = StringListCompressor(9, logname)
+			if not self.compressor.outputopenedok:
+				self.out = None
+				self.formatError("failed to initialise compression routines." )
+				return False
+		return True
+		
+	def write(self, data):
+		"""Write data compressed log"""
+		if self.compressor:
+			self.compressor.write(data)
+		return True
+	
+	def close(self):
+		"""Close the log file"""
+		return True