Example #1
0
File: CLI.py Project: dmwm/DQIS
 def create_doc(self): #what to do if document ID is existing
     '''
     It takes run, lumi dataset. In args first parameter has to be bfield.
     Other following variables in args - key value pairs. 
     '''
     run = self.options['run']
     lumi = self.options['lumi']
     dataset = self.options['dataset']
     bfield = self.options['bfield']
     id = self.generate_doc_id(run, lumi, dataset)
     bfield = self.expect_nothing_or_int(bfield) #can thow exception
     doc = {'bfield': bfield, 
            '_id': id,
            'dataset': dataset.split("/")[1:],
            'run': long(run),
            'lumi': long(lumi)}
     
     doc['map'] = {}
     
     for k, v in self.option['keys']:
         doc['map'][k] = bool(v) # adding keys
         
     db = self.get_connection() #TODO give connection
     r = DQISResult(dqis_db = db, dict = doc)
     r.save()
Example #2
0
File: CLI.py Project: dmwm/DQIS
 def del_doc_by_id(self, id):
     doc = self.get_document_id_or_rdl()    
     try:   
         doc = DQISResult(dqis_db = self.database, 
                          dict= self.database.document(id))
         doc.delete()
         doc.save()
     except:
         raise DocumentCouldNotBeDeleted(id)
Example #3
0
File: CLI.py Project: dmwm/DQIS
 def push_doc(self):
     '''
     Pushing document by run lumi dataset. Pushing from file
     '''
     if self.options['filename']:
         try:
             f = open(self.options['filename'], 'r')
             entry = json.load(f)
         except:
             print "Bad file name or file content"
             exit() #maby to throw common exceptions
     else:
         print "File name required"
         exit()    
     dts = "/"+"/".join(entry['dataset'])
     id = self.generate_doc_id(entry['run'], entry['lumi'], dts)    
     entry['_id'] = id
     if entry.has_key('_rev'):
         del entry['_rev']
     d = DQISResult(dqis_db=self.database, dict=entry)
     d.save() #check conflict errors. delete rev