idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
41,500 | def read ( file , frames = - 1 , start = 0 , stop = None , dtype = 'float64' , always_2d = False , fill_value = None , out = None , samplerate = None , channels = None , format = None , subtype = None , endian = None , closefd = True ) : with SoundFile ( file , 'r' , samplerate , channels , subtype , endian , format , ... | Provide audio data from a sound file as NumPy array . |
41,501 | def write ( file , data , samplerate , subtype = None , endian = None , format = None , closefd = True ) : import numpy as np data = np . asarray ( data ) if data . ndim == 1 : channels = 1 else : channels = data . shape [ 1 ] with SoundFile ( file , 'w' , samplerate , channels , subtype , endian , format , closefd ) a... | Write data to a sound file . |
41,502 | def available_subtypes ( format = None ) : subtypes = _available_formats_helper ( _snd . SFC_GET_FORMAT_SUBTYPE_COUNT , _snd . SFC_GET_FORMAT_SUBTYPE ) return dict ( ( subtype , name ) for subtype , name in subtypes if format is None or check_format ( format , subtype ) ) | Return a dictionary of available subtypes . |
41,503 | def _error_check ( err , prefix = "" ) : if err != 0 : err_str = _snd . sf_error_number ( err ) raise RuntimeError ( prefix + _ffi . string ( err_str ) . decode ( 'utf-8' , 'replace' ) ) | Pretty - print a numerical error code if there is an error . |
41,504 | def _format_int ( format , subtype , endian ) : result = _check_format ( format ) if subtype is None : subtype = default_subtype ( format ) if subtype is None : raise TypeError ( "No default subtype for major format {0!r}" . format ( format ) ) elif not isinstance ( subtype , ( _unicode , str ) ) : raise TypeError ( "I... | Return numeric ID for given format|subtype|endian combo . |
41,505 | def _check_mode ( mode ) : if not isinstance ( mode , ( _unicode , str ) ) : raise TypeError ( "Invalid mode: {0!r}" . format ( mode ) ) mode_set = set ( mode ) if mode_set . difference ( 'xrwb+' ) or len ( mode ) > len ( mode_set ) : raise ValueError ( "Invalid mode: {0!r}" . format ( mode ) ) if len ( mode_set . inte... | Check if mode is valid and return its integer representation . |
41,506 | def _create_info_struct ( file , mode , samplerate , channels , format , subtype , endian ) : original_format = format if format is None : format = _get_format_from_filename ( file , mode ) assert isinstance ( format , ( _unicode , str ) ) else : _check_format ( format ) info = _ffi . new ( "SF_INFO*" ) if 'r' not in m... | Check arguments and create SF_INFO struct . |
41,507 | def _format_str ( format_int ) : for dictionary in _formats , _subtypes , _endians : for k , v in dictionary . items ( ) : if v == format_int : return k else : return 'n/a' | Return the string representation of a given numeric format . |
41,508 | def _format_info ( format_int , format_flag = _snd . SFC_GET_FORMAT_INFO ) : format_info = _ffi . new ( "SF_FORMAT_INFO*" ) format_info . format = format_int _snd . sf_command ( _ffi . NULL , format_flag , format_info , _ffi . sizeof ( "SF_FORMAT_INFO" ) ) name = format_info . name return ( _format_str ( format_info . ... | Return the ID and short description of a given format . |
41,509 | def _check_format ( format_str ) : if not isinstance ( format_str , ( _unicode , str ) ) : raise TypeError ( "Invalid format: {0!r}" . format ( format_str ) ) try : format_int = _formats [ format_str . upper ( ) ] except KeyError : raise ValueError ( "Unknown format: {0!r}" . format ( format_str ) ) return format_int | Check if format_str is valid and return format ID . |
41,510 | def _has_virtual_io_attrs ( file , mode_int ) : readonly = mode_int == _snd . SFM_READ writeonly = mode_int == _snd . SFM_WRITE return all ( [ hasattr ( file , 'seek' ) , hasattr ( file , 'tell' ) , hasattr ( file , 'write' ) or readonly , hasattr ( file , 'read' ) or hasattr ( file , 'readinto' ) or writeonly , ] ) | Check if file has all the necessary attributes for virtual IO . |
41,511 | def extra_info ( self ) : info = _ffi . new ( "char[]" , 2 ** 14 ) _snd . sf_command ( self . _file , _snd . SFC_GET_LOG_INFO , info , _ffi . sizeof ( info ) ) return _ffi . string ( info ) . decode ( 'utf-8' , 'replace' ) | Retrieve the log string generated when opening the file . |
41,512 | def read ( self , frames = - 1 , dtype = 'float64' , always_2d = False , fill_value = None , out = None ) : if out is None : frames = self . _check_frames ( frames , fill_value ) out = self . _create_empty_array ( frames , always_2d , dtype ) else : if frames < 0 or frames > len ( out ) : frames = len ( out ) frames = ... | Read from the file and return data as NumPy array . |
41,513 | def buffer_read ( self , frames = - 1 , dtype = None ) : frames = self . _check_frames ( frames , fill_value = None ) ctype = self . _check_dtype ( dtype ) cdata = _ffi . new ( ctype + '[]' , frames * self . channels ) read_frames = self . _cdata_io ( 'read' , cdata , ctype , frames ) assert read_frames == frames retur... | Read from the file and return data as buffer object . |
41,514 | def buffer_read_into ( self , buffer , dtype ) : ctype = self . _check_dtype ( dtype ) cdata , frames = self . _check_buffer ( buffer , ctype ) frames = self . _cdata_io ( 'read' , cdata , ctype , frames ) return frames | Read from the file into a given buffer object . |
41,515 | def write ( self , data ) : import numpy as np data = np . ascontiguousarray ( data ) written = self . _array_io ( 'write' , data , len ( data ) ) assert written == len ( data ) self . _update_frames ( written ) | Write audio data from a NumPy array to the file . |
41,516 | def truncate ( self , frames = None ) : if frames is None : frames = self . tell ( ) err = _snd . sf_command ( self . _file , _snd . SFC_FILE_TRUNCATE , _ffi . new ( "sf_count_t*" , frames ) , _ffi . sizeof ( "sf_count_t" ) ) if err : raise RuntimeError ( "Error truncating the file" ) self . _info . frames = frames | Truncate the file to a given number of frames . |
41,517 | def close ( self ) : if not self . closed : self . flush ( ) err = _snd . sf_close ( self . _file ) self . _file = None _error_check ( err ) | Close the file . Can be called multiple times . |
41,518 | def _check_frames ( self , frames , fill_value ) : if self . seekable ( ) : remaining_frames = self . frames - self . tell ( ) if frames < 0 or ( frames > remaining_frames and fill_value is None ) : frames = remaining_frames elif frames < 0 : raise ValueError ( "frames must be specified for non-seekable files" ) return... | Reduce frames to no more than are available in the file . |
41,519 | def _check_buffer ( self , data , ctype ) : assert ctype in _ffi_types . values ( ) if not isinstance ( data , bytes ) : data = _ffi . from_buffer ( data ) frames , remainder = divmod ( len ( data ) , self . channels * _ffi . sizeof ( ctype ) ) if remainder : raise ValueError ( "Data size must be a multiple of frame si... | Convert buffer to cdata and check for valid size . |
41,520 | def _create_empty_array ( self , frames , always_2d , dtype ) : import numpy as np if always_2d or self . channels > 1 : shape = frames , self . channels else : shape = frames , return np . empty ( shape , dtype , order = 'C' ) | Create an empty array with appropriate shape . |
41,521 | def _check_dtype ( self , dtype ) : try : return _ffi_types [ dtype ] except KeyError : raise ValueError ( "dtype must be one of {0!r} and not {1!r}" . format ( sorted ( _ffi_types . keys ( ) ) , dtype ) ) | Check if dtype string is valid and return ctype string . |
41,522 | def _array_io ( self , action , array , frames ) : if ( array . ndim not in ( 1 , 2 ) or array . ndim == 1 and self . channels != 1 or array . ndim == 2 and array . shape [ 1 ] != self . channels ) : raise ValueError ( "Invalid shape: {0!r}" . format ( array . shape ) ) if not array . flags . c_contiguous : raise Value... | Check array and call low - level IO function . |
41,523 | def _update_frames ( self , written ) : if self . seekable ( ) : curr = self . tell ( ) self . _info . frames = self . seek ( 0 , SEEK_END ) self . seek ( curr , SEEK_SET ) else : self . _info . frames += written | Update self . frames after writing . |
41,524 | def _prepare_read ( self , start , stop , frames ) : if start != 0 and not self . seekable ( ) : raise ValueError ( "start is only allowed for seekable files" ) if frames >= 0 and stop is not None : raise TypeError ( "Only one of {frames, stop} may be used" ) start , stop , _ = slice ( start , stop ) . indices ( self .... | Seek to start frame and calculate length . |
41,525 | def probes_used_generate_vector ( probe_files_full , probe_files_model ) : import numpy as np C_probesUsed = np . ndarray ( ( len ( probe_files_full ) , ) , 'bool' ) C_probesUsed . fill ( False ) c = 0 for k in sorted ( probe_files_full . keys ( ) ) : if probe_files_model . has_key ( k ) : C_probesUsed [ c ] = True c +... | Generates boolean matrices indicating which are the probes for each model |
41,526 | def probes_used_extract_scores ( full_scores , same_probes ) : if full_scores . shape [ 1 ] != same_probes . shape [ 0 ] : raise "Size mismatch" import numpy as np model_scores = np . ndarray ( ( full_scores . shape [ 0 ] , np . sum ( same_probes ) ) , 'float64' ) c = 0 for i in range ( 0 , full_scores . shape [ 1 ] ) ... | Extracts a matrix of scores for a model given a probes_used row vector of boolean |
41,527 | def read ( filename ) : import scipy . io . wavfile rate , audio = scipy . io . wavfile . read ( filename ) data = numpy . cast [ 'float' ] ( audio ) return rate , data | Read audio file |
41,528 | def normalize_std_array ( vector ) : length = 1 n_samples = len ( vector ) mean = numpy . ndarray ( ( length , ) , 'float64' ) std = numpy . ndarray ( ( length , ) , 'float64' ) mean . fill ( 0 ) std . fill ( 0 ) for array in vector : x = array . astype ( 'float64' ) mean += x std += ( x ** 2 ) mean /= n_samples std /=... | Applies a unit mean and variance normalization to an arrayset |
41,529 | def _conversion ( self , input_signal , vad_file ) : e = bob . ap . Energy ( rate_wavsample [ 0 ] , self . win_length_ms , self . win_shift_ms ) energy_array = e ( rate_wavsample [ 1 ] ) labels = self . use_existing_vad ( energy_array , vad_file ) return labels | Converts an external VAD to follow the Spear convention . Energy is used in order to avoind out - of - bound array indexes . |
41,530 | def mod_4hz ( self , rate_wavsample ) : wl = self . win_length_ms ws = self . win_shift_ms nf = self . n_filters f_min = self . f_min f_max = self . f_max pre = self . pre_emphasis_coef c = bob . ap . Spectrogram ( rate_wavsample [ 0 ] , wl , ws , nf , f_min , f_max , pre ) c . energy_filter = True c . log_filter = Fal... | Computes and returns the 4Hz modulation energy features for the given input wave file |
41,531 | def read_matlab_files ( self , biofile , directory , extension ) : import bob . io . matlab data_path = biofile . make_path ( directory , extension ) return bob . io . base . load ( data_path ) | Read pre - computed CQCC Matlab features here |
41,532 | def command_line_arguments ( command_line_parameters ) : parser = argparse . ArgumentParser ( description = 'Execute baseline algorithms with default parameters' , formatter_class = argparse . ArgumentDefaultsHelpFormatter ) parser . add_argument ( '-a' , '--algorithms' , choices = all_algorithms , default = ( 'gmm-vox... | Defines the command line parameters that are accepted . |
41,533 | def calc_mean ( c0 , c1 = [ ] ) : if c1 != [ ] : return ( numpy . mean ( c0 , 0 ) + numpy . mean ( c1 , 0 ) ) / 2. else : return numpy . mean ( c0 , 0 ) | Calculates the mean of the data . |
41,534 | def calc_std ( c0 , c1 = [ ] ) : if c1 == [ ] : return numpy . std ( c0 , 0 ) prop = float ( len ( c0 ) ) / float ( len ( c1 ) ) if prop < 1 : p0 = int ( math . ceil ( 1 / prop ) ) p1 = 1 else : p0 = 1 p1 = int ( math . ceil ( prop ) ) return numpy . std ( numpy . vstack ( p0 * [ c0 ] + p1 * [ c1 ] ) , 0 ) | Calculates the variance of the data . |
41,535 | def calc_mean_std ( c0 , c1 = [ ] , nonStdZero = False ) : mi = calc_mean ( c0 , c1 ) std = calc_std ( c0 , c1 ) if ( nonStdZero ) : std [ std == 0 ] = 1 return mi , std | Calculates both the mean of the data . |
41,536 | def solve_sweep_structure ( self , structures , sweep_param_list , filename = "structure_n_effs.dat" , plot = True , x_label = "Structure number" , fraction_mode_list = [ ] , ) : n_effs = [ ] mode_types = [ ] fractions_te = [ ] fractions_tm = [ ] for s in tqdm . tqdm ( structures , ncols = 70 ) : self . solve ( s ) n_e... | Find the modes of many structures . |
41,537 | def solve_sweep_wavelength ( self , structure , wavelengths , filename = "wavelength_n_effs.dat" , plot = True , ) : n_effs = [ ] for w in tqdm . tqdm ( wavelengths , ncols = 70 ) : structure . change_wavelength ( w ) self . solve ( structure ) n_effs . append ( np . real ( self . n_effs ) ) if filename : self . _write... | Solve for the effective indices of a fixed structure at different wavelengths . |
41,538 | def _add_material ( self , x_bot_left , y_bot_left , x_top_right , y_top_right , n_material , angle = 0 ) : x_mask = np . logical_and ( x_bot_left <= self . x , self . x <= x_top_right ) y_mask = np . logical_and ( y_bot_left <= self . y , self . y <= y_top_right ) xy_mask = np . kron ( y_mask , x_mask ) . reshape ( ( ... | A low - level function that allows writing a rectangle refractive index profile to a Structure . |
41,539 | def add_material ( self , x_min , x_max , n , angle = 0 ) : self . _mat_params . append ( [ x_min , x_max , n , angle ] ) if not callable ( n ) : n_mat = lambda wl : n else : n_mat = n Structure . _add_material ( self , x_min , self . y_min , x_max , self . y_max , n_mat ( self . _wl ) , angle ) return self . n | Add a refractive index between two x - points . |
41,540 | def trapz2 ( f , x = None , y = None , dx = 1.0 , dy = 1.0 ) : return numpy . trapz ( numpy . trapz ( f , x = y , dx = dy ) , x = x , dx = dx ) | Double integrate . |
41,541 | def solve ( self , neigs = 4 , tol = 0 , guess = None , mode_profiles = True , initial_mode_guess = None ) : from scipy . sparse . linalg import eigen self . nmodes = neigs self . tol = tol A = self . build_matrix ( ) if guess is not None : k = 2 * numpy . pi / self . wl shift = ( guess * k ) ** 2 else : shift = None [... | This function finds the eigenmodes . |
41,542 | def grating_coupler_period ( wavelength , n_eff , n_clad , incidence_angle_deg , diffration_order = 1 ) : k0 = 2. * np . pi / wavelength beta = n_eff . real * k0 n_inc = n_clad grating_period = ( 2. * np . pi * diffration_order ) / ( beta - k0 * n_inc * np . sin ( np . radians ( incidence_angle_deg ) ) ) return grating... | Calculate the period needed for a grating coupler . |
41,543 | def oop ( aa ) : return ( '%s %s %s %.2f %+.2f %s %s %s %s %+.2f %s %s %.2f %.4f %.4f' % ( aa . stock_no , aa . stock_name , aa . data_date [ - 1 ] , aa . raw_data [ - 1 ] , aa . range_per , aa . MAC ( 3 ) , aa . MAC ( 6 ) , aa . MAC ( 18 ) , aa . MAO ( 3 , 6 ) [ 1 ] , aa . MAO ( 3 , 6 ) [ 0 ] [ 1 ] [ - 1 ] , aa . MAO ... | For cmd output . |
41,544 | def reflection ( n1 , n2 ) : r = abs ( ( n1 - n2 ) / ( n1 + n2 ) ) ** 2 return r | Calculate the power reflection at the interface of two refractive index materials . |
41,545 | def coupling_efficiency ( mode_solver , fibre_mfd , fibre_offset_x = 0 , fibre_offset_y = 0 , n_eff_fibre = 1.441 ) : etas = [ ] gaus = _make_gaussian ( mode_solver . _structure . xc , mode_solver . _structure . yc , fibre_mfd , fibre_offset_x , fibre_offset_y ) for mode , n_eff in zip ( mode_solver . modes , mode_solv... | Finds the coupling efficiency between a solved fundamental mode and a fibre of given MFD . |
41,546 | def getIndex ( reference ) : if reference : reffas = reference else : parent_directory = path . dirname ( path . abspath ( path . dirname ( __file__ ) ) ) reffas = path . join ( parent_directory , "reference/DNA_CS.fasta" ) if not path . isfile ( reffas ) : logging . error ( "Could not find reference fasta for lambda g... | Find the reference folder using the location of the script file Create the index test if successful |
41,547 | def _exec_ipmitool ( driver_info , command ) : ipmi_cmd = ( "ipmitool -H %(address)s" " -I lanplus -U %(user)s -P %(passwd)s %(cmd)s" % { 'address' : driver_info [ 'address' ] , 'user' : driver_info [ 'username' ] , 'passwd' : driver_info [ 'password' ] , 'cmd' : command } ) out = None try : out = subprocess . check_ou... | Execute the ipmitool command . |
41,548 | def get_nic_capacity ( driver_info , ilo_fw ) : i = 0x0 value = None ilo_fw_rev = get_ilo_version ( ilo_fw ) or DEFAULT_FW_REV if ilo_fw_rev < MIN_SUGGESTED_FW_REV : for i in range ( 0xff ) : if ( i < 0x6e ) or ( i > 0xee ) : cmd = "fru print %s" % hex ( i ) out = _exec_ipmitool ( driver_info , cmd ) if out and 'port' ... | Gets the FRU data to see if it is NIC data |
41,549 | def _parse_ipmi_nic_capacity ( nic_out ) : if ( ( "Device not present" in nic_out ) or ( "Unknown FRU header" in nic_out ) or not nic_out ) : return None capacity = None product_name = None data = nic_out . split ( '\n' ) for item in data : fields = item . split ( ':' ) if len ( fields ) > 1 : first_field = fields [ 0 ... | Parse the FRU output for NIC capacity |
41,550 | def _extract_encryption_metadata ( entity , require_encryption , key_encryption_key , key_resolver ) : _validate_not_none ( 'entity' , entity ) try : encrypted_properties_list = _decode_base64_to_bytes ( entity [ '_ClientEncryptionMetadata2' ] ) encryption_data = entity [ '_ClientEncryptionMetadata1' ] encryption_data ... | Extracts the encryption metadata from the given entity setting them to be utf - 8 strings . If no encryption metadata is present will return None for all return values unless require_encryption is true in which case the method will throw . |
41,551 | def logical_drives ( self ) : return logical_drive . HPELogicalDriveCollection ( self . _conn , utils . get_subresource_path_by ( self , [ 'Links' , 'LogicalDrives' ] ) , redfish_version = self . redfish_version ) | Gets the resource HPELogicalDriveCollection of ArrayControllers |
41,552 | def physical_drives ( self ) : return physical_drive . HPEPhysicalDriveCollection ( self . _conn , utils . get_subresource_path_by ( self , [ 'Links' , 'PhysicalDrives' ] ) , redfish_version = self . redfish_version ) | Gets the resource HPEPhysicalDriveCollection of ArrayControllers |
41,553 | def physical_drives_maximum_size_mib ( self ) : return utils . max_safe ( [ member . physical_drives . maximum_size_mib for member in self . get_members ( ) ] ) | Gets the biggest disk |
41,554 | def array_controller_by_location ( self , location ) : for member in self . get_members ( ) : if member . location == location : return member | Returns array controller instance by location |
41,555 | def array_controller_by_model ( self , model ) : for member in self . get_members ( ) : if member . model == model : return member | Returns array controller instance by model |
41,556 | def get_subresource_path_by ( resource , subresource_path ) : if isinstance ( subresource_path , six . string_types ) : subresource_path = [ subresource_path ] elif not subresource_path : raise ValueError ( '"subresource_path" cannot be empty' ) body = resource . json for path_item in subresource_path : body = body . g... | Helper function to find the resource path |
41,557 | def get_supported_boot_mode ( supported_boot_mode ) : boot_mode_bios = 'false' boot_mode_uefi = 'false' if ( supported_boot_mode == sys_cons . SUPPORTED_LEGACY_BIOS_ONLY ) : boot_mode_bios = 'true' elif ( supported_boot_mode == sys_cons . SUPPORTED_UEFI_ONLY ) : boot_mode_uefi = 'true' elif ( supported_boot_mode == sys... | Return bios and uefi support . |
41,558 | def get_allowed_operations ( resource , subresouce_path ) : uri = get_subresource_path_by ( resource , subresouce_path ) response = resource . _conn . get ( path = uri ) return response . headers [ 'Allow' ] | Helper function to get the HTTP allowed methods . |
41,559 | def _op ( self , method , path = '' , data = None , headers = None ) : resp = super ( HPEConnector , self ) . _op ( method , path , data , headers , allow_redirects = False ) if resp . status_code == 308 : path = urlparse ( resp . headers [ 'Location' ] ) . path resp = super ( HPEConnector , self ) . _op ( method , pat... | Overrides the base method to support retrying the operation . |
41,560 | def generate_file_shared_access_signature ( self , share_name , directory_name = None , file_name = None , permission = None , expiry = None , start = None , id = None , ip = None , protocol = None , cache_control = None , content_disposition = None , content_encoding = None , content_language = None , content_type = N... | Generates a shared access signature for the file . Use the returned signature with the sas_token parameter of FileService . |
41,561 | def get_share_properties ( self , share_name , timeout = None ) : _validate_not_none ( 'share_name' , share_name ) request = HTTPRequest ( ) request . method = 'GET' request . host = self . _get_host ( ) request . path = _get_path ( share_name ) request . query = [ ( 'restype' , 'share' ) , ( 'timeout' , _int_to_str ( ... | Returns all user - defined metadata and system properties for the specified share . The data returned does not include the shares s list of files or directories . |
41,562 | def get_share_metadata ( self , share_name , timeout = None ) : _validate_not_none ( 'share_name' , share_name ) request = HTTPRequest ( ) request . method = 'GET' request . host = self . _get_host ( ) request . path = _get_path ( share_name ) request . query = [ ( 'restype' , 'share' ) , ( 'comp' , 'metadata' ) , ( 't... | Returns all user - defined metadata for the specified share . |
41,563 | def set_file_properties ( self , share_name , directory_name , file_name , content_settings , timeout = None ) : _validate_not_none ( 'share_name' , share_name ) _validate_not_none ( 'file_name' , file_name ) _validate_not_none ( 'content_settings' , content_settings ) request = HTTPRequest ( ) request . method = 'PUT'... | Sets system properties on the file . If one property is set for the content_settings all properties will be overriden . |
41,564 | def copy_file ( self , share_name , directory_name , file_name , copy_source , metadata = None , timeout = None ) : _validate_not_none ( 'share_name' , share_name ) _validate_not_none ( 'file_name' , file_name ) _validate_not_none ( 'copy_source' , copy_source ) request = HTTPRequest ( ) request . method = 'PUT' reques... | Copies a blob or file to a destination file within the storage account . |
41,565 | def create_file_from_bytes ( self , share_name , directory_name , file_name , file , index = 0 , count = None , content_settings = None , metadata = None , progress_callback = None , max_connections = 1 , max_retries = 5 , retry_wait = 1.0 , timeout = None ) : _validate_not_none ( 'share_name' , share_name ) _validate_... | Creates a new file from an array of bytes or updates the content of an existing file with automatic chunking and progress notifications . |
41,566 | def list_ranges ( self , share_name , directory_name , file_name , start_range = None , end_range = None , timeout = None ) : _validate_not_none ( 'share_name' , share_name ) _validate_not_none ( 'file_name' , file_name ) request = HTTPRequest ( ) request . method = 'GET' request . host = self . _get_host ( ) request .... | Retrieves the valid ranges for a file . |
41,567 | def _get_sushy_system ( self , system_id ) : system_url = parse . urljoin ( self . _sushy . get_system_collection_path ( ) , system_id ) try : return self . _sushy . get_system ( system_url ) except sushy . exceptions . SushyError as e : msg = ( self . _ ( 'The Redfish System "%(system)s" was not found. ' 'Error %(erro... | Get the sushy system for system_id |
41,568 | def _get_sushy_manager ( self , manager_id ) : manager_url = parse . urljoin ( self . _sushy . get_manager_collection_path ( ) , manager_id ) try : return self . _sushy . get_manager ( manager_url ) except sushy . exceptions . SushyError as e : msg = ( self . _ ( 'The Redfish Manager "%(manager)s" was not found. ' 'Err... | Get the sushy Manager for manager_id |
41,569 | def get_host_power_status ( self ) : sushy_system = self . _get_sushy_system ( PROLIANT_SYSTEM_ID ) return GET_POWER_STATE_MAP . get ( sushy_system . power_state ) | Request the power state of the server . |
41,570 | def reset_server ( self ) : sushy_system = self . _get_sushy_system ( PROLIANT_SYSTEM_ID ) try : sushy_system . reset_system ( sushy . RESET_FORCE_RESTART ) except sushy . exceptions . SushyError as e : msg = ( self . _ ( 'The Redfish controller failed to reset server. ' 'Error %(error)s' ) % { 'error' : str ( e ) } ) ... | Resets the server . |
41,571 | def set_host_power ( self , target_value ) : if target_value not in POWER_RESET_MAP : msg = ( 'The parameter "%(parameter)s" value "%(target_value)s" is ' 'invalid. Valid values are: %(valid_power_values)s' % { 'parameter' : 'target_value' , 'target_value' : target_value , 'valid_power_values' : POWER_RESET_MAP . keys ... | Sets the power state of the system . |
41,572 | def _validate_virtual_media ( self , device ) : if device not in VIRTUAL_MEDIA_MAP : msg = ( self . _ ( "Invalid device '%s'. Valid devices: FLOPPY or " "CDROM." ) % device ) LOG . debug ( msg ) raise exception . IloInvalidInputError ( msg ) | Check if the device is valid device . |
41,573 | def _is_boot_mode_uefi ( self ) : boot_mode = self . get_current_boot_mode ( ) return ( boot_mode == BOOT_MODE_MAP . get ( sys_cons . BIOS_BOOT_MODE_UEFI ) ) | Checks if the system is in uefi boot mode . |
41,574 | def get_supported_boot_mode ( self ) : sushy_system = self . _get_sushy_system ( PROLIANT_SYSTEM_ID ) try : return SUPPORTED_BOOT_MODE_MAP . get ( sushy_system . supported_boot_mode ) except sushy . exceptions . SushyError as e : msg = ( self . _ ( 'The Redfish controller failed to get the ' 'supported boot modes. Erro... | Get the system supported boot modes . |
41,575 | def get_server_capabilities ( self ) : capabilities = { } sushy_system = self . _get_sushy_system ( PROLIANT_SYSTEM_ID ) sushy_manager = self . _get_sushy_manager ( PROLIANT_MANAGER_ID ) try : count = len ( sushy_system . pci_devices . gpu_devices ) boot_mode = rf_utils . get_supported_boot_mode ( sushy_system . suppor... | Returns the server capabilities |
41,576 | def get_essential_properties ( self ) : sushy_system = self . _get_sushy_system ( PROLIANT_SYSTEM_ID ) try : prop = { 'memory_mb' : ( sushy_system . memory_summary . size_gib * 1024 ) , 'cpus' : sushy_system . processors . summary . count , 'cpu_arch' : sushy_map . PROCESSOR_ARCH_VALUE_MAP_REV . get ( sushy_system . pr... | Constructs the dictionary of essential properties |
41,577 | def _change_iscsi_target_settings ( self , iscsi_info ) : sushy_system = self . _get_sushy_system ( PROLIANT_SYSTEM_ID ) try : pci_settings_map = ( sushy_system . bios_settings . bios_mappings . pci_settings_mappings ) nics = [ ] for mapping in pci_settings_map : for subinstance in mapping [ 'Subinstances' ] : for asso... | Change iSCSI target settings . |
41,578 | def set_iscsi_info ( self , target_name , lun , ip_address , port = '3260' , auth_method = None , username = None , password = None ) : if ( self . _is_boot_mode_uefi ( ) ) : iscsi_info = { } iscsi_info [ 'iSCSITargetName' ] = target_name iscsi_info [ 'iSCSILUN' ] = lun iscsi_info [ 'iSCSITargetIpAddress' ] = ip_addres... | Set iSCSI details of the system in UEFI boot mode . |
41,579 | def get_host_post_state ( self ) : sushy_system = self . _get_sushy_system ( PROLIANT_SYSTEM_ID ) return GET_POST_STATE_MAP . get ( sushy_system . post_state ) | Get the current state of system POST . |
41,580 | def _get_collection ( self , collection_uri , request_headers = None ) : status , headers , thecollection = self . _rest_get ( collection_uri ) if status != 200 : msg = self . _get_extended_error ( thecollection ) raise exception . IloError ( msg ) while status < 300 : ctype = self . _get_type ( thecollection ) if ( ct... | Generator function that returns collection members . |
41,581 | def _get_type ( self , obj ) : typever = obj [ 'Type' ] typesplit = typever . split ( '.' ) return typesplit [ 0 ] + '.' + typesplit [ 1 ] | Return the type of an object . |
41,582 | def _render_extended_error_message_list ( self , extended_error ) : messages = [ ] if isinstance ( extended_error , dict ) : if ( 'Type' in extended_error and extended_error [ 'Type' ] . startswith ( 'ExtendedError.' ) ) : for msg in extended_error [ 'Messages' ] : message_id = msg [ 'MessageID' ] x = message_id . spli... | Parse the ExtendedError object and retruns the message . |
41,583 | def _get_host_details ( self ) : status , headers , system = self . _rest_get ( '/rest/v1/Systems/1' ) if status < 300 : stype = self . _get_type ( system ) if stype not in [ 'ComputerSystem.0' , 'ComputerSystem.1' ] : msg = "%s is not a valid system type " % stype raise exception . IloError ( msg ) else : msg = self .... | Get the system details . |
41,584 | def _check_bios_resource ( self , properties = [ ] ) : system = self . _get_host_details ( ) if ( 'links' in system [ 'Oem' ] [ 'Hp' ] and 'BIOS' in system [ 'Oem' ] [ 'Hp' ] [ 'links' ] ) : bios_uri = system [ 'Oem' ] [ 'Hp' ] [ 'links' ] [ 'BIOS' ] [ 'href' ] status , headers , bios_settings = self . _rest_get ( bios... | Check if the bios resource exists . |
41,585 | def _get_pci_devices ( self ) : system = self . _get_host_details ( ) if ( 'links' in system [ 'Oem' ] [ 'Hp' ] and 'PCIDevices' in system [ 'Oem' ] [ 'Hp' ] [ 'links' ] ) : pci_uri = system [ 'Oem' ] [ 'Hp' ] [ 'links' ] [ 'PCIDevices' ] [ 'href' ] status , headers , pci_device_list = self . _rest_get ( pci_uri ) if s... | Gets the PCI devices . |
41,586 | def _get_gpu_pci_devices ( self ) : pci_device_list = self . _get_pci_devices ( ) gpu_list = [ ] items = pci_device_list [ 'Items' ] for item in items : if item [ 'ClassCode' ] in CLASSCODE_FOR_GPU_DEVICES : if item [ 'SubclassCode' ] in SUBCLASSCODE_FOR_GPU_DEVICES : gpu_list . append ( item ) return gpu_list | Returns the list of gpu devices . |
41,587 | def _get_storage_resource ( self ) : system = self . _get_host_details ( ) if ( 'links' in system [ 'Oem' ] [ 'Hp' ] and 'SmartStorage' in system [ 'Oem' ] [ 'Hp' ] [ 'links' ] ) : storage_uri = system [ 'Oem' ] [ 'Hp' ] [ 'links' ] [ 'SmartStorage' ] [ 'href' ] status , headers , storage_settings = self . _rest_get ( ... | Gets the SmartStorage resource if exists . |
41,588 | def _get_array_controller_resource ( self ) : headers , storage_uri , storage_settings = self . _get_storage_resource ( ) if ( 'links' in storage_settings and 'ArrayControllers' in storage_settings [ 'links' ] ) : array_uri = storage_settings [ 'links' ] [ 'ArrayControllers' ] [ 'href' ] status , headers , array_settin... | Gets the ArrayController resource if exists . |
41,589 | def _create_list_of_array_controllers ( self ) : headers , array_uri , array_settings = ( self . _get_array_controller_resource ( ) ) array_uri_links = [ ] if ( 'links' in array_settings and 'Member' in array_settings [ 'links' ] ) : array_uri_links = array_settings [ 'links' ] [ 'Member' ] else : msg = ( '"links/Membe... | Creates the list of Array Controller URIs . |
41,590 | def _get_drive_type_and_speed ( self ) : disk_details = self . _get_physical_drive_resource ( ) drive_hdd = False drive_ssd = False drive_details = { } speed_const_list = [ 4800 , 5400 , 7200 , 10000 , 15000 ] if disk_details : for item in disk_details : value = item [ 'MediaType' ] if value == "HDD" : drive_hdd = True... | Gets the disk drive type . |
41,591 | def _get_drive_resource ( self , drive_name ) : disk_details_list = [ ] array_uri_links = self . _create_list_of_array_controllers ( ) for array_link in array_uri_links : _ , _ , member_settings = ( self . _rest_get ( array_link [ 'href' ] ) ) if ( 'links' in member_settings and drive_name in member_settings [ 'links' ... | Gets the DiskDrive resource if exists . |
41,592 | def _get_logical_raid_levels ( self ) : logical_drive_details = self . _get_logical_drive_resource ( ) raid_level = { } if logical_drive_details : for item in logical_drive_details : if 'Raid' in item : raid_level_var = "logical_raid_level_" + item [ 'Raid' ] raid_level . update ( { raid_level_var : 'true' } ) return r... | Gets the different raid levels configured on a server . |
41,593 | def _is_raid_supported ( self ) : header , uri , array_resource = self . _get_array_controller_resource ( ) return True if array_resource [ 'Total' ] > 0 else False | Get the RAID support on the server . |
41,594 | def _get_bios_settings_resource ( self , data ) : try : bios_settings_uri = data [ 'links' ] [ 'Settings' ] [ 'href' ] except KeyError : msg = ( 'BIOS Settings resource not found.' ) raise exception . IloError ( msg ) status , headers , bios_settings = self . _rest_get ( bios_settings_uri ) if status != 200 : msg = sel... | Get the BIOS settings resource . |
41,595 | def _validate_if_patch_supported ( self , headers , uri ) : if not self . _operation_allowed ( headers , 'PATCH' ) : msg = ( 'PATCH Operation not supported on the resource ' '"%s"' % uri ) raise exception . IloError ( msg ) | Check if the PATCH Operation is allowed on the resource . |
41,596 | def _get_bios_setting ( self , bios_property ) : headers , bios_uri , bios_settings = self . _check_bios_resource ( [ bios_property ] ) return bios_settings [ bios_property ] | Retrieves bios settings of the server . |
41,597 | def _get_bios_hash_password ( self , bios_password ) : request_headers = { } if bios_password : bios_password_hash = hashlib . sha256 ( ( bios_password . encode ( ) ) . hexdigest ( ) . upper ( ) ) request_headers [ 'X-HPRESTFULAPI-AuthToken' ] = bios_password_hash return request_headers | Get the hashed BIOS password . |
41,598 | def _change_bios_setting ( self , properties ) : keys = properties . keys ( ) headers , bios_uri , settings = self . _check_bios_resource ( keys ) if not self . _operation_allowed ( headers , 'PATCH' ) : headers , bios_uri , _ = self . _get_bios_settings_resource ( settings ) self . _validate_if_patch_supported ( heade... | Change the bios settings to specified values . |
41,599 | def _get_iscsi_settings_resource ( self , data ) : try : iscsi_settings_uri = data [ 'links' ] [ 'Settings' ] [ 'href' ] except KeyError : msg = ( 'iscsi settings resource not found.' ) raise exception . IloCommandNotSupportedError ( msg ) status , headers , iscsi_settings = self . _rest_get ( iscsi_settings_uri ) if s... | Get the iscsi settings resoure . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.