[tuxdroid-svn] r4640 - software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin
Status: Beta
Brought to you by:
ks156
|
From: remi <c2m...@c2...> - 2009-05-05 14:17:12
|
Author: remi Date: 2009-05-05 16:17:01 +0200 (Tue, 05 May 2009) New Revision: 4640 Removed: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/GadgetHelper.py Log: * removed useless class. SimplePlugin is the official class to build a python plugin Deleted: software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/GadgetHelper.py =================================================================== --- software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/GadgetHelper.py 2009-05-05 14:14:18 UTC (rev 4639) +++ software_suite_v3/smart-core/smart-server/trunk/util/SimplePlugin/GadgetHelper.py 2009-05-05 14:17:01 UTC (rev 4640) @@ -1,108 +0,0 @@ -# Copyright (C) 2009 C2ME Sa -# Remi Jocaille <rem...@c2...> -# Distributed under the terms of the GNU General Public License -# http://www.gnu.org/copyleft/gpl.html - -import sys -import traceback -import platform - -# ------------------------------------------------------------------------------ -# This class is the minimal helper for builder python gadgets. -# It's an alternative to the SimpleGadget helper. -# ------------------------------------------------------------------------------ -class GadgetHelper(object): - """This class is the minimal helper for builder python gadgets. - It's an alternative to the SimpleGadget helper. - """ - - # -------------------------------------------------------------------------- - # Get if the platform is Windows or not. - # -------------------------------------------------------------------------- - def isWindows(): - """Get if the platform is Windows or not. - @return: A boolean. - """ - platformName = platform.system().lower() - return (platformName == "microsoft") or (platformName == "windows") - - # -------------------------------------------------------------------------- - # Throw a generic notification to the framework. - # -------------------------------------------------------------------------- - def throwNotification(messageId, *args): - """Throw a generic notification to the framework. - @param messageId: Message Id. - @param args: List of objects. - """ - stringBuffer = messageId - for arg in args: - stringBuffer += " '" - stringBuffer += str(arg).replace("'", "\\'") - stringBuffer += "'" - sys.stdout.write(stringBuffer + "\n") - sys.stdout.flush() - - # -------------------------------------------------------------------------- - # Throw a message to the framework. - # -------------------------------------------------------------------------- - def throwMessage(content, *args): - """Throw a message to the framework. - @param content: Content of the message. - @param args: Arguments for the message. - """ - tmp = [content,] - for arg in args: - tmp.append(arg) - GadgetHelper.throwNotification("message", *tmp) - - # -------------------------------------------------------------------------- - # Throw a trace message to the framework. - # -------------------------------------------------------------------------- - def throwTrace(message): - """Throw a trace message to the framework. - @param message: Throwed message. - """ - GadgetHelper.throwNotification("trace", message) - - # -------------------------------------------------------------------------- - # Throw the result of the "check" command to the framework. - # -------------------------------------------------------------------------- - def throwResult(result): - """Throw the result of the "check" command to the framework. - @param result: A boolean. - """ - if result: - resultValue = "true" - else: - resultValue = "false" - GadgetHelper.throwNotification("check_result", resultValue) - - # -------------------------------------------------------------------------- - # Throw an error message to the framework. - # -------------------------------------------------------------------------- - def throwError(message, sendTraceback = False): - """Throw an error message to the framework. - @param message: Thowed message if the gadget don't want to be traced. - @param sendTraceback: For to send the traceback. Default False. - """ - def formatException(): - fList = traceback.format_exception(sys.exc_info()[0], - sys.exc_info()[1], - sys.exc_info()[2]) - result = "" - for line in fList: - result += line - return result - messagesList = [message,] - if sendTraceback: - tmpList = formatException().split("\n") - for line in tmpList: - messagesList.append(line) - GadgetHelper.throwNotification("error", *messagesList) - - isWindows = staticmethod(isWindows) - throwNotification = staticmethod(throwNotification) - throwMessage = staticmethod(throwMessage) - throwTrace = staticmethod(throwTrace) - throwResult = staticmethod(throwResult) - throwError = staticmethod(throwError) |