def updateAcquisitionSettings(): settingsclasses = [] for value in leginondata.__dict__.values(): try: if issubclass(value, leginondata.AcquisitionSettingsData): settingsclasses.append(value) except: pass print 'Settings Classes:' for s in settingsclasses: print ' %s' % (s, ) qusers = leginondata.UserData() users = qusers.query() for user in users: print 'USER', user['name'] qsession = leginondata.SessionData(user=user) for cls in settingsclasses: print '==========================' print 'CLS', cls temp_add_drift(cls) qset = cls(session=qsession) settings = qset.query() recent = {} for s in settings: if s['name'] not in recent: recent[s['name']] = s drift2transform(s)
def run(self): sinedon.setConfig('leginondata', db=self.source_dbname) userdata = leginondata.UserData(username='******').query()[0] self.publish([ userdata, ]) self.adminid = userdata.dbid
def run(self): userids = self.getEssentialUsers() for id in userids: sinedon.setConfig('leginondata', db=self.source_dbname) print 'querying user %d' % id userdata = leginondata.UserData().direct_query(id) self.publish([ userdata, ])
def archiveAdminSettings(): ''' Archive all users and sessions in the project identified by id number ''' adminid = archiveAdminUser() if adminid is None: print "No administration user found, Abort" sys.exit(1) u = leginondata.UserData().direct_query(adminid) recent_session = leginondata.SessionData(user=u).query()[0] app = SettingArchiver(recent_session['name']) app.run() app = None
def upgradeLeginonDB(self): if not self.leginon_dbupgrade.columnExists('AcquisitionSettingsData', 'adjust for transform'): return users = leginondata.UserData().query() for userdata in users: sessionq = leginondata.SessionData(user=userdata) asettingsq = leginondata.AcquisitionSettingsData(session=sessionq,name='Centered Square') # only need to change the most recent one asettings = asettingsq.query(results=1) if asettings: asettingsdata = asettings[0] if asettingsdata['adjust for transform'] == 'no': print asettingsdata.dbid,asettingsdata['session']['name'],asettingsdata['session']['user']['username'] self.leginon_dbupgrade.updateColumn('AcquisitionSettingsData', 'adjust for transform',"'one'",'`DEF_id`=%d' % asettingsdata.dbid,True)
if leginondb.tableExists('GroupData'): if not leginondb.columnExists( 'GroupData', 'REF|projectdata|privileges|privilege'): leginondb.addColumn('GroupData', 'REF|projectdata|privileges|privilege', leginondb.int) #=================== # # set administrators group privileges to highest privilege for groups # #=================== q = projectdata.privileges(groups=4) adminpriv = q.query(results=1) adminprivid = adminpriv[0].dbid q = leginondata.UserData(username='******') adminuser = q.query(results=1) adminuser = adminuser[0] # some old databases have no group assigned to users if adminuser['group'] is not None: admingroupid = adminuser['group'].dbid else: qgroup = leginondata.GroupData() admingroup = qgroup.query() if len(admingroup) > 0: admingroupid = admingroup[-1].dbid else: qgroup['name'] = 'administrators' qgroup.insert() admingroupid = qgroup.dbid if adminprivid and admingroupid:
def getAdministratorUser(self): try: return leginondata.UserData(username='******').query()[0] except: print "Can not find administrator user, Aborting" sys.exit(1)
def getAdministratorUserId(self): return leginondata.UserData(username='******').query()[0].dbid