本文整理汇总了Python中genologics.lims.Lims.upload_new_file方法的典型用法代码示例。如果您正苦于以下问题:Python Lims.upload_new_file方法的具体用法?Python Lims.upload_new_file怎么用?Python Lims.upload_new_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类genologics.lims.Lims
的用法示例。
在下文中一共展示了Lims.upload_new_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_upload_new_file
# 需要导入模块: from genologics.lims import Lims [as 别名]
# 或者: from genologics.lims.Lims import upload_new_file [as 别名]
def test_upload_new_file(self, mocked_open, mocked_isfile):
lims = Lims(self.url, username=self.username, password=self.password)
xml_intro = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>"""
file_start = """<file:file xmlns:file="http://genologics.com/ri/file">"""
file_start2 = """<file:file xmlns:file="http://genologics.com/ri/file" uri="{url}/api/v2/files/40-3501" limsid="40-3501">"""
attached = """ <attached-to>{url}/api/v2/samples/test_sample</attached-to>"""
upload = """ <original-location>filename_to_upload</original-location>"""
content_loc = """ <content-location>sftp://{url}/opt/gls/clarity/users/glsftp/clarity/samples/test_sample/test</content-location>"""
file_end = """</file:file>"""
glsstorage_xml = '\n'.join([xml_intro,file_start, attached, upload, content_loc, file_end]).format(url=self.url)
file_post_xml = '\n'.join([xml_intro, file_start2, attached, upload, content_loc, file_end]).format(url=self.url)
with patch('requests.post', side_effect=[Mock(content=glsstorage_xml, status_code=200),
Mock(content=file_post_xml, status_code=200),
Mock(content="", status_code=200)]):
file = lims.upload_new_file(Mock(uri=self.url+"/api/v2/samples/test_sample"),
'filename_to_upload')
assert file.id == "40-3501"
with patch('requests.post', side_effect=[Mock(content=self.error_xml, status_code=400)]):
self.assertRaises(HTTPError,
lims.upload_new_file,
Mock(uri=self.url+"/api/v2/samples/test_sample"),
'filename_to_upload')
示例2: main
# 需要导入模块: from genologics.lims import Lims [as 别名]
# 或者: from genologics.lims.Lims import upload_new_file [as 别名]
def main(args):
log = []
lims = Lims(BASEURI,USERNAME,PASSWORD)
process = Process(lims, id=args.pid)
for io in process.input_output_maps:
if io[1]['output-generation-type'] != 'PerInput':
continue
try:
starting_amount = obtain_amount(io[0]['uri'])
except Exception as e:
log.append(str(e))
starting_amount = 0
log.append("Starting amount of {} : {} ng".format(io[0]['uri'].samples[0].name, starting_amount))
current_amount = starting_amount
#preps
preps = lims.get_processes(inputartifactlimsid=io[0]['uri'].id, type=["Setup Workset/Plate", "Amount confirmation QC"])
for pro in preps:
if pro.id == args.pid:
continue # skip the current step
for prepio in pro.input_output_maps:
if prepio[1]['output-generation-type'] == 'PerInput' and prepio[0]['uri'].id == io[0]['uri'].id:
if "Amount taken (ng)" in prepio[1]['uri'].udf: #should always be true
prep_amount = prepio[1]['uri'].udf["Amount taken (ng)"]
log.append("Removing {} ng for prep {} for sample {}".format(prep_amount, pro.id, io[0]['uri'].samples[0].name))
current_amount = current_amount - prep_amount
else:
log.append("No Amount Taken found for prep {} of sample {}".format(pro.id, io[0]['uri'].samples[0].name))
if current_amount < 0:
log.append("Estimated amount for sample {} is {}, correcting to zero".format(io[0]['uri'].samples[0].name, current_amount))
current_amount = 0
update_output_values(io[0]['uri'], io[1]['uri'], current_amount)
with open("amount_check_log.txt", "w") as f:
f.write("\n".join(log))
for out in process.all_outputs():
if out.name == "QC Assignment Log File" :
for f in out.files:
lims.request_session.delete(f.uri)
lims.upload_new_file(out, "amount_check_log.txt")