appgroup.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 """
4 usage: %(progname)s [args]
5 """
6 
7 import os, sys, string, time, getopt, re
8 from pyclearsilver.log import *
9 
10 import neo_cgi, neo_util, neo_cs
11 
12 from pyclearsilver import CSPage
13 from pyclearsilver import odb
14 import launchman.app
15 
16 import MBPage
17 import db_webui
18 import webutil
19 
21  def setup(self, hdf):
22  self.db = db_webui.initSchema()
23  self.appgroup = self.db.appgroups.lookup(id=hdf.getValue("Query.id", ""))
24  self.appids = self.appgroup.appIdList()
25 
26  def display(self, hdf):
27  webutil.set_tabs(hdf, ["apps", "appgroup"])
28 
29  i = 0
30  for taskid in self.appids:
31  doc = launchman.app.App(taskid).load_yaml()
32 
33  prefix = "CGI.cur.app_group.apps.%s" % i
34  hdf.setValue(prefix + "." + "taskid", taskid)
35  for key, val in doc.items():
36  if val is not None:
37  hdf.setValue(prefix + "." + key, val)
38  else:
39  hdf.setValue(prefix + "." + key, '')
40  i += 1
41 
42  self.appgroup.hdfExport("CGI.cur.app_group", hdf)
43 
44  # experimental new stuff
45  apps = webutil.list_apps()
46  n = 0
47  for appfn in apps:
48  taskid = db_webui.path2taskid(appfn)
49  prefix = "CGI.cur.available_apps.%d" % n
50  _app = launchman.app.App(taskid)
51  doc = _app.load_yaml()
52 
53  if taskid in self.appids:
54  pass
55  else:
56  n = n + 1
57  hdf.setValue(prefix + "." + "taskid", taskid)
58  for key, val in doc.items():
59  if val is not None:
60  hdf.setValue(prefix + "." + key, val)
61  else:
62  hdf.setValue(prefix + "." + key, '')
63 
64  def Action_AddApp(self, hdf):
65  taskid = hdf.getValue("Query.taskid", "")
66 
67  if taskid not in self.appids:
68  user_id = self.authdb.users.lookup(hdf.getValue("CGI.Login", "")).uid
69 
70  self.appids.append(taskid)
71  self.appgroup.appids = string.join(self.appids, ',')
72  self.appgroup.save()
73 
74 
75 def run(context):
76  return MyPage(context, pagename="appgroup", nologin=False)
77 
78 def main():
79  context = CSPage.Context()
80  run(context).start()
81 
82 if __name__ == "__main__":
83  main()


webui
Author(s): Scott Hassan
autogenerated on Mon Jun 10 2019 15:51:24