def run(self): # DEF_id field in SessionData table is used to choose which row of data to update sessionid = self.sessiondata.dbid # update query = "update `SessionData` set `image path` = '%s' where `SessionData`.`DEF_id`=%d" % (self.new_path, sessionid) # send the query to the database linked to sinedon module named leginondata directq.complexMysqlQuery('leginondata',query)
def updatePath(self,old_path_list): for pathdict in old_path_list: dbid = pathdict['dbid'] old_path = pathdict['path'] old_parent_len = len(self.old_parent_path) trail_part = old_path[old_parent_len:] new_path = self.new_parent_path + trail_part query = "Update %s.ApPathData set path='%s' where `DEF_id`=%d" % (self.apdbname, new_path,dbid) print query directq.complexMysqlQuery('appiondata',query)
def run(self): # DEF_id field in SessionData table is used to choose which row of data to update sessionid = self.sessiondata.dbid # update query = "update `SessionData` set `image path` = '%s' where `SessionData`.`DEF_id`=%d" % ( self.new_path, sessionid) # send the query to the database linked to sinedon module named leginondata directq.complexMysqlQuery('leginondata', query)
def updatePath(self, old_path_list): for pathdict in old_path_list: dbid = pathdict['dbid'] old_path = pathdict['path'] old_parent_len = len(self.old_parent_path) trail_part = old_path[old_parent_len:] new_path = self.new_parent_path + trail_part query = "Update %s.ApPathData set path='%s' where `DEF_id`=%d" % ( self.apdbname, new_path, dbid) print query directq.complexMysqlQuery('appiondata', query)
def run(self): # setAppionDB apProject.setAppiondbBySessionName(self.sessionname) import sinedon apdbname = sinedon.getConfig('appiondata')['db'] print 'Change apPath in database %s' % apdbname # update query = "update %s.`ApPathData` set `path` = '%s' where %s.`ApPathData`.`path` like '%s'" % (apdbname,self.new_path, apdbname,self.old_path) print query # send the query to the database linked to sinedon module named appiondata directq.complexMysqlQuery('appiondata',query) print 'Path changed from %s to %s' % (self.old_path, self.new_path)
def run(self): # setAppionDB apProject.setAppiondbBySessionName(self.sessionname) import sinedon apdbname = sinedon.getConfig('appiondata')['db'] print 'Change apPath in database %s' % apdbname # update query = "update %s.`ApPathData` set `path` = '%s' where %s.`ApPathData`.`path` like '%s'" % ( apdbname, self.new_path, apdbname, self.old_path) print query # send the query to the database linked to sinedon module named appiondata directq.complexMysqlQuery('appiondata', query) print 'Path changed from %s to %s' % (self.old_path, self.new_path)
def importInstall(self): print "Importing Installation Log...." source_dbinfo = dbconfig.getConfig('projectdata') destination_dbinfo = dbconfig.getConfig('importdata') q = 'select * from install where 1;' results = directq.complexMysqlQuery('projectdata',q) q = 'select * from install where 1;' imported_results = directq.complexMysqlQuery('importdata',q) for row in results: keys = row.keys() values = map((lambda x: row[x]),keys) if not imported_results: keystring = '`'+'`,`'.join(keys)+'`' valuestring = "'"+"','".join(values)+"'" q = "INSERT into `install` (%s) VALUES (%s)" % (keystring, valuestring) directq.complexMysqlQuery('importdata',q) else: q = "UPDATE `install` SET `value` = '%s' where `install`.`key` = '%s';" % (row['value'],row['key']) directq.complexMysqlQuery('importdata',q)
def queryOldPath(self): print 'Change apPath in database %s' % self.apdbname query = "Select DEF_id as dbid, path from %s.ApPathData where path like '%s%%'" % (self.apdbname, self.old_parent_path) print query return directq.complexMysqlQuery('appiondata',query)
datatype = datatypes[key] print 'datatype set to %s' % (datatype) if not datatype: print 'Can not determine datatype' sys.exit(1) new_sessionnames = os.listdir(new_path_base) for sessionname in new_sessionnames: # find session(s) that is named as sessionname. It should be unique results = leginondata.SessionData(name=sessionname).query() if len(results) != 1: print 'Found %d session data record for %s' % (len(results), sessionname) continue new_path = os.path.join(new_path_base, sessionname, 'rawdata') if not os.path.isdir(new_path): print 'New path %s must exists' % (new_path) continue # DEF_id field in SessionData table is used to choose which row of data to update sessionid = results[0].dbid # update query = "update `SessionData` set `%s path` = '%s' where `SessionData`.`DEF_id`=%d" % ( dirtype, new_path, sessionid) # send the query to the database linked to sinedon module named leginondata directq.complexMysqlQuery('leginondata', query)
for key in datatypes.keys(): if key in new_path_base: datatype = datatypes[key] print "datatype set to %s" % (datatype) if not datatype: print "Can not determine datatype" sys.exit(1) new_sessionnames = os.listdir(new_path_base) for sessionname in new_sessionnames: # find session(s) that is named as sessionname. It should be unique results = leginondata.SessionData(name=sessionname).query() if len(results) != 1: print "Found %d session data record for %s" % (len(results), sessionname) continue new_path = os.path.join(new_path_base, sessionname, "rawdata") if not os.path.isdir(new_path): print "New path %s must exists" % (new_path) continue # DEF_id field in SessionData table is used to choose which row of data to update sessionid = results[0].dbid # update query = "update `SessionData` set `%s path` = '%s' where `SessionData`.`DEF_id`=%d" % (dirtype, new_path, sessionid) # send the query to the database linked to sinedon module named leginondata directq.complexMysqlQuery("leginondata", query)
def queryOldPath(self): print 'Change apPath in database %s' % self.apdbname query = "Select DEF_id as dbid, path from %s.ApPathData where path like '%s%%'" % ( self.apdbname, self.old_parent_path) print query return directq.complexMysqlQuery('appiondata', query)