def upload_new_file(bqsession, path): """ uploads files to bisque server """ r = save_blob(bqsession, path) print 'Uploaded id: %s url: %s'%(r.get('resource_uniq'), r.get('uri')) return r
def process_full_set(session, start_path): ''' This function will upload files (including non-images) and add annotations to the image get relevant file paths ''' file_list = [] uri_list = [] file_names = [] for dirname, dirnames, filenames in os.walk(start_path): for filename in filenames: # find relevant images # TODO: Add a check for the file types / avoid certain types file_names.append(filename.split('.')[0]) path = os.path.join(dirname, filename) path = path.replace('\\', '/') file_list.append(path) if notFsFile(path): if isValidFile(path): r = save_blob(session, path) if r is None: print('Error uploading') # r is a created metadata document in etree form else: uri = r.get('uri') #this line adds all the tags (by passing into createtags to get the tags, then passing the return into addtags) addTag(uri, path) uri_list.append(uri) print(uri) return uri_list
def main(): parser = argparse.ArgumentParser( description='Set Basic auth credentials on CAS protected Bisque') parser.add_argument('-u', '--credentials', default=None, help="CAS credentials in form of user:password") parser.add_argument("bisque_host", nargs=1) args = parser.parse_args() session = setbasicauth(args.bisque_host[0], *args.credentials.split(':')) resource = etree.Element('image', name="IMG_2014-10-01_18-55-17.png") etree.SubElement(resource, 'tag', name="experiment", value="RPi test") etree.SubElement(resource, 'tag', name="timestamp", value="2014-10-01_18-55-17") r = save_blob(session, LOCAL_FILE_PATH, resource=resource) #r = save_image_pixels(session, LOCAL_FILE_PATH) if r is None: print("Error uploading") else: uri = r.get('uri') print(uri)
def upload_file(self, path, resource=None): #if resource is not None: # print etree.tostring(resource) r = save_blob(self.session, path, resource=resource) if r is None or r.get('uri') is None: print 'Error uploading: %s' % path.encode('ascii', 'replace') return None print 'Uploaded id: %s url: %s' % (r.get('resource_uniq'), r.get('uri')) return r
def take_photo(filename): app_settings = DBSession.query(Settings).first() if app_settings.image_ISO == 'auto': iso_call = '' else: iso_call = ' -ISO ' + str(app_settings.image_ISO) call([ 'raspistill -t 500' + ' -n ' + ' -w ' + str(app_settings.image_width) + ' -h ' + str(app_settings.image_height) + ' -e ' + app_settings.encoding_mode + ' -ex ' + app_settings.exposure_mode + ' -awb ' + app_settings.awb_mode + ' -rot ' + str(app_settings.image_rotation) + ' -ifx ' + app_settings.image_effect + iso_call + ' -o ' + RASPISTILL_DIRECTORY + filename ], stdout=PIPE, shell=True) # if not (RASPISTILL_DIRECTORY == 'raspistillweb/pictures/'): # call ( # ['ln -s ' + RASPISTILL_DIRECTORY + filename # + ' raspistillweb/pictures/' + filename], shell=True # ) #generate_thumbnail(filename) if app_settings.bisque_enabled == 'Yes': resource = etree.Element('image', name=filename) etree.SubElement(resource, 'tag', name="experiment", value="Phenotiki") etree.SubElement(resource, 'tag', name="timestamp", value=os.path.splitext(filename)[0]) bqsession = setbasicauth(bisque_root_url, bisque_user, bisque_pswd) print 'Uploading \'' + filename + '\' to Bisque...' start_time = time() r = save_blob(bqsession, localfile=RASPISTILL_DIRECTORY + filename, resource=resource) elapsed_time = time() - start_time if r is None: print 'Error uploading!' preferences_fail_alert.append('Error uploading \'' + filename + '\' to Bisque!') else: print 'Image uploaded in %.2f seconds' % elapsed_time print r.items() print 'Image URI:', r.get('uri') #call(['cp raspistillweb/pictures/preview.jpg raspistillweb/pictures/'+filename],shell=True) #generate_thumbnail(filename) return
def main(): parser = argparse.ArgumentParser(description='Set Basic auth credentials on CAS protected Bisque') parser.add_argument ('-u', '--credentials', default=None, help="CAS credentials in form of user:password") parser.add_argument ("bisque_host", nargs=1) args = parser.parse_args() session = setbasicauth(args.bisque_host[0], *args.credentials.split(':')) resource = etree.Element('image', name="IMG_2014-10-01_18-55-17.png") etree.SubElement(resource, 'tag', name="experiment", value="RPi test") etree.SubElement(resource, 'tag', name="timestamp", value="2014-10-01_18-55-17") r = save_blob(session, LOCAL_FILE_PATH, resource=resource) #r = save_image_pixels(session, LOCAL_FILE_PATH) if r is None: print("Error uploading") else: uri = r.get('uri') print(uri)
user = config.get('Host', 'user') or 'test' pswd = config.get('Host', 'password') or 'test' session = BQSession().init_local(user, pswd, bisque_root=root, create_mex=False) request = '<image name="%s">'%'series_t_jpeg' request = '%s<value>%s</value>'%(request, localpath2url('f:/dima/develop/python/bq5irods/data/imagedir/admin/tests/multi_file/series_t_jpeg/t_000241.jpg')) request = '%s<value>%s</value>'%(request, localpath2url('f:/dima/develop/python/bq5irods/data/imagedir/admin/tests/multi_file/series_t_jpeg')) request = '%s<tag name="%s" type="%s">'%(request, 'image_meta', 'image_meta') request = '%s<tag name="%s" value="%s" type="number" />'%(request, 'image_num_z', '1') request = '%s<tag name="%s" value="%s" type="number" />'%(request, 'image_num_t', '80') request = '%s<tag name="%s" value="%s" />'%(request, 'dimensions', 'XYCZT') request = '%s<tag name="%s" value="%s" type="number" />'%(request, 'pixel_resolution_x', '0.4') request = '%s<tag name="%s" value="%s" type="number" />'%(request, 'pixel_resolution_y', '0.4') request = '%s<tag name="%s" value="%s" type="number" />'%(request, 'pixel_resolution_t', '2.0') request = '%s<tag name="%s" value="%s" />'%(request, 'pixel_resolution_unit_x', 'micron') request = '%s<tag name="%s" value="%s" />'%(request, 'pixel_resolution_unit_y', 'micron') request = '%s<tag name="%s" value="%s" />'%(request, 'pixel_resolution_unit_t', 'seconds') request = '%s</tag>'%(request) request = '%s</image>'%request #url = session.service_url('data_service', 'image') #r = session.postxml(url, etree.fromstring(request), method='POST') r = save_blob(session, resource=request) if r is None or r.get('uri') is None: print 'Upload failed' else: print 'id: %s'%r.get('resource_uniq') print 'url: %s'%r.get('uri')
def take_photo(filename): app_settings = DBSession.query(Settings).first() if app_settings.image_ISO == 'auto': iso_call = '' else: iso_call = ' -ISO ' + str(app_settings.image_ISO) # ----- TEST CODE -----# #print PiCamera.AWB_MODES #with picamera.PiCamera() as camera: # camera.resolution = (app_settings.image_width,app_settings.image_height) # # Camera warm-up time # time.sleep(2) # camera.shutter_speed = camera.exposure_speed # camera.exposure_mode = app_settings.exposure_mode # camera.awb_mode = app_settings.awb_mode # camera.image_rotation = app_settings.image_rotation # camera.image_effect = app_settings.image_effect # camera.iso = 0 if app_settings.image_ISO == 'auto' else app_settings.image_ISO # camera.capture(RASPISTILL_DIRECTORY + filename + '_test', format=app_settings.encoding_mode) # ----- TEST CODE -----# call ( ['raspistill -t 500' + ' -n ' + ' -w ' + str(app_settings.image_width) + ' -h ' + str(app_settings.image_height) + ' -e ' + app_settings.encoding_mode + ' -ex ' + app_settings.exposure_mode + ' -awb ' + app_settings.awb_mode + ' -rot ' + str(app_settings.image_rotation) + ' -ifx ' + app_settings.image_effect + iso_call + ' -o ' + RASPISTILL_DIRECTORY + filename], stdout=PIPE, shell=True ) # if not (RASPISTILL_DIRECTORY == 'raspistillweb/pictures/'): # call ( # ['ln -s ' + RASPISTILL_DIRECTORY + filename # + ' raspistillweb/pictures/' + filename], shell=True # ) #generate_thumbnail(filename) if app_settings.bisque_enabled == 'Yes': resource = etree.Element('image', name=filename) etree.SubElement(resource, 'tag', name="experiment", value="Phenotiki") etree.SubElement(resource, 'tag', name="timestamp", value=os.path.splitext(filename)[0]) bqsession = setbasicauth(app_settings.bisque_root_url, app_settings.bisque_user, app_settings.bisque_pswd) print 'Uploading \'' + filename + '\' to Bisque...' start_time = time() r = save_blob(bqsession, localfile=RASPISTILL_DIRECTORY+filename, resource=resource) elapsed_time = time() - start_time if r is None: print 'Error uploading!' preferences_fail_alert.append('Error uploading \'' + filename + '\' to Bisque!') else: print 'Image uploaded in %.2f seconds' % elapsed_time print r.items() print 'Image URI:', r.get('uri') #call(['cp raspistillweb/pictures/preview.jpg raspistillweb/pictures/'+filename],shell=True) #generate_thumbnail(filename) return
def take_photo(filename): app_settings = DBSession.query(Settings).first() if app_settings.image_ISO == 'auto': iso_call = '' else: iso_call = ' -ISO ' + str(app_settings.image_ISO) # ----- TEST CODE -----# #print PiCamera.AWB_MODES #with picamera.PiCamera() as camera: # camera.resolution = (app_settings.image_width,app_settings.image_height) # # Camera warm-up time # time.sleep(2) # camera.shutter_speed = camera.exposure_speed # camera.exposure_mode = app_settings.exposure_mode # camera.awb_mode = app_settings.awb_mode # camera.image_rotation = app_settings.image_rotation # camera.image_effect = app_settings.image_effect # camera.iso = 0 if app_settings.image_ISO == 'auto' else app_settings.image_ISO # camera.capture(RASPISTILL_DIRECTORY + filename + '_test', format=app_settings.encoding_mode) # ----- TEST CODE -----# call ( ['raspistill -t 500' + ' -n ' + ' -w ' + str(app_settings.image_width) + ' -h ' + str(app_settings.image_height) + ' -e ' + app_settings.encoding_mode + ' -ex ' + app_settings.exposure_mode + ' -awb ' + app_settings.awb_mode + ' -rot ' + str(app_settings.image_rotation) + ' -ifx ' + app_settings.image_effect + iso_call + ' -o ' + RASPISTILL_DIRECTORY + filename], stdout=PIPE, shell=True ) # if not (RASPISTILL_DIRECTORY == 'raspistillweb/pictures/'): # call ( # ['ln -s ' + RASPISTILL_DIRECTORY + filename # + ' raspistillweb/pictures/' + filename], shell=True # ) #generate_thumbnail(filename) if app_settings.bisque_enabled == 'Yes' and internet_on(): resource = etree.Element('image', name=filename) etree.SubElement(resource, 'tag', name="experiment", value="Phenotiki") etree.SubElement(resource, 'tag', name="timestamp", value=os.path.splitext(filename)[0]) bqsession = setbasicauth(app_settings.bisque_root_url, app_settings.bisque_user, app_settings.bisque_pswd) print 'Uploading \'' + filename + '\' to Bisque...' start_time = time() r = save_blob(bqsession, localfile=RASPISTILL_DIRECTORY+filename, resource=resource) elapsed_time = time() - start_time if r is None: print 'Error uploading!' preferences_fail_alert.append('Error uploading \'' + filename + '\' to Bisque!') else: print 'Image uploaded in %.2f seconds' % elapsed_time print r.items() print 'Image URI:', r.get('uri') #call(['cp raspistillweb/pictures/preview.jpg raspistillweb/pictures/'+filename],shell=True) #generate_thumbnail(filename) return