00001
00002
00003 """
00004 usage: %(progname)s [args]
00005 """
00006
00007 import os, sys, string, time, getopt, re
00008 from pyclearsilver.log import *
00009
00010 import neo_cgi, neo_util, neo_cs
00011
00012 from pyclearsilver import CSPage
00013 from pyclearsilver import odb
00014 import launchman.app
00015
00016 import MBPage
00017 import db_webui
00018 import webutil
00019
00020 class MyPage(MBPage.MBPage):
00021 def setup(self, hdf):
00022 self.db = db_webui.initSchema()
00023 self.appgroup = self.db.appgroups.lookup(id=hdf.getValue("Query.id", ""))
00024 self.appids = self.appgroup.appIdList()
00025
00026 def display(self, hdf):
00027 webutil.set_tabs(hdf, ["apps", "appgroup"])
00028
00029 i = 0
00030 for taskid in self.appids:
00031 doc = launchman.app.App(taskid).load_yaml()
00032
00033 prefix = "CGI.cur.app_group.apps.%s" % i
00034 hdf.setValue(prefix + "." + "taskid", taskid)
00035 for key, val in doc.items():
00036 if val is not None:
00037 hdf.setValue(prefix + "." + key, val)
00038 else:
00039 hdf.setValue(prefix + "." + key, '')
00040 i += 1
00041
00042 self.appgroup.hdfExport("CGI.cur.app_group", hdf)
00043
00044
00045 apps = webutil.list_apps()
00046 n = 0
00047 for appfn in apps:
00048 taskid = db_webui.path2taskid(appfn)
00049 prefix = "CGI.cur.available_apps.%d" % n
00050 _app = launchman.app.App(taskid)
00051 doc = _app.load_yaml()
00052
00053 if taskid in self.appids:
00054 pass
00055 else:
00056 n = n + 1
00057 hdf.setValue(prefix + "." + "taskid", taskid)
00058 for key, val in doc.items():
00059 if val is not None:
00060 hdf.setValue(prefix + "." + key, val)
00061 else:
00062 hdf.setValue(prefix + "." + key, '')
00063
00064 def Action_AddApp(self, hdf):
00065 taskid = hdf.getValue("Query.taskid", "")
00066
00067 if taskid not in self.appids:
00068 user_id = self.authdb.users.lookup(hdf.getValue("CGI.Login", "")).uid
00069
00070 self.appids.append(taskid)
00071 self.appgroup.appids = string.join(self.appids, ',')
00072 self.appgroup.save()
00073
00074
00075 def run(context):
00076 return MyPage(context, pagename="appgroup", nologin=False)
00077
00078 def main():
00079 context = CSPage.Context()
00080 run(context).start()
00081
00082 if __name__ == "__main__":
00083 main()