def update_status( self, status, dataset_id='All', msg='' ): ''' Update the data transfer status for this dataset in the database ''' try: log.debug( 'Setting status "%s" for dataset "%s" of sample "%s"' % ( status, str( dataset_id ), str( self.sample_id) ) ) sample_dataset_ids = [] if dataset_id == 'All': for dataset in self.dataset_files: sample_dataset_ids.append( api.encode_id( self.config_id_secret, dataset[ 'dataset_id' ] ) ) else: sample_dataset_ids.append( api.encode_id( self.config_id_secret, dataset_id ) ) # update the transfer status data = {} data[ 'update_type' ] = SamplesAPIController.update_types.SAMPLE_DATASET[0] data[ 'sample_dataset_ids' ] = sample_dataset_ids data[ 'new_status' ] = status data[ 'error_msg' ] = msg url = "http://%s/api/samples/%s" % ( self.galaxy_host, api.encode_id( self.config_id_secret, self.sample_id ) ) log.debug( str( ( self.api_key, url, data))) retval = api.update( self.api_key, url, data, return_formatted=False ) log.debug( str( retval ) ) except urllib2.URLError, e: log.debug( 'ERROR( sample_dataset_transfer_status ( %s ) ): %s' % ( url, str( e ) ) ) log.error( traceback.format_exc() )
def add_to_library(self): ''' This method adds the dataset file to the target data library & folder by opening the corresponding url in Galaxy server running. ''' self.update_status(SampleDataset.transfer_status.ADD_TO_LIBRARY) try: data = {} data['folder_id'] = 'F%s' % api.encode_id(self.config_id_secret, self.folder_id) data['file_type'] = 'auto' data['server_dir'] = self.server_dir data['dbkey'] = '' data['upload_option'] = 'upload_directory' data['create_type'] = 'file' url = "http://%s/api/libraries/%s/contents" % ( self.galaxy_host, api.encode_id(self.config_id_secret, self.library_id)) log.debug(str((self.api_key, url, data))) retval = api.submit(self.api_key, url, data, return_formatted=False) log.debug(str(retval)) except Exception, e: self.error_and_exit(str(e))
def add_to_library( self ): ''' This method adds the dataset file to the target data library & folder by opening the corresponding url in Galaxy server running. ''' self.update_status( SampleDataset.transfer_status.ADD_TO_LIBRARY ) try: data = {} data[ 'folder_id' ] = 'F%s' % api.encode_id( self.config_id_secret, self.folder_id ) data[ 'file_type' ] = 'auto' data[ 'server_dir' ] = self.server_dir data[ 'dbkey' ] = '' data[ 'upload_option' ] = 'upload_directory' data[ 'create_type' ] = 'file' url = "http://%s/api/libraries/%s/contents" % ( self.galaxy_host, api.encode_id( self.config_id_secret, self.library_id ) ) log.debug( str( ( self.api_key, url, data ) ) ) retval = api.submit( self.api_key, url, data, return_formatted=False ) log.debug( str( retval ) ) except Exception, e: self.error_and_exit( str( e ) )
def update_request( api_key, request_id ): encoded_request_id = api.encode_id( config.get( "app:main", "id_secret" ), request_id ) data = dict( update_type=RequestsAPIController.update_types.REQUEST ) url = "http://%s:%s/api/requests/%s" % ( config.get(http_server_section, "host"), config.get(http_server_section, "port"), encoded_request_id ) log.debug( 'Updating request %i' % request_id ) try: retval = api.update( api_key, url, data, return_formatted=False ) log.debug( str( retval ) ) except Exception, e: log.debug( 'ERROR(update_request (%s)): %s' % ( str((self.api_key, url, data)), str(e) ) )
def update_status(self, status, dataset_id='All', msg=''): ''' Update the data transfer status for this dataset in the database ''' try: log.debug('Setting status "%s" for dataset "%s" of sample "%s"' % (status, str(dataset_id), str(self.sample_id))) sample_dataset_ids = [] if dataset_id == 'All': for dataset in self.dataset_files: sample_dataset_ids.append( api.encode_id(self.config_id_secret, dataset['dataset_id'])) else: sample_dataset_ids.append( api.encode_id(self.config_id_secret, dataset_id)) # update the transfer status data = {} data[ 'update_type'] = SamplesAPIController.update_types.SAMPLE_DATASET[ 0] data['sample_dataset_ids'] = sample_dataset_ids data['new_status'] = status data['error_msg'] = msg url = "http://%s/api/samples/%s" % ( self.galaxy_host, api.encode_id(self.config_id_secret, self.sample_id)) log.debug(str((self.api_key, url, data))) retval = api.update(self.api_key, url, data, return_formatted=False) log.debug(str(retval)) except urllib2.URLError, e: log.debug('ERROR( sample_dataset_transfer_status ( %s ) ): %s' % (url, str(e))) log.error(traceback.format_exc())