"""
assert flowcell is not None
assert serial is not None
+
+ LTS_UPDATED = False
+ SD_UPDATED = False
+ LIBRARY_UPDATED = False
###########################################
# Retrieve Storage Device
lts.flowcell = fc
# Need a primary keey before linking to storage devices
lts.save()
+ LTS_UPDATED = True
############################################
# Link Storage to Flowcell
# Add a link to this storage device if it is not already linked.
- if sd not in lts.storage_devices.values():
+ if sd not in lts.storage_devices.all():
lts.storage_devices.add(sd)
+ SD_UPDATED = True
###########################################
# Add Library Links to LTS
- if fc.lane_1_library not in lts.storage_devices.values():
+ if fc.lane_1_library not in lts.libraries.all():
lts.libraries.add(fc.lane_1_library)
+ LIBRARY_UPDATED = True
+ print 1
- if fc.lane_2_library not in lts.storage_devices.values():
+ if fc.lane_2_library not in lts.libraries.all():
lts.libraries.add(fc.lane_2_library)
+ LIBRARY_UPDATED = True
+ print 2
- if fc.lane_3_library not in lts.storage_devices.values():
+ if fc.lane_3_library not in lts.libraries.all():
lts.libraries.add(fc.lane_3_library)
+ LIBRARY_UPDATED = True
+ print 3
- if fc.lane_4_library not in lts.storage_devices.values():
+ if fc.lane_4_library not in lts.libraries.all():
lts.libraries.add(fc.lane_4_library)
+ LIBRARY_UPDATED = True
+ print 4
- if fc.lane_5_library not in lts.storage_devices.values():
+ if fc.lane_5_library not in lts.libraries.all():
lts.libraries.add(fc.lane_5_library)
+ LIBRARY_UPDATED = True
+ print 5
- if fc.lane_6_library not in lts.storage_devices.values():
+ if fc.lane_6_library not in lts.libraries.all():
lts.libraries.add(fc.lane_6_library)
+ LIBRARY_UPDATED = True
+ print 6
- if fc.lane_7_library not in lts.storage_devices.values():
+ if fc.lane_7_library not in lts.libraries.all():
lts.libraries.add(fc.lane_7_library)
+ LIBRARY_UPDATED = True
+ print 7
- if fc.lane_8_library not in lts.storage_devices.values():
+ if fc.lane_8_library not in lts.libraries.all():
lts.libraries.add(fc.lane_8_library)
+ LIBRARY_UPDATED = True
+ print 8
# Save Changes
lts.save()
- return HttpResponse("Success")
\ No newline at end of file
+ msg = ['Success:']
+ if LTS_UPDATED or SD_UPDATED or LIBRARY_UPDATED:
+ msg.append(' LongTermStorage (LTS) Created: %s' % (LTS_UPDATED))
+ msg.append(' Storage Device Linked to LTS: %s' % (SD_UPDATED))
+ msg.append(' Libraries updated in LTS: %s' % (LIBRARY_UPDATED))
+ else:
+ msg.append(' No Updates Needed.')
+
+ return HttpResponse('\n'.join(msg))
\ No newline at end of file
help="device flowcell is being archived to")
parser.add_option("-s", "--serial", action="store", type="string", dest="serial",
help="serial num. of archive device")
+ parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False)
return parser
-def update_db(flowcell, serial):
+def update_db(flowcell, serial, debug=False):
"""
Creates link between flowcell and storage device over http
"""
www = urllib.urlopen(settings.LINK_FLOWCELL_STORAGE_DEVICE_URL+'%s/%s/' % (flowcell, serial))
httpcode = www.getcode()
if httpcode != 200:
- print 'ERROR - HTTP OUTPUT:'
- print www.read()
+ print 'ERROR - HTTP OUTPUT (Return Code: %s); use -v/--verbose for more details.' % (httpcode)
+ if debug:
+ print www.read()
sys.exit(httpcode)
print "DB Update of %s & %s succeeded" % (flowcell, serial)
+ print www.read()
def process_args(parser):
" The serial number is extracted automatically if the device is provided."
sys.exit(2)
- print options.flowcell
- print options.device
- print options.serial
+ print 'Flowcell:', options.flowcell
+ print ' Device:', options.device
+ print ' Serial:', options.serial
if options.flowcell is None:
msg.append(" --flowcell required")
# Update db records
if options.device is not None:
serial = get_hd_serial_num(options.device)
- update_db(flowcell=options.flowcell, serial=serial)
+ update_db(flowcell=options.flowcell, serial=serial, debug=options.verbose)
elif options.serial is not None:
- update_db(flowcell=options.flowcell, serial=options.serial)
+ update_db(flowcell=options.flowcell, serial=options.serial, debug=options.verbose)
else:
msg ="FATAL should not happen error occured; i.e. the best kind!"
raise ValueError, msg