Author: remi
Date: 2009-05-05 16:46:45 +0200 (Tue, 05 May 2009)
New Revision: 4644
Added:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/PluginPackager.py
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/plugin-skeleton.py
Removed:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py
Modified:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/build.py
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/resources/plugin.xml
Log:
* fixed terminology "gadget" -> "plugin" in the python plugin skeleton
Modified:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/build.py
===================================================================
---
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/build.py
2009-05-05 14:33:22 UTC (rev 4643)
+++
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/build.py
2009-05-05 14:46:45 UTC (rev 4644)
@@ -5,7 +5,7 @@
# Distributed under the terms of the GNU General Public License
# http://www.gnu.org/copyleft/gpl.html
-from builder.GadgetPackager import GadgetPackager
+from builder.PluginPackager import PluginPackager
if __name__ == "__main__":
- GadgetPackager().createTgf("tuxdroid-gadget-pySkeleton.tpg")
+ PluginPackager().createScp("plugin-pySkeleton.scp")
Deleted:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py
===================================================================
---
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py
2009-05-05 14:33:22 UTC (rev 4643)
+++
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py
2009-05-05 14:46:45 UTC (rev 4644)
@@ -1,78 +0,0 @@
-# -*- 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 TGF file from the main directory of a python gadget
project.
-#
------------------------------------------------------------------------------
-class GadgetPackager(object):
- """Class to create a TGF file from the main directory of a python gadget
- project.
- """
-
- #
--------------------------------------------------------------------------
- # Create a tgf file.
- #
--------------------------------------------------------------------------
- def createTgf(self, tgfFileName):
- """Create a tgf file.
- @param tgfFileName: Tux Gadget Format file name.
- @return: The success of the file creation.
- """
- self.__sourcePath = os.path.realpath("")
- if not os.path.isdir(self.__sourcePath):
- return False
- if not os.path.isdir(os.path.join(self.__sourcePath, "executables")):
- return False
- if not os.path.isdir(os.path.join(self.__sourcePath, "resources")):
- return False
- # Get some paths
- SRC_EXECUTABLES_PATH = os.path.join(self.__sourcePath, "executables")
- SRC_RESOURCES_PATH = os.path.join(self.__sourcePath, "resources")
- TMP_BUILD_PATH = os.path.join(self.__sourcePath, "tmp")
- DEST_EXECUTABLES_PATH = os.path.join(TMP_BUILD_PATH, "executables")
- DEST_RESOURCES_PATH = os.path.join(TMP_BUILD_PATH, "resources")
- DEST_TGF_FILENAME = os.path.join(self.__sourcePath, tgfFileName)
- # Create the temporary build path
- MKDirsF(TMP_BUILD_PATH)
- # Copy "executables" directory
- CPDir(SRC_EXECUTABLES_PATH, DEST_EXECUTABLES_PATH)
- # Copy "resources" directory
- CPDir(SRC_RESOURCES_PATH, DEST_RESOURCES_PATH)
- # Filtering the content of temporary path
- RMWithFilters(TMP_BUILD_PATH, filters = ['.svn', '.pyc'])
- # Create a zip file
- directory = TMP_BUILD_PATH
- last_cwd = os.getcwd()
- os.chdir(TMP_BUILD_PATH)
- zf = ZipFile(DEST_TGF_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
Copied:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/PluginPackager.py
(from rev 4620,
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/GadgetPackager.py)
===================================================================
---
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/PluginPackager.py
(rev 0)
+++
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/builder/PluginPackager.py
2009-05-05 14:46:45 UTC (rev 4644)
@@ -0,0 +1,78 @@
+# -*- 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 SCP file from the main directory of a python plugin
project.
+#
------------------------------------------------------------------------------
+class PluginPackager(object):
+ """Class to create a SCP file from the main directory of a python plugin
+ project.
+ """
+
+ #
--------------------------------------------------------------------------
+ # Create a scp file.
+ #
--------------------------------------------------------------------------
+ def createScp(self, scpFileName):
+ """Create a scp file.
+ @param scpFileName: Smart-Core Plugin file name.
+ @return: The success of the file creation.
+ """
+ self.__sourcePath = os.path.realpath("")
+ if not os.path.isdir(self.__sourcePath):
+ return False
+ if not os.path.isdir(os.path.join(self.__sourcePath, "executables")):
+ return False
+ if not os.path.isdir(os.path.join(self.__sourcePath, "resources")):
+ return False
+ # Get some paths
+ SRC_EXECUTABLES_PATH = os.path.join(self.__sourcePath, "executables")
+ SRC_RESOURCES_PATH = os.path.join(self.__sourcePath, "resources")
+ TMP_BUILD_PATH = os.path.join(self.__sourcePath, "tmp")
+ DEST_EXECUTABLES_PATH = os.path.join(TMP_BUILD_PATH, "executables")
+ DEST_RESOURCES_PATH = os.path.join(TMP_BUILD_PATH, "resources")
+ DEST_SCP_FILENAME = os.path.join(self.__sourcePath, scpFileName)
+ # Create the temporary build path
+ MKDirsF(TMP_BUILD_PATH)
+ # Copy "executables" directory
+ CPDir(SRC_EXECUTABLES_PATH, DEST_EXECUTABLES_PATH)
+ # Copy "resources" directory
+ CPDir(SRC_RESOURCES_PATH, DEST_RESOURCES_PATH)
+ # Filtering the content of temporary path
+ RMWithFilters(TMP_BUILD_PATH, filters = ['.svn', '.pyc'])
+ # Create a zip file
+ directory = TMP_BUILD_PATH
+ last_cwd = os.getcwd()
+ os.chdir(TMP_BUILD_PATH)
+ zf = ZipFile(DEST_SCP_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
Copied:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/plugin-skeleton.py
(from rev 4620,
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py)
===================================================================
---
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/plugin-skeleton.py
(rev 0)
+++
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/plugin-skeleton.py
2009-05-05 14:46:45 UTC (rev 4644)
@@ -0,0 +1,146 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2009 Kysoh Sa
+# Remi Jocaille <[email protected]>
+# Distributed under the terms of the GNU General Public License
+# http://www.gnu.org/copyleft/gpl.html
+
+__author__ = "Kysoh"
+__appname__ = "Python plugin skeleton"
+__version__ = "0.0.1"
+__date__ = "2009/05/05"
+__license__ = "GPL"
+
+import os
+import time
+import sys
+
+sys.path.append(os.environ['TUXDROID_SERVER_PYTHON_UTIL'])
+
+from util.SimplePlugin.SimplePluginConfiguration import
SimplePluginConfiguration
+from util.SimplePlugin.SimplePlugin import SimplePlugin
+
+class Configuration(SimplePluginConfiguration):
+ """This class make an access to the plugin parameters.
+ Parameters are automatically filled by the SimplePlugin class at plugin
+ starting.
+ """
+
+ def __init__(self):
+ """Initialization of the class.
+ It's necessary to initialize the values because the type of the python
+ variables is set by value assignation. If we don't initialize the
+ parameters the simple plugin class can't check and validate the values
+ passed by the plugins server through the os environment variables.
+ """
+ # Call the super class
+ SimplePluginConfiguration.__init__(self)
+ # Initialize the parameters
+ self.__stringParam = ""
+ self.__integerParam = 0
+ self.__booleanParam = False
+ self.__enumeratedParam = ""
+ self.__linuxParam = ""
+ self.__windowsParam = ""
+
+ def getStringParam(self):
+ return self.__stringParam
+
+ def setStringParam(self, stringParam):
+ self.__stringParam = stringParam
+
+ def getIntegerParam(self):
+ return self.__integerParam
+
+ def setIntegerParam(self, integerParam):
+ self.__integerParam = integerParam
+
+ def getBooleanParam(self):
+ return self.__booleanParam
+
+ def setBooleanParam(self, booleanParam):
+ self.__booleanParam = booleanParam
+
+ def getEnumeratedParam(self):
+ return self.__enumeratedParam
+
+ def setEnumeratedParam(self, enumeratedParam):
+ self.__enumeratedParam = enumeratedParam
+
+ def getLinuxParam(self):
+ return self.__linuxParam
+
+ def setLinuxParam(self, linuxParam):
+ self.__linuxParam = linuxParam
+
+ def getWindowsParam(self):
+ return self.__windowsParam
+
+ def setWindowsParam(self, windowsParam):
+ self.__windowsParam = windowsParam
+
+
+class SkeletonPlugin(SimplePlugin):
+ """This class override the SimplePlugin class to make easy
+ the plugin coding.
+ """
+
+ def __init__(self):
+ """Initialization of the class.
+ """
+ # Call the super class
+ SimplePlugin.__init__(self)
+ # Initialize some values ...
+ self.__daemonRun = False
+
+ def start(self):
+ """Plugin entry point.
+ This method should be used to dispatch commands.
+ """
+ if self.getCommand() == "run":
+ self.run()
+ elif self.getCommand() == "run_daemon":
+ self.runDaemon()
+ elif self.getCommand() == "check":
+ self.check()
+ else:
+ self.run()
+
+ def run(self):
+ """Plugin entry point for the "run" command.
+ """
+ if self.isWindows():
+ self.throwMessage(self.configuration().getWindowsParam())
+ else:
+ self.throwMessage(self.configuration().getLinuxParam())
+ self.throwMessage("I finished my work ...")
+
+ def runDaemon(self):
+ """Plugin entry point for the "run_daemon" command.
+ """
+ # Start a fake daemon loop ...
+ # Warning the daemonRun flag is not safe-thread (in order to have a
+ # clean code in this plugin example)
+ self.__daemonRun = True
+ while self.__daemonRun:
+ time.sleep(0.5)
+
+ def check(self):
+ """Plugin entry point for the "check" command.
+ """
+ # Check a condition ...
+ # For example get the value of the parameter "booleanParam"
+ checkResult = self.configuration().getBooleanParam()
+ # Return the check result
+ self.throwResult(checkResult)
+ self.throwMessage("I throwed my result, so I can die. RIP ...")
+
+ def onPluginStop(self):
+ """Callback on plugin stop.
+ """
+ # Stop the fake daemon loop
+ self.__daemonRun = False
+
+if __name__ == "__main__":
+ plugin = SkeletonPlugin()
+ plugin.boot(sys.argv[1:], Configuration())
Deleted:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py
===================================================================
---
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py
2009-05-05 14:33:22 UTC (rev 4643)
+++
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/executables/tux-gadget-skeleton.py
2009-05-05 14:46:45 UTC (rev 4644)
@@ -1,146 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Copyright (C) 2009 Kysoh Sa
-# Remi Jocaille <[email protected]>
-# Distributed under the terms of the GNU General Public License
-# http://www.gnu.org/copyleft/gpl.html
-
-__author__ = "Kysoh"
-__appname__ = "Python gadget skeleton"
-__version__ = "0.0.1"
-__date__ = "2009/03/31"
-__license__ = "GPL"
-
-import os
-import time
-import sys
-
-sys.path.append(os.environ['TUXDROID_SERVER_PYTHON_UTIL'])
-
-from util.SimpleGadget.SimpleGadgetConfiguration import
SimpleGadgetConfiguration
-from util.SimpleGadget.SimpleGadget import SimpleGadget
-
-class Configuration(SimpleGadgetConfiguration):
- """This class make an access to the gadget parameters.
- Parameters are automatically filled by the SimpleGadget class at gadget
- starting.
- """
-
- def __init__(self):
- """Initialization of the class.
- It's necessary to initialize the values because the type of the python
- variables is set by value assignation. If we don't initialize the
- parameters the simple gadget class can't check and validate the values
- passed by the framework through the os environment variables.
- """
- # Call the super class
- SimpleGadgetConfiguration.__init__(self)
- # Initialize the parameters
- self.__stringParam = ""
- self.__integerParam = 0
- self.__booleanParam = False
- self.__enumeratedParam = ""
- self.__linuxParam = ""
- self.__windowsParam = ""
-
- def getStringParam(self):
- return self.__stringParam
-
- def setStringParam(self, stringParam):
- self.__stringParam = stringParam
-
- def getIntegerParam(self):
- return self.__integerParam
-
- def setIntegerParam(self, integerParam):
- self.__integerParam = integerParam
-
- def getBooleanParam(self):
- return self.__booleanParam
-
- def setBooleanParam(self, booleanParam):
- self.__booleanParam = booleanParam
-
- def getEnumeratedParam(self):
- return self.__enumeratedParam
-
- def setEnumeratedParam(self, enumeratedParam):
- self.__enumeratedParam = enumeratedParam
-
- def getLinuxParam(self):
- return self.__linuxParam
-
- def setLinuxParam(self, linuxParam):
- self.__linuxParam = linuxParam
-
- def getWindowsParam(self):
- return self.__windowsParam
-
- def setWindowsParam(self, windowsParam):
- self.__windowsParam = windowsParam
-
-
-class SkeletonGadget(SimpleGadget):
- """This class override the SimpleGadget class to make easy
- the gadget coding.
- """
-
- def __init__(self):
- """Initialization of the class.
- """
- # Call the super class
- SimpleGadget.__init__(self)
- # Initialize some values ...
- self.__daemonRun = False
-
- def start(self):
- """Gadget entry point.
- This method should be used to dispatch commands.
- """
- if self.getCommand() == "run":
- self.run()
- elif self.getCommand() == "run_daemon":
- self.runDaemon()
- elif self.getCommand() == "check":
- self.check()
- else:
- self.run()
-
- def run(self):
- """Gadget entry point for the "run" command.
- """
- if self.isWindows():
- self.throwMessage(self.configuration().getWindowsParam())
- else:
- self.throwMessage(self.configuration().getLinuxParam())
- self.throwMessage("I finished my work ...")
-
- def runDaemon(self):
- """Gadget entry point for the "run_daemon" command.
- """
- # Start a fake daemon loop ...
- # Warning the daemonRun flag is not safe-thread (in order to have a
- # clean code in this gadget example)
- self.__daemonRun = True
- while self.__daemonRun:
- time.sleep(0.5)
-
- def check(self):
- """Gadget entry point for the "check" command.
- """
- # Check a condition ...
- # For example get the value of the parameter "booleanParam"
- checkResult = self.configuration().getBooleanParam()
- # Return the check result
- self.throwResult(checkResult)
- self.throwMessage("I throwed my result, so I can die. RIP ...")
-
- def onGadgetStop(self):
- """Callback on gadget stop.
- """
- # Stop the fake daemon loop
- self.__daemonRun = False
-
-if __name__ == "__main__":
- gadget = SkeletonGadget()
- gadget.boot(sys.argv[1:], Configuration())
Modified:
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/resources/plugin.xml
===================================================================
---
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/resources/plugin.xml
2009-05-05 14:33:22 UTC (rev 4643)
+++
software_suite_v3/smart-core/smart-dev/plugin-toolkit/python/skeleton/trunk/resources/plugin.xml
2009-05-05 14:46:45 UTC (rev 4644)
@@ -1,7 +1,7 @@
<plugin>
<interpreter
kind="python">
- <executable>executables/tux-gadget-skeleton.py</executable>
+ <executable>executables/plugin-skeleton.py</executable>
</interpreter>
<description>
<name>Python plugin skeleton</name>
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn