|
From: <wgh...@us...> - 2009-08-26 04:15:08
|
Revision: 22943
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=22943&view=rev
Author: wghassan
Date: 2009-08-26 04:14:59 +0000 (Wed, 26 Aug 2009)
Log Message:
-----------
changed the app loading
Modified Paths:
--------------
pkg/trunk/sandbox/web/launchman/src/launchman/app.py
pkg/trunk/sandbox/web/webui/src/webui/mod/webui/db_webui.py
Modified: pkg/trunk/sandbox/web/launchman/src/launchman/app.py
===================================================================
--- pkg/trunk/sandbox/web/launchman/src/launchman/app.py 2009-08-26 04:05:27 UTC (rev 22942)
+++ pkg/trunk/sandbox/web/launchman/src/launchman/app.py 2009-08-26 04:14:59 UTC (rev 22943)
@@ -44,21 +44,33 @@
return pkgpath
class App:
+ app_keys = ('name', 'package', 'launch_file', 'description',
+ 'icon', 'provides', 'depends')
def __init__(self, taskid):
+ self.taskid = taskid
+ self.package, self.app_file = self.taskid.split('/', 1)
+ self.path = None
+
+ def fn(self):
+ if self.path: return self.path
+ self.path = getPackagePath(self.package)
+ fn = os.path.join(self.path, self.app_file)
+ return fn
+
+ def load_yaml(self):
+ fn = self.fn()
# TODO catch file system exception
- package, app_file = taskid.split('/', 1)
- sys.stderr.write(package + "\n")
- path = getPackagePath(package)
- doc = yaml.load(open(os.path.join(path, app_file)))
+ doc = yaml.load(open(fn))
+ return doc
+
+ def load(self):
+ doc = self.load_yaml()
try:
- self.taskid = taskid
- self.app_file = app_file
- self.name = doc['name'].strip()
- self.package = doc['package'].strip()
- self.launch_file = doc['launch_file'].strip()
-
- self.provides = doc.get('provides', None)
- self.depends = doc.get('depends', None)
+ for key in self.app_keys:
+ if doc.has_key(key):
+ val = doc[key]
+ if val is not None: val = val.strip()
+ setattr(self, key, val)
except KeyError:
print "Invalid YAML file"
Modified: pkg/trunk/sandbox/web/webui/src/webui/mod/webui/db_webui.py
===================================================================
--- pkg/trunk/sandbox/web/webui/src/webui/mod/webui/db_webui.py 2009-08-26 04:05:27 UTC (rev 22942)
+++ pkg/trunk/sandbox/web/webui/src/webui/mod/webui/db_webui.py 2009-08-26 04:14:59 UTC (rev 22943)
@@ -84,8 +84,13 @@
class Application(hdfhelp.HdfRow):
def fetchApp(self, prefix, hdf):
_app = app.App(str(self.taskid))
-
- hdf.setValue(prefix + ".name", _app.name)
+ doc = _app.load_yaml()
+
+ for key, val in doc.items():
+ if val is not None:
+ hdf.setValue(prefix + "." + key, val)
+ else:
+ hdf.setValue(prefix + "." + key, '')
def fullDBPath(path_to_store):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|