Author: remi Date: 2009-07-29 13:49:39 +0200 (Wed, 29 Jul 2009) New Revision: 5222
Added: software_suite_v3/smart-core/smart-server/trunk/util/smartcore/SmartServerCommander.py Modified: software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py Log: * Added functionalities to launch Attitunes studio and Tux Droid Controller by http requests * Added a python script to send commands to smart-server. Modified: software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py =================================================================== --- software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py 2009-07-29 09:55:03 UTC (rev 5221) +++ software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py 2009-07-29 11:49:39 UTC (rev 5222) @@ -559,6 +559,8 @@ contentStruct = self.getDefaultContentStruct() contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS) language = parameters['language'] + if language.lower() == "null": + language = resourceUsers.getCurrentFirstLanguage() outputPath = os.path.join(resourceUsers.getCurrentUserBasePath(), "attitunes") t = threading.Thread(target = resourcePluginsServer.startPlugin, @@ -622,6 +624,40 @@ resourceWIUser01.addService(TDSServiceWIUser01EditAttitune) # ------------------------------------------------------------------------------ +# Declaration of the service "start_tux_controller". +# ------------------------------------------------------------------------------ +class TDSServiceWIUser01StartTuxController(TDSService): + + def configure(self): + self.parametersDict = { + 'language' : 'string', + } + self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS + self.exclusiveExecution = False + self.name = "start_tux_controller" + self.comment = "Start Tux Controller tool." + + def execute(self, id, parameters): + headersStruct = self.getDefaultHeadersStruct() + contentStruct = self.getDefaultContentStruct() + contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS) + language = parameters['language'] + if language.lower() == "null": + language = resourceUsers.getCurrentFirstLanguage() + t = threading.Thread(target = resourcePluginsServer.startPlugin, + args = ( + "548f7a77-567d-773e-a0ef-321fe63a1c88", + "run", + { + 'language' : language, + })) + t.start() + return headersStruct, contentStruct + +# Register the service into the resource +resourceWIUser01.addService(TDSServiceWIUser01StartTuxController) + +# ------------------------------------------------------------------------------ # Declaration of the service "global_configuration". # ------------------------------------------------------------------------------ class TDSServiceWIUser01GlobalConfiguration(TDSService): Added: software_suite_v3/smart-core/smart-server/trunk/util/smartcore/SmartServerCommander.py =================================================================== --- software_suite_v3/smart-core/smart-server/trunk/util/smartcore/SmartServerCommander.py (rev 0) +++ software_suite_v3/smart-core/smart-server/trunk/util/smartcore/SmartServerCommander.py 2009-07-29 11:49:39 UTC (rev 5222) @@ -0,0 +1,40 @@ +# Copyright (C) 2009 C2ME Sa +# Remi Jocaille <remi.jocai...@c2me.be> +# Distributed under the terms of the GNU General Public License +# http://www.gnu.org/copyleft/gpl.html + +import socket +import httplib +import sys + +def sendRequest(host, port, request): + old_timeout = socket.getdefaulttimeout() + socket.setdefaulttimeout(2.) + hp = "%s:%d" % (host, port) + h = httplib.HTTP(hp) + try: + h.connect() + except: + socket.setdefaulttimeout(old_timeout) + return 1 + h.putrequest("GET", request) + h.endheaders() + errcode, errmsg, headers = h.getreply() + if errcode != 200: + socket.setdefaulttimeout(old_timeout) + return 1 + else: + socket.setdefaulttimeout(old_timeout) + return 0 + +if __name__ == "__main__": + if len(sys.argv) != 4: + sys.exit(1) + host = sys.argv[1] + try: + port = eval(sys.argv[2]) + except: + sys.exit(1) + request = sys.argv[3] + ret = sendRequest(host, port, request) + sys.exit(ret) ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Tux-droid-svn mailing list Tux-droid-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tux-droid-svn