示例#1
0
 def load_from_db(self, name):
     instance = leginondata.ApplicationData(name=name)
     applicationdatalist = instance.query()
     try:
         appdata = applicationdatalist[0]
     except IndexError:
         raise ValueError('no such application')
     nodeinstance = leginondata.NodeSpecData(application=appdata)
     self.nodespecs = nodeinstance.query()
     bindinginstance = leginondata.BindingSpecData(application=appdata)
     self.bindingspecs = bindinginstance.query()
     self.applicationdata = appdata
     ## create a copy so we can modify it
     self.data = leginondata.ApplicationData(initializer=appdata)
示例#2
0
 def getApplications(self, show_hidden=False):
     apps = {}
     hiddens = []
     appdatalist = self.getBuiltinApplications()
     appdatalist.extend(self.research(leginondata.ApplicationData()))
     for appdata in appdatalist:
         appname = appdata['name']
         if appname not in apps:
             app = application.Application(self, name=appname)
             if show_hidden:
                 apps[appname] = app
             else:
                 if appname not in hiddens:
                     if appdata['hide']:
                         hiddens.append(appname)
                     else:
                         apps[appname] = app
     if not show_hidden:
         history, map = self.getApplicationHistory()
         for appname in history:
             if appname not in apps:
                 app = application.Application(self, name=appname)
                 apps[appname] = app
     appnames = apps.keys()
     appnames.sort()
     orderedapps = ordereddict.OrderedDict()
     for appname in appnames:
         orderedapps[appname] = apps[appname]
     return orderedapps
示例#3
0
 def getNewVersion(self, name):
     instance = leginondata.ApplicationData(name=name)
     applicationdatalist = self.node.research(datainstance=instance)
     try:
         applicationdata = applicationdatalist[0]
     except IndexError:
         return 0
     return applicationdata['version'] + 1
示例#4
0
 def clear(self):
     name = self.getName()
     self.data = leginondata.ApplicationData()
     if name is not None:
         self.data['name'] = name
     self.nodespecs = []
     self.bindingspecs = []
     self.launchednodes = []
     self.launchernames = {}
示例#5
0
 def __init__(self, node, name=None):
     self.node = node
     self.data = leginondata.ApplicationData()
     if name is not None:
         self.data['name'] = name
     self.nodespecs = []
     self.bindingspecs = []
     self.launchednodes = []
     self.launchernames = {}
示例#6
0
 def save(self):
     self.data['version'] = self.getNewVersion(self.data['name'])
     self.data['hide'] = False
     self.node.publish(self.data, database=True)
     for nodespecdata in self.nodespecs:
         self.node.publish(nodespecdata, database=True)
     for bindingspecdata in self.bindingspecs:
         self.node.publish(bindingspecdata, database=True)
     ## create a copy so we can modify it
     self.data = leginondata.ApplicationData(initializer=self.data)
示例#7
0
 def getApplicationHistory(self):
     initializer = {
         'session': leginondata.SessionData(user=self.session['user']),
         'application': leginondata.ApplicationData()
     }
     appdata = leginondata.LaunchedApplicationData(initializer=initializer)
     appdatalist = self.research(appdata, timelimit='-90 0:0:0')
     history = []
     map = {}
     for a in appdatalist:
         name = a['application']['name']
         if name not in history:
             history.append(name)
             map[name] = a['launchers']
     return history, map
示例#8
0
 def getApplicationNames(self, show_hidden=False):
     names = []
     hiddennames = []
     appdatalist = self.getBuiltinApplications()
     appdatalist.extend(self.research(leginondata.ApplicationData()))
     for appdata in appdatalist:
         appname = appdata['name']
         if appname not in names:
             if show_hidden is True:
                 names.append(appname)
             else:
                 if appname not in hiddennames:
                     if not appdata['hide']:
                         names.append(appname)
                     else:
                         hiddennames.append(appname)
     return names
        def upgradeLeginonDB(self):
                if not self.leginon_dbupgrade.tableExists('ApplicationData'):
                        return
                
                if not self.leginon_dbupgrade.columnExists('ApplicationData', 'hide'):
                        self.leginon_dbupgrade.addColumn('ApplicationData', 'hide', self.leginon_dbupgrade.bool)

                apps = leginondata.ApplicationData().query()

                for appdata in apps:
                        t_results, n_results = self.getTransformManagerNavigatorNodes(appdata)
                        # Only on applications with the two nodes
                        if t_results and n_results:
                                hasbindings = self.hasTransformManagerNavigatorBindings(appdata,t_results[0],n_results[0])
                                if not hasbindings:
                                        print appdata['name'], appdata['version'], appdata['hide']
                                        q = "UPDATE `ApplicationData` SET `hide` = '1' WHERE `DEF_id` =%d" % appdata.dbid
                                        self.leginon_dbupgrade.executeCustomSQL(q)
示例#10
0
    def importRecentSettings(self):
        '''
		Import Settings based on recent applications
		'''
        # getSourceSession resets sinedon
        source_session = self.getSourceSession()
        q = leginondata.ApplicationData()
        all_apps = self.research(q)
        unique_apps = []
        allalias = {}
        for appdata in all_apps:
            if appdata['name'] in unique_apps:
                continue
            q = leginondata.NodeSpecData(application=appdata)
            results = self.research(q)
            for r in results:
                if r['class string'] not in allalias.keys():
                    allalias[r['class string']] = []
                allalias[r['class string']].append(r['alias'])
            unique_apps.append(appdata['name'])
        # import settings
        self.importSettingsByClassAndAlias(allalias)
示例#11
0
except:
	print '''no 'delapps' file'''
	sys.exit()

delapps = f.readlines()
f.close()
delapps = [app[:-1] for app in delapps]

appids = []
evtids = []
nodids = []

db = sinedon.getConnection('leginondata')

for delapp in delapps:
	qapp = leginondata.ApplicationData(name=delapp)
	apps = db.query(qapp)
	appids.extend([a.dbid for a in apps])

if not appids:
	print '''No apps listed in 'delapps' file exist in DB'''
	sys.exit()

host = raw_input('DB Host: ')
dbname = raw_input('DB Name: ')
user = raw_input('DB User: ')
passwd = getpass.getpass()

db = MySQLdb.connect(host=host, user=user, db=dbname, passwd=passwd)
db.autocommit(True)