Author: remi
Date: 2009-09-16 10:20:08 +0200 (Wed, 16 Sep 2009)
New Revision: 5405
Added:
software_suite_v3/software/gadget/default/trunk/build.bat
software_suite_v3/software/gadget/default/trunk/build.py
software_suite_v3/software/gadget/default/trunk/builder/
software_suite_v3/software/gadget/default/trunk/builder/GadgetPackager.py
software_suite_v3/software/gadget/default/trunk/builder/__init__.py
software_suite_v3/software/gadget/default/trunk/builder/util/
software_suite_v3/software/gadget/default/trunk/builder/util/__init__.py
software_suite_v3/software/gadget/default/trunk/builder/util/misc/
software_suite_v3/software/gadget/default/trunk/builder/util/misc/DirectoriesAndFilesTools.py
software_suite_v3/software/gadget/default/trunk/builder/util/misc/__init__.py
software_suite_v3/software/gadget/default/trunk/builder/util/misc/version.py
software_suite_v3/software/gadget/default/trunk/builder/version.py
Log:
* Added a builder to automatically make scg files
Added: software_suite_v3/software/gadget/default/trunk/build.bat
===================================================================
--- software_suite_v3/software/gadget/default/trunk/build.bat
(rev 0)
+++ software_suite_v3/software/gadget/default/trunk/build.bat 2009-09-16
08:20:08 UTC (rev 5405)
@@ -0,0 +1,2 @@
+python build.py
+cmd
\ No newline at end of file
Added: software_suite_v3/software/gadget/default/trunk/build.py
===================================================================
--- software_suite_v3/software/gadget/default/trunk/build.py
(rev 0)
+++ software_suite_v3/software/gadget/default/trunk/build.py 2009-09-16
08:20:08 UTC (rev 5405)
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+
+# Copyleft (C) 2009 C2ME Sa
+# Remi Jocaille <[email protected]>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+import os
+
+from builder.GadgetPackager import GadgetPackager
+
+gadgetsList = [
+ "gadget_0a58d901-309a-dd6a-e6e7-be691858f9f0",
+ "gadget_2ba0fe92-c73f-61b5-50c5-d8de0aee9194",
+ "gadget_4e139371-e72a-5df7-c272-17d22f1fc258",
+ "gadget_5c5e7e0d-89c5-8799-3175-df2bddf5653c",
+ "gadget_33b14aea-907e-9d9d-7e64-c40c3bbf56fb",
+ "gadget_56cdb050-3bba-d814-32c5-df4b90fee8c3",
+ "gadget_59cce412-9224-639c-d64d-9d25de84b960",
+ "gadget_710c4d99-9a26-b7c4-67e5-dabf78718462",
+ "gadget_84628d00-1e17-62dd-eaa4-7b11436f3211",
+ "gadget_d71cec40-c44e-73d7-e63f-a152986354e0",
+]
+
+#
==============================================================================
+# Class to retrieve the py file path.
+#
==============================================================================
+class localFilePath(object):
+ """Class to retrieve the local file path.
+ """
+ def getPath(self):
+ """Get the local file path.
+ """
+ mPath, mFile = os.path.split(__file__)
+ return mPath
+
+if __name__ == "__main__":
+ basePath = localFilePath().getPath()
+ for gadget in gadgetsList:
+ GadgetPackager().createScg(os.path.join(basePath, gadget))
Added: software_suite_v3/software/gadget/default/trunk/builder/GadgetPackager.py
===================================================================
--- software_suite_v3/software/gadget/default/trunk/builder/GadgetPackager.py
(rev 0)
+++ software_suite_v3/software/gadget/default/trunk/builder/GadgetPackager.py
2009-09-16 08:20:08 UTC (rev 5405)
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+
+import version
+__author__ = version.author
+__date__ = version.date
+__version__ = version.version
+__licence__ = version.licence
+del version
+
+# Copyleft (C) 2009 C2ME Sa
+# Remi Jocaille <[email protected]>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+import os
+from zipfile import *
+
+from util.misc.DirectoriesAndFilesTools import *
+
+#
------------------------------------------------------------------------------
+# Class to create a SCG file from the directory of a smart-core gadget.
+#
------------------------------------------------------------------------------
+class GadgetPackager(object):
+ """Class to create a SCG file from the directory of a smart-core gadget.
+ """
+
+ #
--------------------------------------------------------------------------
+ # Create a scg file.
+ #
--------------------------------------------------------------------------
+ def createScg(self, scgDirectory):
+ """Create a scg file.
+ @param scgDirectory: Smart-Core gadget directory path.
+ @return: The success of the file creation.
+ """
+ self.__sourcePath = os.path.realpath(scgDirectory)
+ if not os.path.isdir(self.__sourcePath):
+ return False
+ # Get some paths
+ TMP_BUILD_PATH = os.path.join(self.__sourcePath, "tmp")
+ DEST_SCG_FILENAME = self.__sourcePath + ".scg"
+ # Create the temporary build path
+ MKDirsF(TMP_BUILD_PATH)
+ # Copy the directory
+ CPDir(self.__sourcePath, TMP_BUILD_PATH)
+ # Filtering the content of temporary path
+ RMWithFilters(TMP_BUILD_PATH, filters = ['.svn',])
+ # Create a zip file
+ directory = TMP_BUILD_PATH
+ last_cwd = os.getcwd()
+ os.chdir(TMP_BUILD_PATH)
+ zf = ZipFile(DEST_SCG_FILENAME, 'w', compression = ZIP_DEFLATED)
+ def walker(zip, directory, files, root = directory):
+ for file in files:
+ file = os.path.join(directory, file)
+ name = file[len(TMP_BUILD_PATH) + 1:]
+ if os.path.isfile(file):
+ zip.write(file, name, ZIP_DEFLATED)
+ elif os.path.isdir(file):
+ file = os.path.join(file, "")
+ name = os.path.join(name, "")
+ zip.writestr(name, name)
+ os.path.walk(TMP_BUILD_PATH, walker, zf)
+ zf.close()
+ os.chdir(os.path.abspath(last_cwd))
+ # Remove the temporary directory
+ RMDirs(TMP_BUILD_PATH)
+ return True
Added: software_suite_v3/software/gadget/default/trunk/builder/__init__.py
===================================================================
Added: software_suite_v3/software/gadget/default/trunk/builder/util/__init__.py
===================================================================
Added:
software_suite_v3/software/gadget/default/trunk/builder/util/misc/DirectoriesAndFilesTools.py
===================================================================
---
software_suite_v3/software/gadget/default/trunk/builder/util/misc/DirectoriesAndFilesTools.py
(rev 0)
+++
software_suite_v3/software/gadget/default/trunk/builder/util/misc/DirectoriesAndFilesTools.py
2009-09-16 08:20:08 UTC (rev 5405)
@@ -0,0 +1,161 @@
+# -*- coding: utf-8 -*-
+
+import version
+__author__ = version.author
+__date__ = version.date
+__version__ = version.version
+__licence__ = version.licence
+del version
+
+# Copyleft (C) 2008 Acness World
+# Remi Jocaille <[email protected]>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+import os
+import shutil
+
+if os.name == 'nt':
+ import win32con
+ import win32file
+
+#
==============================================================================
+# Public functions
+#
==============================================================================
+
+#
------------------------------------------------------------------------------
+# Force to create a directories tree if not exists.
+#
------------------------------------------------------------------------------
+def MKDirs(path):
+ """Force to create a directories tree if not exists.
+ @param path: Directory path.
+ """
+ if not os.path.isdir(path):
+ try:
+ os.makedirs(path)
+ except:
+ pass
+
+#
------------------------------------------------------------------------------
+# Force to create a directories tree after having deleted the old one.
+#
------------------------------------------------------------------------------
+def MKDirsF(path):
+ """Force to create a directories tree after having deleted the old one.
+ @param path: Directory path.
+ """
+ if os.path.isdir(path):
+ RMDirs(path)
+ os.makedirs(path)
+
+#
------------------------------------------------------------------------------
+# Remove directories and files recursively.
+#
------------------------------------------------------------------------------
+def RMDirs(path):
+ """Remove directories and files recursively.
+ @param path: Path of the base directory.
+ """
+ if not os.path.isdir(path):
+ return
+ for root, dirs, files in os.walk(path, topdown = False):
+ for d in dirs:
+ try:
+ os.removedirs(os.path.join(root, d))
+ except:
+ pass
+ for f in files:
+ try:
+ if os.name == 'nt':
+ win32file.SetFileAttributesW(os.path.join(root, f),
+ win32con.FILE_ATTRIBUTE_NORMAL)
+ os.remove(os.path.join(root, f))
+ except:
+ pass
+ if os.path.isdir(path):
+ try:
+ os.removedirs(path)
+ except:
+ pass
+
+#
------------------------------------------------------------------------------
+# Remove directories and files recursively with filters.
+#
------------------------------------------------------------------------------
+def RMWithFilters(path, filters = ['.pyc', '.pyo']):
+ """Remove directories and files recursively with filters.
+ @param path: Path of the base directory.
+ @param filters: Filters as list.
+ """
+ def checkFilter(name):
+ for filter in filters:
+ if name.lower().find(filter.lower()) == (len(name) - len(filter)):
+ return True
+ return False
+
+ if not os.path.isdir(path):
+ return
+
+ for root, dirs, files in os.walk(path, topdown = False):
+ for d in dirs:
+ if checkFilter(os.path.join(root, d)):
+ try:
+ RMDirs(os.path.join(root, d))
+ except:
+ pass
+ for f in files:
+ if checkFilter(os.path.join(root, f)):
+ try:
+ if os.name == 'nt':
+ win32file.SetFileAttributesW(os.path.join(root, f),
+ win32con.FILE_ATTRIBUTE_NORMAL)
+ os.remove(os.path.join(root, f))
+ except:
+ pass
+
+#
------------------------------------------------------------------------------
+# Remove a file.
+#
------------------------------------------------------------------------------
+def RMFile(path):
+ """Remove a file.
+ @param path: File path.
+ """
+ if os.path.isfile(path):
+ try:
+ if os.name == 'nt':
+ win32file.SetFileAttributesW(path,
+ win32con.FILE_ATTRIBUTE_NORMAL)
+ os.remove(path)
+ except:
+ pass
+
+#
------------------------------------------------------------------------------
+# Copy a directories tree to another directory.
+#
------------------------------------------------------------------------------
+def CPDir(src, dest):
+ """Copy a directories tree to another directory.
+ @param src: Source path.
+ @param dest: Destination path.
+ """
+ if not os.path.isdir(src):
+ return
+ if os.path.isdir(dest):
+ RMDirs(dest)
+ shutil.copytree(src, dest)
+
+#
------------------------------------------------------------------------------
+# Retrieve the OS temporary directory.
+#
------------------------------------------------------------------------------
+def GetOSTMPDir():
+ """Retrieve the OS temporary directory.
+ @return: The OS temporary directory.
+ """
+ result = None
+ # On Windows
+ if os.name == 'nt':
+ result = os.environ.get('tmp')
+ if result == None:
+ result = os.environ.get('temp')
+ if result == None:
+ result = "c:\\windows\\temp"
+ # On linux
+ else:
+ result = "/tmp"
+ return result
Added:
software_suite_v3/software/gadget/default/trunk/builder/util/misc/__init__.py
===================================================================
Added:
software_suite_v3/software/gadget/default/trunk/builder/util/misc/version.py
===================================================================
---
software_suite_v3/software/gadget/default/trunk/builder/util/misc/version.py
(rev 0)
+++
software_suite_v3/software/gadget/default/trunk/builder/util/misc/version.py
2009-09-16 08:20:08 UTC (rev 5405)
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+
+"""Version data for tuxisalive.lib.Util"""
+
+__author__ = "Remi Jocaille ([email protected])"
+
+# Copyleft (C) 2008 C2ME Sa
+# Remi Jocaille <[email protected]>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+name = 'util.misc'
+version = '0.0.1'
+author = "Remi Jocaille ([email protected])"
+
+description = "Utilities libraries."
+
+licence = "GPL"
+date = "December 2008"
Added: software_suite_v3/software/gadget/default/trunk/builder/version.py
===================================================================
--- software_suite_v3/software/gadget/default/trunk/builder/version.py
(rev 0)
+++ software_suite_v3/software/gadget/default/trunk/builder/version.py
2009-09-16 08:20:08 UTC (rev 5405)
@@ -0,0 +1,9 @@
+# Copyleft (C) 2009 C2ME Sa
+# Remi Jocaille <[email protected]>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+version = '0.0.1'
+author = "Remi Jocaille ([email protected])"
+licence = "GPL"
+date = "2009"
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn