本文整理汇总了Python中qtools.model.Session.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Session.commit方法的具体用法?Python Session.commit怎么用?Python Session.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtools.model.Session
的用法示例。
在下文中一共展示了Session.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __update_batch_plate_record
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [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()
示例2: command
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [as 别名]
def command(self):
app = self.load_wsgi_app()
min_id = 0
if len(self.args) > 1:
min_id = self.args[0]
storage = QLStorageSource(app.config)
qlbplates = Session.query(QLBPlate).filter(QLBPlate.id > min_id).order_by('id').all()
for qlbplate in qlbplates:
try:
path = storage.qlbplate_path(qlbplate)
except Exception:
print "Could not find plate: %s (%s)" % (qlbplate.plate.name if qlbplate.plate else 'Name unknown', qlbplate.id)
continue
try:
qlplate = get_plate(path)
except Exception:
print "Could not read plate: %s (%s)" % (qlbplate.plate.name if qlbplate.plate else 'Name Unknown', qlbplate.id)
continue
if qlplate.is_fam_vic:
qlbplate.dyeset = QLBPlate.DYESET_FAM_VIC
elif qlplate.is_fam_hex:
qlbplate.dyeset = QLBPlate.DYESET_FAM_HEX
elif qlplate.is_eva_green:
qlbplate.dyeset = QLBPlate.DYESET_EVA
else:
qlbplate.dyeset = QLBPlate.DYESET_UNKNOWN
print "Assigned dye %s - %s (%s)" % (qlbplate.dyeset, qlbplate.plate.name if qlbplate.plate else 'Name Unknown', qlbplate.id)
Session.commit()
示例3: tearDown
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [as 别名]
def tearDown(self):
from qtools.model import Session
Session.delete(self.testUser)
Session.delete(self.testProject)
Session.delete(self.readQLP)
Session.delete(self.unreadQLP)
Session.commit()
示例4: register_algorithm
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [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'))
示例5: batch_plate_template_download
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [as 别名]
def batch_plate_template_download(self, id=None):
plate = self.__load_batch_plate(id)
box2 = Session.query(Box2).get(self.form_result['box2_id'])
if not plate or not box2:
abort(404)
code = plate.batch.plate_type.code
if self.form_result['qc_plate']:
plate.qc_plate = self.form_result['qc_plate']
Session.commit()
# TODO FIXFIX or incorporate into model
if plate.qc_plate:
serial = 'QC'
else:
serial = box2.name.split(' ')[-1]
# only mfgco supported right now
if code == 'mfgco':
qlt_file = "%s/carryover.qlt" % config['qlb.setup_template_store']
elif code == 'fvtitr':
qlt_file = "%s/fvbatch_QC.qlt" % config['qlb.setup_template_store']
else:
abort(404)
response.headers['Content-Type'] = 'application/quantalife-template'
h.set_download_response_header(request, response, "%s_%s.qlt" % (serial, plate.name))
response.headers['Pragma'] = 'no-cache'
response.headers['Cache-Control'] = 'no-cache'
return forward(FileApp(qlt_file, response.headerlist))
示例6: batch_plate_do_upload
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [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))
示例7: batch_csfv_unhook
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [as 别名]
def batch_csfv_unhook(self):
plate = self.__load_batch_plate(self.form_result['batch_plate_id'])
plate.plate_id = None
Session.commit()
session['flash'] = 'CSFV QC plate discarded.'
session.save()
return redirect(url(controller='product', action='batch_plates', id=plate.mfg_batch_id))
示例8: save
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [as 别名]
def save(self, id=None):
"""
"""
if id is None:
abort(404)
assay_q = Session.query(Assay)
assay = assay_q.filter_by(id=id).first()
if assay is None:
abort(404)
reload_sequences = False
for k, v in self.form_result.items():
if k in ("primer_fwd", "primer_rev", "chromosome", "probe_pos", "amplicon_width", "snp_rsid"):
if getattr(assay, k) != v:
reload_sequences = True
if k not in ("id"):
setattr(assay, k, v)
# blow away previous sequences; on view, this will update.
if reload_sequences:
cached_sequences = assay.cached_sequences
for i in range(len(cached_sequences)):
cs = cached_sequences[-1]
snps = cs.snps
for j in range(len(snps)):
snp = snps.pop()
Session.delete(snp)
cached_sequences.pop()
Session.delete(cs)
self.__update_tms(assay)
Session.commit()
session.save()
redirect(url(controller="assay", action="view", id=assay.id))
示例9: batch_delete
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [as 别名]
def batch_delete(self, id=None):
batch = self.__load_batch(id)
if not batch:
abort(404)
# check for bound plates
bound_plates = [p for p in batch.plates if p.plate_id is not None]
if bound_plates:
session['flash'] = "Cannot delete this batch; there are run plates bound to it."
session['flash_class'] = 'error'
session.save()
return redirect(url(controller='product', action='batch_edit', id=id))
else:
try:
for plate in batch.plates:
Session.delete(plate)
batch.plates = []
Session.delete(batch)
Session.commit()
session['flash'] = "Batch deleted."
session.save()
except Exception, e:
logging.exception("Error from batch deletion:")
session['flash'] = "Could not delete the batch from the database."
session['flash_class'] = 'error'
session.save()
return redirect(url(controller='product', action='batch_edit', id=id))
# redirect = Exception! good to know-- don't put in try block...
return redirect(url(controller='product', action='batch_list'))
示例10: sensitivity
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [as 别名]
def sensitivity(self):
enz = Session.query(Enzyme).get(self.form_result['enzyme'])
if not self.form_result['sensitivity']:
enz.methylation_sensitivity = None
else:
enz.methylation_sensitivity = self.form_result['sensitivity']
Session.commit()
return "OK"
示例11: instock
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [as 别名]
def instock(self):
enz = Session.query(VendorEnzyme).get(self.form_result['vendor_enzyme_id'])
if self.form_result['in_stock']:
enz.stock_units = 1
else:
enz.stock_units = 0
Session.commit()
return 'OK'
示例12: enzyme_conc_create
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [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"]))
示例13: update_reader
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [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))
示例14: save_reagents
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [as 别名]
def save_reagents(self, id=None):
self.__load_context()
setup, struct = self.__load_setup(id)
if not setup:
abort(404)
for k, v in self.form_result.items():
setattr(setup, k, v)
Session.commit()
redirect(url(controller='setup', action='dg', id=id, beta=c.beta))
示例15: upload_file
# 需要导入模块: from qtools.model import Session [as 别名]
# 或者: from qtools.model.Session import commit [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