当前位置: 首页>>代码示例>>Python>>正文


Python Session.add方法代码示例

本文整理汇总了Python中qtools.model.Session.add方法的典型用法代码示例。如果您正苦于以下问题:Python Session.add方法的具体用法?Python Session.add怎么用?Python Session.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qtools.model.Session的用法示例。


在下文中一共展示了Session.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_algorithm

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
    def register_algorithm(self):
        storage = QSAlgorithmSource(config)
        existing_folders = [tup[0] for tup in Session.query(ReprocessConfig.original_folder).all()]

        errors = dict()
        src_dir = self.form_result['src_dir']
        if src_dir in existing_folders:
            errors['src_dir'] = 'This algorithm has already been registered.'

        elif not storage.source_path_exists(src_dir):
            errors['src_dir'] = 'This algorithm is not accessible in the file system.'

        if self.form_result['peak_detection_version'] == (0,0):
            # this is arbitrary
            peak_detection_version = (0, QUANTASOFT_DIR_VERSION_RE.search(src_dir).group(1).split('_')[-1])
        else:
            peak_detection_version = self.form_result['peak_detection_version']

        if self.form_result['peak_quantitation_version'] == (0,0):
            peak_quantitation_version = (0, QUANTASOFT_DIR_VERSION_RE.search(src_dir).group(1).split('_')[-1])
        else:
            peak_quantitation_version = self.form_result['peak_quantitation_version']

        if errors:
            resp = self._algorithms_base()
            defaults = AlgorithmRegisterForm.from_python(self.form_result)
            return h.render_bootstrap_form(resp,
                defaults=defaults,
                errors=errors,
                error_formatters=h.tw_bootstrap_error_formatters)

        try:
            rp = ReprocessConfig(name=src_dir.split(os.path.sep)[0],
                                 code=self.form_result['code'],
                                 peak_detection_major=peak_detection_version[0],
                                 peak_detection_minor=peak_detection_version[1],
                                 peak_quant_major=peak_quantitation_version[0],
                                 peak_quant_minor=peak_quantitation_version[1],
                                 trigger_fixed_width=100,
                                 active=True,
                                 cluster_mode=ReprocessConfig.CLUSTER_MODE_CLUSTER,
                                 original_folder=src_dir)

            storage.add_reprocessor(src_dir, self.form_result['code'])
            Session.add(rp)
            Session.commit()
            session['flash'] = 'New algorithm reprocessor created.'
            session.save()
            return redirect(url(controller='product', action='algorithms'))

        except shutil.Error:
            session['flash'] = 'Could not copy source algorithm to destination.'
            session['flash_class'] = 'error'
            session.save()
            return redirect(url(controller='product', action='algorithms'))
        except IOError:
            session['flash'] = "Could not access the algorithm's file system."
            session['flash_class'] = 'error'
            session.save()
            return redirect(url(controller='product', action='algorithms'))
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:62,代码来源:product.py

示例2: command

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
    def command(self):
        app = self.load_wsgi_app()
        root = app.config['qlb.dg_root']
        top_folders = app.config['qlb.top_dg_folders']
        source = DGLogSource(root, top_folders)

        min_file_dict = dict(Session.query(DropletGeneratorRun.dirname,
                                      func.max(DropletGeneratorRun.basename).label('last_file')).\
                                group_by(DropletGeneratorRun.dirname).all())
        
        min_file_prefix = '2011-03-21'

        dgs = Session.query(DropletGenerator).all()
        dg_ids = [dg.id for dg in dgs]

        for dirname, basename in source.path_iter(min_file_name=min_file_prefix, min_file_dict=min_file_dict):
            print dirname, basename
            dg_run = read_dg_log(source.full_path(dirname, basename))
            if not dg_run:
                continue
            dg_run.dirname = dirname
            dg_run.basename = basename
            if dg_run.droplet_generator_id in dg_ids:
                Session.add(dg_run)
                Session.commit()
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:27,代码来源:cron.py

示例3: batch_plate_do_upload

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
    def batch_plate_do_upload(self, id=None):
        batch_plate = self.__load_batch_plate(id)
        if not batch_plate:
            abort(404)
        box2 = self.form_result['box2']
        plate = self.form_result['plate']
        plate_type = batch_plate.batch.plate_type
        if plate_type.code == 'fvtitr' and len(plate.analyzed_wells) == 4:
            # if four wells, it's really a MFGCC (FVTITR FAM+/VIC+ should have 2)
            plate_type = Session.query(PlateType).filter_by(code='mfgcc').one()

        plateobj = save_plate_from_upload_request(request.POST['plate'], plate, box2, plate_type_obj=plate_type)

        # I want to put this in the form validator, but it's field dependent, so not right now
        if plate_type.code in ('mfgcc', 'bcc'):
            ok, message = validate_colorcomp_plate(plate)
            if not ok:
                response = self._batch_plate_upload_base(id)
                Session.rollback()
                return h.render_bootstrap_form(response, errors={'plate': message})
        
        Session.add(plateobj)
        if batch_plate.batch.plate_type.code == plate_type.code:
            batch_plate.plate = plateobj
        else:
            batch_plate.secondary_plate = plateobj

        batch_plate.qc_plate = self.form_result['qc_plate']
        batch_plate.plate_notes = self.form_result['plate_notes']
        Session.commit()

        session['flash'] = 'Plate linked.'
        session.save()
        return redirect(url(controller='metrics', action='per_plate', id=plateobj.id))
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:36,代码来源:product.py

示例4: __update_batch_plate_record

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
 def __update_batch_plate_record(self, record):
     record.dg_method = self.form_result['dg_method']
     record.qc_plate = self.form_result['qc_plate'] and True or False
     record.plate_notes = self.form_result['plate_notes']
     record.thermal_cycler_id = self.form_result['thermal_cycler_id']
     Session.add(record)
     Session.commit()
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:9,代码来源:product.py

示例5: __form_to_model

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
 def __form_to_model(self, form, model=None):
     if not model:
         model = SequenceGroupTag()
         Session.add(model)
     
     model.name  = form['name']
     model.notes = form['notes']
     model.owner_id = form['owner_id']
     Session.merge(model)
     return model
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:12,代码来源:assay_group.py

示例6: update_reader

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
    def update_reader(self):
        log_entry = self.__make_box2_log_entry(self.form_result)
        Session.add(log_entry)
        Session.commit()

        box2 = Session.query(Box2).get(self.form_result['box2_id'])
        session['flash'] = 'Configuration for %s updated.' % box2.name
        session.save()

        redirect(url(controller='admin', action='reader_history', id=box2.code))
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:12,代码来源:admin.py

示例7: enzyme_conc_create

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
    def enzyme_conc_create(self):
        conc = EnzymeConcentration()

        for k, v in self.form_result.items():
            setattr(conc, k, v)

        Session.add(conc)
        Session.commit()

        redirect(url(controller="assay", action="view", id=self.form_result["assay_id"]))
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:12,代码来源:assay.py

示例8: upload_file

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
    def upload_file(self, id=None):
        self.__setup_box2_code_context(id)
        source = QLStorageSource(config)
        basename = upload_basename(self.form_result['file'].filename)
        errors = {}

        existing_path = self.__file_name_query(c.box2.id, basename)
        if existing_path and not self.form_result['file_id'] == existing_path.id:
            # todo, if existing update path
            errors = dict(file='File with this name already exists for this reader.  Use the Update page.')

        path = "%s_%s" % (int(round(time.time())), basename)
        thefile = self.form_result['file'].file

        filerec = self.__file_id_query(c.box2.id, self.form_result['file_id'])
        new_record = False
        if not filerec:
            filerec = Box2File(box2_id=c.box2.id)
            new_record = True

        filerec.name = basename
        filerec.deleted = False
        filerec.path = path
        filerec.updated = datetime.datetime.now()
        filerec.description = self.form_result['description']
        filerec.mime_type = guess_type(basename)[0] or 'text/plain'


        if errors:
            response = self._upload_base(id)
            return h.render_bootstrap_form(response, errors=errors, error_formatters=h.tw_bootstrap_error_formatters)

        try:
            attachment_dir = self.__upload_file_dir(c.box2)
            if not os.path.exists(attachment_dir):
                os.mkdir(attachment_dir)

            permanent_path = self.__upload_file_path(c.box2, path)
            permanent_file = open(permanent_path, 'wb')
            shutil.copyfileobj(thefile, permanent_file)
            thefile.close()
            permanent_file.close()

            filerec.size = os.stat(permanent_path).st_size
            if new_record:
                Session.add(filerec)
            else:
                Session.merge(filerec)
            Session.commit()
            session['flash'] = 'File uploaded.'
            write_success = True
        except Exception, e:
            session['flash'] = 'Could not upload file: %s' % str(e)
            session['flash_class'] = 'error'
            write_success = False
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:57,代码来源:box2.py

示例9: create

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
    def create(self):
        self.__load_context()
        plate_setup = PlateSetup()
        plate_setup.project_id = self.form_result['project_id']
        plate_setup.author_id = self.form_result['author_id']
        plate_setup.name = self.form_result['name']
        plate_setup.prefix = make_setup_name(plate_setup)

        Session.add(plate_setup)
        Session.commit()
        redirect(url(controller='setup', action='consumable', id=plate_setup.id, beta=c.beta))
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:13,代码来源:setup.py

示例10: update_size

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
    def update_size(self, id=None):
        batch = self.__batch(id)
        if not batch:
            abort(404)

        batch_test = self.__batch_test(id)
        if not batch_test:
            batch_test = ConsumableBatchTest(consumable_batch_id=batch.id)
            Session.add(batch_test)

        batch_test.pixel_calibration = self.form_result["pixel_calibration"]

        garbage = []
        # check for cleared entities first
        for chan in batch_test.size_channels:
            thechip = [chip for chip in self.form_result["chips"] if chip["chip_num"] == chan.chip_num]
            if not thechip:
                garbage.append(chan)
                continue

            thechan = [c for c in thechip[0]["channels"] if c["channel_num"] == chan.channel_num]
            if not thechan:
                garbage.append(chan)
                continue

            if thechan[0]["droplet_count"] is None and thechan[0]["mean"] is None and thechan[0]["stdev"] is None:
                garbage.append(chan)

        for g in garbage:
            batch_test.size_channels.remove(g)
            Session.delete(g)

        # This is the case for a GAE-like Entity or a Mongo object or storing
        # JSON in a text column or whatever
        for chip in self.form_result["chips"]:
            for channel in chip["channels"]:
                if channel["droplet_count"] is not None or channel["mean"] is not None or channel["stdev"] is not None:
                    dbchan = batch_test.size_channel(chip["chip_num"], channel["channel_num"])
                    if not dbchan:
                        dbchan = ConsumableBatchSizeChannel(
                            chip_num=chip["chip_num"], channel_num=channel["channel_num"]
                        )
                        batch_test.size_channels.append(dbchan)

                    dbchan.size_mean = channel["mean"]
                    dbchan.size_stdev = channel["stdev"]
                    dbchan.droplet_count = channel["droplet_count"]

        Session.commit()
        session["flash"] = "Sizes updated."
        session.save()

        return redirect(url(controller="consumable", action="size", id=batch.id))
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:55,代码来源:consumable.py

示例11: create

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
 def create(self):
     batch = ConsumableBatch(
         manufacturer=self.form_result["manufacturer"],
         insert=self.form_result["insert"],
         consumable_molding_style_id=self.form_result["molding_style"],
         consumable_bonding_style_id=self.form_result["bonding_style"],
         bside=self.form_result["bside"],
         lot_num=self.form_result["lot_number"],
         manufacturing_date=self.form_result["manufacture_date"],
     )
     Session.add(batch)
     Session.commit()
     session.flash = "Created batch %s" % self.form_result["lot_number"]
     session.save()
     return redirect(url(controller="consumable", action="details", id=batch.id))
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:17,代码来源:consumable.py

示例12: add_qlp_plate_record

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
def add_qlp_plate_record(qlplate, qlbfile):
    """
    Create a QLBPlate object based off a new QLBFile.  Adds to
    the current SQLAlchemy Session object, but does not commit (will
    rollback, however, if there is a problem)
    """
    valid_plate = True
    plate = None
    
    try:
        plate = QLBPlate()
        set_qlp_plate_record_attrs(plate, qlplate)
        plate.file = qlbfile
        Session.add(plate)
    except Exception, e:
        print e
        Session.rollback()
        valid_plate = False
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:20,代码来源:platescan.py

示例13: cache

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
 def cache(self):
     addresses = self.form_result['addresses']
     for a in addresses:
         if a['validated']:
             cache = MapCache(verified = a['validated'],
                              address = a['address'],
                              lat = a['lat'],
                              lon = a['lon'])
         else:
             cache = MapCache(verified = False,
                              address = a['address'])
         try:
             Session.add(cache)
             Session.commit()
         except Exception, e:
             # in case multiple same addresses per update
             # just fail
             continue
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:20,代码来源:map.py

示例14: do_register_lab_reader

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
    def do_register_lab_reader(self):
        LAB_FILEROOT = 'main'
        storage = QLStorageSource(config)
        path = self.form_result['path']
        name = self.form_result['path'][3:] # sans DR
        new_reader_path = storage.real_path(LAB_FILEROOT, self.form_result['path'])

        new_reader = Box2(name=name,
                          code=name,
                          src_dir=path,
                          reader_type=Box2.READER_TYPE_WHOLE,
                          active=True,
                          fileroot=LAB_FILEROOT)
        Session.add(new_reader)
        Session.commit()
        session['flash'] = 'Reader %s added.' % name
        session.save()
        return redirect(url(controller='admin', action='register_lab'))
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:20,代码来源:admin.py

示例15: tag

# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import add [as 别名]
 def tag(self):
     well = Session.query(QLBWell).get(self.form_result['well_id'])
     if not well:
         abort(500)
     
     tag_ids = [tag.id for tag in well.tags]
     new_id = self.form_result['tag_id']
     if new_id not in tag_ids:
         new_tag = Session.query(WellTag).get(new_id)
         if not new_tag:
             abort(500)
         tag = QLBWellTag(well=well, well_tag=new_tag, tagger_id=self.form_result['tagger_id'])
         Session.add(tag)
         Session.commit()
     
     if self.form_result['tagger_id']:
         session['person_id'] = self.form_result['tagger_id']
         session.save()
     return {'tag_id': new_id, 'tag_names': [tag.name for tag in well.tags]}
开发者ID:v-makarenko,项目名称:vtoolsmq,代码行数:21,代码来源:well.py


注:本文中的qtools.model.Session.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。