Author: remi
Date: 2009-03-12 12:16:51 +0100 (Thu, 12 Mar 2009)
New Revision: 3987
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
Log:
* added a mechanism to retry to launch the framework if the first attempt has
failed
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
===================================================================
---
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
2009-03-12 11:09:30 UTC (rev 3986)
+++
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
2009-03-12 11:16:51 UTC (rev 3987)
@@ -50,7 +50,18 @@
if not self.__getRun():
return
if self.__process != None:
+ handle = self.__process._handle
+ pid = self.__process.pid
self.sendCommand("STOP")
+ time.sleep(1.0)
+ if os.name == 'nt':
+ import win32api
+ try:
+ win32api.TerminateProcess(int(handle), -1)
+ except:
+ pass
+ else:
+ os.system("kill -9 " + str(pid))
self.__setRun(False)
self.__process = None
time.sleep(0.25)
@@ -158,6 +169,10 @@
self.__currentGadgetLoad = {}
self.__currentGadgetLoadState = "HEAD"
self.__containerDirectory = None
+ self.__language = "en"
+ self.__country = "US"
+ self.__locutor = "Ryan"
+ self.__pitch = 130
# Registering the framework statuses and add it in the excluded list.
# Clients have to syndicate to receive.
for statusName in SW_NAME_FRAMEWORK:
@@ -250,75 +265,80 @@
t.start()
def __onGadgetLoad(self, args):
- if self.__currentGadgetLoadState == "GETDESCRIPTION":
- if len(args) != 9:
- self.__currentGadgetLoadState = "HEAD"
- else:
- self.__currentGadgetLoad['description']['name'] = args[0]
- self.__currentGadgetLoad['description']['translated_name'] =
args[1]
- self.__currentGadgetLoad['description']['uuid'] = args[2]
- self.__currentGadgetLoad['description']['author'] = args[3]
- self.__currentGadgetLoad['description']['version'] = args[4]
- self.__currentGadgetLoad['description']['description'] =
args[5]
- self.__currentGadgetLoad['description']['icon_file'] = args[6]
- self.__currentGadgetLoad['description']['help_file'] = args[7]
- self.__currentGadgetLoad['description']['tgf_file'] = args[8]
- return
- elif self.__currentGadgetLoadState == "GETPARAMETERS":
- if len(args) != 9:
- self.__currentGadgetLoadState = "HEAD"
- else:
- idx = "parameter_%.3d" %
len(self.__currentGadgetLoad['parameters'].keys())
- self.__currentGadgetLoad['parameters'][idx] = {
- 'name' : args[0],
- 'translated_name' : args[1],
- 'description' : args[2],
- 'category' : args[3],
- 'type' : args[4],
- 'default_value' : args[5],
- 'enum_values' : args[6],
- 'min_value' : args[7],
- 'max_value' : args[8],
- }
- return
- elif self.__currentGadgetLoadState == "GETCOMMANDS":
- if len(args) != 3:
- self.__currentGadgetLoadState = "HEAD"
- else:
- idx = "command_%.3d" %
len(self.__currentGadgetLoad['commands'].keys())
- self.__currentGadgetLoad['commands'][idx] = {
- 'name' : args[0],
- 'translated_name' : args[1],
- 'description' : args[2],
- }
- return
- if self.__currentGadgetLoadState == "HEAD":
- if args[0] == "BEGIN":
- self.__currentGadgetLoadState = "HEAD"
- elif args[0] == "END":
- uuid = self.__currentGadgetLoad['description']['uuid']
- idx = "gadget_%s" % uuid
- self.__tmpGadgetsDictionary[idx] = self.__currentGadgetLoad
- self.__currentGadgetLoad = {}
- self.__currentGadgetLoadState = "HEAD"
- elif args[0] == "DESCRIPTION":
- if args[1] == "BEGIN":
- self.__currentGadgetLoad['description'] = {}
- self.__currentGadgetLoadState = "GETDESCRIPTION"
- elif args[1] == "END":
+ try:
+ if self.__currentGadgetLoadState == "GETDESCRIPTION":
+ if len(args) != 9:
self.__currentGadgetLoadState = "HEAD"
- elif args[0] == "COMMANDS":
- if args[1] == "BEGIN":
- self.__currentGadgetLoad['commands'] = {}
- self.__currentGadgetLoadState = "GETCOMMANDS"
- elif args[1] == "END":
+ else:
+ self.__currentGadgetLoad['description']['name'] = args[0]
+ self.__currentGadgetLoad['description']['translated_name']
= args[1]
+ self.__currentGadgetLoad['description']['uuid'] = args[2]
+ self.__currentGadgetLoad['description']['author'] = args[3]
+ self.__currentGadgetLoad['description']['version'] =
args[4]
+ self.__currentGadgetLoad['description']['description'] =
args[5]
+ self.__currentGadgetLoad['description']['icon_file'] =
args[6]
+ self.__currentGadgetLoad['description']['help_file'] =
args[7]
+ self.__currentGadgetLoad['description']['tgf_file'] =
args[8]
+ return
+ elif self.__currentGadgetLoadState == "GETPARAMETERS":
+ if len(args) != 9:
self.__currentGadgetLoadState = "HEAD"
- elif args[0] == "PARAMETERS":
- if args[1] == "BEGIN":
- self.__currentGadgetLoad['parameters'] = {}
- self.__currentGadgetLoadState = "GETPARAMETERS"
- elif args[1] == "END":
+ else:
+ idx = "parameter_%.3d" %
len(self.__currentGadgetLoad['parameters'].keys())
+ self.__currentGadgetLoad['parameters'][idx] = {
+ 'name' : args[0],
+ 'translated_name' : args[1],
+ 'description' : args[2],
+ 'category' : args[3],
+ 'type' : args[4],
+ 'default_value' : args[5],
+ 'enum_values' : args[6],
+ 'min_value' : args[7],
+ 'max_value' : args[8],
+ }
+ return
+ elif self.__currentGadgetLoadState == "GETCOMMANDS":
+ if len(args) != 3:
self.__currentGadgetLoadState = "HEAD"
+ else:
+ idx = "command_%.3d" %
len(self.__currentGadgetLoad['commands'].keys())
+ self.__currentGadgetLoad['commands'][idx] = {
+ 'name' : args[0],
+ 'translated_name' : args[1],
+ 'description' : args[2],
+ }
+ return
+ if self.__currentGadgetLoadState == "HEAD":
+ if args[0] == "BEGIN":
+ self.__currentGadgetLoadState = "HEAD"
+ elif args[0] == "END":
+ uuid = self.__currentGadgetLoad['description']['uuid']
+ idx = "gadget_%s" % uuid
+ self.__tmpGadgetsDictionary[idx] = self.__currentGadgetLoad
+ self.__currentGadgetLoad = {}
+ self.__currentGadgetLoadState = "HEAD"
+ elif args[0] == "DESCRIPTION":
+ if args[1] == "BEGIN":
+ self.__currentGadgetLoad['description'] = {}
+ self.__currentGadgetLoadState = "GETDESCRIPTION"
+ elif args[1] == "END":
+ self.__currentGadgetLoadState = "HEAD"
+ elif args[0] == "COMMANDS":
+ if args[1] == "BEGIN":
+ self.__currentGadgetLoad['commands'] = {}
+ self.__currentGadgetLoadState = "GETCOMMANDS"
+ elif args[1] == "END":
+ self.__currentGadgetLoadState = "HEAD"
+ elif args[0] == "PARAMETERS":
+ if args[1] == "BEGIN":
+ self.__currentGadgetLoad['parameters'] = {}
+ self.__currentGadgetLoadState = "GETPARAMETERS"
+ elif args[1] == "END":
+ self.__currentGadgetLoadState = "HEAD"
+ except:
+ # Error in the retrieved structure, retry ...
+ self.startFramework(self.__containerDirectory, self.__language,
+ self.__country, self.__locutor, self.__pitch)
def __onGadgetUnload(self, uuid):
for key in self.__gadgetsDictionary.keys():
@@ -468,9 +488,13 @@
self.__containerDirectory = None
self.__gadgetFramework.start()
time.sleep(0.5)
+ self.__language = language
+ self.__country = country
+ self.__locutor = locutor
+ self.__pitch = pitch
+ self.__containerDirectory = gadgetsPath
self.__containerSetLocales(language, country, locutor, pitch)
self.__containerStart(gadgetsPath)
- self.__containerDirectory = gadgetsPath
self.__publishEvents(True, ST_NAME_FW_RUN, ["True",])
t = threading.Thread(target = async)
t.start()
@@ -485,6 +509,10 @@
- The framework bridge must be previously started.
"""
if (self.__gadgetFramework.isStarted()):
+ self.__language = language
+ self.__country = country
+ self.__locutor = locutor
+ self.__pitch = pitch
self.__containerSetLocales(language, country, locutor, pitch)
self.__containerRestart()
return True
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn