idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
28,300 | def parse_iparamvalue ( self , tup_tree ) : self . check_node ( tup_tree , 'IPARAMVALUE' , ( 'NAME' , ) ) child = self . optional_child ( tup_tree , ( 'VALUE' , 'VALUE.ARRAY' , 'VALUE.REFERENCE' , 'INSTANCENAME' , 'CLASSNAME' , 'QUALIFIER.DECLARATION' , 'CLASS' , 'INSTANCE' , 'VALUE.NAMEDINSTANCE' ) ) _name = attrs ( t... | Parse expected IPARAMVALUE element . I . e . |
28,301 | def parse_embeddedObject ( self , val ) : if type ( val ) == list : return [ self . parse_embeddedObject ( obj ) for obj in val ] if val is None : return None tup_tree = xml_to_tupletree_sax ( val , "embedded object" , self . conn_id ) if name ( tup_tree ) == 'INSTANCE' : return self . parse_instance ( tup_tree ) if na... | Parse and embedded instance or class and return the CIMInstance or CIMClass . |
28,302 | def unpack_value ( self , tup_tree ) : valtype = attrs ( tup_tree ) [ 'TYPE' ] raw_val = self . list_of_matching ( tup_tree , ( 'VALUE' , 'VALUE.ARRAY' ) ) if not raw_val : return None if len ( raw_val ) > 1 : raise CIMXMLParseError ( _format ( "Element {0!A} has too many child elements {1!A} " "(allowed is one of 'VAL... | Find VALUE or VALUE . ARRAY under tup_tree and convert to a Python value . |
28,303 | def unpack_boolean ( self , data ) : if data is None : return None data_ = data . strip ( ) . lower ( ) if data_ == 'true' : return True if data_ == 'false' : return False if data_ == '' : warnings . warn ( "WBEM server sent invalid empty boolean value in a " "CIM-XML response." , ToleratedServerIssueWarning , stacklev... | Unpack a string value of CIM type boolean and return its CIM data type object or None . |
28,304 | def unpack_numeric ( self , data , cimtype ) : if data is None : return None data = data . strip ( ) if CIMXML_HEX_PATTERN . match ( data ) : value = int ( data , 16 ) else : try : value = int ( data ) except ValueError : try : value = float ( data ) except ValueError : raise CIMXMLParseError ( _format ( "Invalid numer... | Unpack a string value of a numeric CIM type and return its CIM data type object or None . |
28,305 | def unpack_datetime ( self , data ) : if data is None : return None try : value = CIMDateTime ( data ) except ValueError as exc : raise CIMXMLParseError ( _format ( "Invalid datetime value: {0!A} ({1})" , data , exc ) , conn_id = self . conn_id ) return value | Unpack a CIM - XML string value of CIM type datetime and return it as a CIMDateTime object or None . |
28,306 | def unpack_char16 ( self , data ) : if data is None : return None len_data = len ( data ) if len_data == 0 : raise CIMXMLParseError ( "Char16 value is empty" , conn_id = self . conn_id ) if len_data > 1 : raise CIMXMLParseError ( _format ( "Char16 value has more than one UCS-2 " "character: {0!A}" , data ) , conn_id = ... | Unpack a CIM - XML string value of CIM type char16 and return it as a unicode string object or None . |
28,307 | def execute_request ( server_url , creds , namespace , classname ) : print ( 'Requesting url=%s, ns=%s, class=%s' % ( server_url , namespace , classname ) ) try : CONN = WBEMConnection ( server_url , creds , default_namespace = namespace , no_verification = True ) INSTANCES = CONN . EnumerateInstances ( classname ) pri... | Open a connection with the server_url and creds and enumerate instances defined by the functions namespace and classname arguments . Displays either the error return or the mof for instances returned . |
28,308 | def get_keys_from_class ( cc ) : return [ prop . name for prop in cc . properties . values ( ) if 'key' in prop . qualifiers ] | Return list of the key property names for a class |
28,309 | def build_instance_name ( inst , obj = None ) : if obj is None : for _ in inst . properties . values ( ) : inst . path . keybindings . __setitem__ ( _ . name , _ . value ) return inst . path if not isinstance ( obj , list ) : return build_instance_name ( inst , get_keys_from_class ( obj ) ) keys = { } for _ in obj : if... | Return an instance name from an instance and set instance . path |
28,310 | def set_instance ( self , env , instance , previous_instance , cim_class ) : raise pywbem . CIMError ( pywbem . CIM_ERR_NOT_SUPPORTED , "" ) | Return a newly created or modified instance . |
28,311 | def references ( self , env , object_name , model , assoc_class , result_class_name , role , result_role , keys_only ) : pass | Instrument Associations . |
28,312 | def MI_deleteInstance ( self , env , instanceName ) : logger = env . get_logger ( ) logger . log_debug ( 'CIMProvider MI_deleteInstance called...' ) self . delete_instance ( env = env , instance_name = instanceName ) logger . log_debug ( 'CIMProvider MI_deleteInstance returning' ) | Delete a CIM instance |
28,313 | def cimtype ( obj ) : if isinstance ( obj , CIMType ) : return obj . cimtype if isinstance ( obj , bool ) : return 'boolean' if isinstance ( obj , ( six . binary_type , six . text_type ) ) : return 'string' if isinstance ( obj , list ) : try : obj = obj [ 0 ] except IndexError : raise ValueError ( "Cannot determine CIM... | Return the CIM data type name of a CIM typed object as a string . |
28,314 | def type_from_name ( type_name ) : if type_name == 'reference' : from . cim_obj import CIMInstanceName return CIMInstanceName try : type_obj = _TYPE_FROM_NAME [ type_name ] except KeyError : raise ValueError ( _format ( "Unknown CIM data type name: {0!A}" , type_name ) ) return type_obj | Return the Python type object for a given CIM data type name . |
28,315 | def atomic_to_cim_xml ( obj ) : if obj is None : return obj elif isinstance ( obj , six . text_type ) : return obj elif isinstance ( obj , six . binary_type ) : return _to_unicode ( obj ) elif isinstance ( obj , bool ) : return u'TRUE' if obj else u'FALSE' elif isinstance ( obj , ( CIMInt , six . integer_types , CIMDat... | Convert an atomic scalar value to a CIM - XML string and return that string . |
28,316 | def __ordering_deprecated ( self ) : msg = _format ( "Ordering comparisons involving {0} objects are " "deprecated." , self . __class__ . __name__ ) if DEBUG_WARNING_ORIGIN : msg += "\nTraceback:\n" + '' . join ( traceback . format_stack ( ) ) warnings . warn ( msg , DeprecationWarning , stacklevel = 3 ) | Deprecated warning for pywbem CIM Objects |
28,317 | def _to_int ( value_str , min_value , rep_digit , field_name , dtarg ) : if '*' in value_str : first = value_str . index ( '*' ) after = value_str . rindex ( '*' ) + 1 if value_str [ first : after ] != '*' * ( after - first ) : raise ValueError ( _format ( "Asterisks in {0} field of CIM datetime value " "{1!A} are not ... | Convert value_str into an integer replacing right - consecutive asterisks with rep_digit and an all - asterisk value with min_value . |
28,318 | def getContext ( self ) : ctx = SSL . Context ( SSL . SSLv23_METHOD ) ctx . use_certificate_file ( 'server.pem' ) ctx . use_privatekey_file ( 'server.pem' ) return ctx | Create an SSL context with a dodgy certificate . |
28,319 | def execute_request ( conn , classname , max_open , max_pull ) : start = ElapsedTimer ( ) result = conn . OpenEnumerateInstances ( classname , MaxObjectCount = max_open ) print ( 'open rtn eos=%s context=%s, count=%s time=%s ms' % ( result . eos , result . context , len ( result . instances ) , start . elapsed_ms ( ) )... | Enumerate instances defined by the function s classname argument using the OpenEnumerateInstances and PullInstancesWithPath . |
28,320 | def _pcdata_nodes ( pcdata ) : nodelist = [ ] if _CDATA_ESCAPING and isinstance ( pcdata , six . string_types ) and ( pcdata . find ( "<" ) >= 0 or pcdata . find ( ">" ) >= 0 or pcdata . find ( "&" ) >= 0 ) : pcdata_part_list = pcdata . split ( "]]>" ) i = 0 for pcdata_part in pcdata_part_list : i += 1 left = "" if i =... | Return a list of minidom nodes with the properly escaped pcdata inside . |
28,321 | def _uprint ( dest , text ) : if isinstance ( text , six . text_type ) : text = text + u'\n' elif isinstance ( text , six . binary_type ) : text = text + b'\n' else : raise TypeError ( "text must be a unicode or byte string, but is {0}" . format ( type ( text ) ) ) if dest is None : if six . PY2 : if isinstance ( text ... | Write text to dest adding a newline character . |
28,322 | def _pretty_xml ( xml_string ) : result_dom = minidom . parseString ( xml_string ) pretty_result = result_dom . toprettyxml ( indent = ' ' ) return re . sub ( r'>( *[\r\n]+)+( *)<' , r'>\n\2<' , pretty_result ) | Common function to produce pretty xml string from an input xml_string . |
28,323 | def add_namespace ( self , namespace ) : if namespace is None : raise ValueError ( "Namespace argument must not be None" ) namespace = namespace . strip ( '/' ) if namespace in self . namespaces : raise CIMError ( CIM_ERR_ALREADY_EXISTS , _format ( "Namespace {0!A} already exists in the mock " "repository" , namespace ... | Add a CIM namespace to the mock repository . |
28,324 | def _remove_namespace ( self , namespace ) : if namespace is None : raise ValueError ( "Namespace argument must not be None" ) namespace = namespace . strip ( '/' ) if namespace not in self . namespaces : raise CIMError ( CIM_ERR_NOT_FOUND , _format ( "Namespace {0!A} does not exist in the mock " "repository" , namespa... | Remove a CIM namespace from the mock repository . |
28,325 | def compile_mof_string ( self , mof_str , namespace = None , search_paths = None , verbose = None ) : namespace = namespace or self . default_namespace self . _validate_namespace ( namespace ) mofcomp = MOFCompiler ( _MockMOFWBEMConnection ( self ) , search_paths = search_paths , verbose = verbose ) mofcomp . compile_s... | Compile the MOF definitions in the specified string and add the resulting CIM objects to the specified CIM namespace of the mock repository . |
28,326 | def compile_dmtf_schema ( self , schema_version , schema_root_dir , class_names , use_experimental = False , namespace = None , verbose = False ) : schema = DMTFCIMSchema ( schema_version , schema_root_dir , use_experimental = use_experimental , verbose = verbose ) schema_mof = schema . build_schema_mof ( class_names )... | Compile the classes defined by class_names and their dependent classes from the DMTF CIM schema version defined by schema_version and keep the downloaded DMTF CIM schema in the directory defined by schema_dir . |
28,327 | def add_method_callback ( self , classname , methodname , method_callback , namespace = None , ) : if namespace is None : namespace = self . default_namespace method_repo = self . _get_method_repo ( namespace ) if classname not in method_repo : method_repo [ classname ] = NocaseDict ( ) if methodname in method_repo [ c... | Register a callback function for a CIM method that will be called when the CIM method is invoked via InvokeMethod . |
28,328 | def display_repository ( self , namespaces = None , dest = None , summary = False , output_format = 'mof' ) : if output_format == 'mof' : cmt_begin = '# ' cmt_end = '' elif output_format == 'xml' : cmt_begin = '<!-- ' cmt_end = ' ->' else : cmt_begin = '' cmt_end = '' if output_format not in OUTPUT_FORMATS : raise Valu... | Display the namespaces and objects in the mock repository in one of multiple formats to a destination . |
28,329 | def _get_inst_repo ( self , namespace = None ) : if namespace is None : namespace = self . default_namespace return self . instances [ namespace ] | Test support method that returns instances from the repository with no processing . It uses the default namespace if input parameter for namespace is None |
28,330 | def _class_exists ( self , classname , namespace ) : class_repo = self . _get_class_repo ( namespace ) return classname in class_repo | Test if class defined by classname parameter exists in repository defined by namespace parameter . |
28,331 | def _remove_qualifiers ( obj ) : assert isinstance ( obj , ( CIMInstance , CIMClass ) ) obj . qualifiers = NocaseDict ( ) for prop in obj . properties : obj . properties [ prop ] . qualifiers = NocaseDict ( ) if isinstance ( obj , CIMClass ) : for method in obj . methods : obj . methods [ method ] . qualifiers = Nocase... | Remove all qualifiers from the input objectwhere the object may be an CIMInstance or CIMClass . Removes qualifiers from the object and from properties methods and parameters |
28,332 | def _remove_classorigin ( obj ) : assert isinstance ( obj , ( CIMInstance , CIMClass ) ) for prop in obj . properties : obj . properties [ prop ] . class_origin = None if isinstance ( obj , CIMClass ) : for method in obj . methods : obj . methods [ method ] . class_origin = None | Remove all ClassOrigin attributes from the input object . The object may be a CIMInstance or CIMClass . |
28,333 | def _validate_namespace ( self , namespace ) : if namespace not in self . namespaces : raise CIMError ( CIM_ERR_INVALID_NAMESPACE , _format ( "Namespace does not exist in mock repository: {0!A}" , namespace ) ) | Validate whether a CIM namespace exists in the mock repository . |
28,334 | def _get_class_repo ( self , namespace ) : self . _validate_namespace ( namespace ) if namespace not in self . classes : self . classes [ namespace ] = NocaseDict ( ) return self . classes [ namespace ] | Returns the class repository for the specified CIM namespace within the mock repository . This is the original instance variable so any modifications will change the mock repository . |
28,335 | def _get_instance_repo ( self , namespace ) : self . _validate_namespace ( namespace ) if namespace not in self . instances : self . instances [ namespace ] = [ ] return self . instances [ namespace ] | Returns the instance repository for the specified CIM namespace within the mock repository . This is the original instance variable so any modifications will change the mock repository . |
28,336 | def _get_qualifier_repo ( self , namespace ) : self . _validate_namespace ( namespace ) if namespace not in self . qualifiers : self . qualifiers [ namespace ] = NocaseDict ( ) return self . qualifiers [ namespace ] | Returns the qualifier repository for the specified CIM namespace within the mock repository . This is the original instance variable so any modifications will change the mock repository . |
28,337 | def _get_method_repo ( self , namespace = None ) : self . _validate_namespace ( namespace ) if namespace not in self . methods : self . methods [ namespace ] = NocaseDict ( ) return self . methods [ namespace ] | Returns the method repository for the specified CIM namespace within the mock repository . This is the original instance variable so any modifications will change the mock repository . |
28,338 | def _get_superclassnames ( self , cn , namespace ) : class_repo = self . _get_class_repo ( namespace ) superclass_names = [ ] if cn is not None : cnwork = cn while cnwork : cnsuper = class_repo [ cnwork ] . superclass if cnsuper : superclass_names . append ( cnsuper ) cnwork = cnsuper superclass_names . reverse ( ) ret... | Get list of superclasses names from the class repository for the defined classname in the namespace . |
28,339 | def _get_subclass_names ( self , classname , namespace , deep_inheritance ) : assert classname is None or isinstance ( classname , ( six . string_types , CIMClassName ) ) if isinstance ( classname , CIMClassName ) : classname = classname . classname try : classes = self . classes [ namespace ] except KeyError : classes... | Get class names that are subclasses of the classname input parameter from the repository . |
28,340 | def _get_class ( self , classname , namespace , local_only = None , include_qualifiers = None , include_classorigin = None , property_list = None ) : class_repo = self . _get_class_repo ( namespace ) try : c = class_repo [ classname ] except KeyError : raise CIMError ( CIM_ERR_NOT_FOUND , _format ( "Class {0!A} not fou... | Get class from repository . Gets the class defined by classname from the repository creates a copy expands the copied class to include superclass properties if not localonly and filters the class based on propertylist and includeClassOrigin . |
28,341 | def _get_association_classes ( self , namespace ) : class_repo = self . _get_class_repo ( namespace ) for cl in six . itervalues ( class_repo ) : if 'Association' in cl . qualifiers : yield cl return | Return iterator of associator classes from the class repo |
28,342 | def _find_instance ( iname , instance_repo ) : rtn_inst = None rtn_index = None for index , inst in enumerate ( instance_repo ) : if iname == inst . path : if rtn_inst is not None : raise CIMError ( CIM_ERR_FAILED , _format ( "Invalid Repository. Multiple instances with " "same path {0!A}." , rtn_inst . path ) ) rtn_in... | Find an instance in the instance repo by iname and return the index of that instance . |
28,343 | def _get_instance ( self , iname , namespace , property_list , local_only , include_class_origin , include_qualifiers ) : instance_repo = self . _get_instance_repo ( namespace ) rtn_tup = self . _find_instance ( iname , instance_repo ) inst = rtn_tup [ 1 ] if inst is None : raise CIMError ( CIM_ERR_NOT_FOUND , _format ... | Local method implements getinstance . This is generally used by other instance methods that need to get an instance from the repository . |
28,344 | def _get_subclass_list_for_enums ( self , classname , namespace ) : if self . _repo_lite : return NocaseDict ( { classname : classname } ) if not self . _class_exists ( classname , namespace ) : raise CIMError ( CIM_ERR_INVALID_CLASS , _format ( "Class {0!A} not found in namespace {1!A}." , classname , namespace ) ) if... | Get class list ( i . e names of subclasses for classname for the enumerateinstance methods . If conn . lite returns only classname but no subclasses . |
28,345 | def _filter_properties ( obj , property_list ) : if property_list is not None : property_list = [ p . lower ( ) for p in property_list ] for pname in obj . properties . keys ( ) : if pname . lower ( ) not in property_list : del obj . properties [ pname ] | Remove properties from an instance or class that aren t in the plist parameter |
28,346 | def _appendpath_unique ( list_ , path ) : for p in list_ : if p == path : return list_ . append ( path ) | Append path to list if not already in list |
28,347 | def _return_assoc_tuple ( self , objects ) : if objects : result = [ ( u'OBJECTPATH' , { } , obj ) for obj in objects ] return self . _make_tuple ( result ) return None | Create the property tuple for _imethod return of references referencenames associators and associatornames methods . |
28,348 | def _return_assoc_class_tuples ( self , rtn_classnames , namespace , iq , ico , pl ) : rtn_tups = [ ] for cn in rtn_classnames : rtn_tups . append ( ( CIMClassName ( cn , namespace = namespace , host = self . host ) , self . _get_class ( cn , namespace = namespace , include_qualifiers = iq , include_classorigin = ico ,... | Creates the correct tuples of for associator and references class level responses from a list of classnames . This is special because the class level references and associators return a tuple of CIMClassName and CIMClass for every entry . |
28,349 | def _classnamedict ( self , classname , namespace ) : clns = self . _classnamelist ( classname , namespace ) rtn_dict = NocaseDict ( ) for cln in clns : rtn_dict [ cln ] = cln return rtn_dict | Get from _classnamelist and cvt to NocaseDict |
28,350 | def _ref_prop_matches ( prop , target_classname , ref_classname , resultclass_names , role ) : assert prop . type == 'reference' if prop . reference_class . lower ( ) == target_classname . lower ( ) : if resultclass_names and ref_classname not in resultclass_names : return False if role and prop . name . lower ( ) != r... | Test filters for a reference property Returns True if matches the criteria . |
28,351 | def _assoc_prop_matches ( prop , ref_classname , assoc_classes , result_classes , result_role ) : assert prop . type == 'reference' if assoc_classes and ref_classname not in assoc_classes : return False if result_classes and prop . reference_class not in result_classes : return False if result_role and prop . name . lo... | Test filters of a reference property and its associated entity Returns True if matches the criteria . Returns False if it does not match . |
28,352 | def _get_reference_classnames ( self , classname , namespace , resultclass_name , role ) : self . _validate_namespace ( namespace ) result_classes = self . _classnamedict ( resultclass_name , namespace ) rtn_classnames_set = set ( ) role = role . lower ( ) if role else role for cl in self . _get_association_classes ( n... | Get list of classnames that are references for which this classname is a target filtered by the result_class and role parameters if they are none . This is a common method used by all of the other reference and associator methods to create a list of reference classnames |
28,353 | def _get_associated_classnames ( self , classname , namespace , assoc_class , result_class , result_role , role ) : class_repo = self . _get_class_repo ( namespace ) result_classes = self . _classnamedict ( result_class , namespace ) assoc_classes = self . _classnamedict ( assoc_class , namespace ) rtn_classnames_set =... | Get list of classnames that are associated classes for which this classname is a target filtered by the assoc_class role result_class and result_role parameters if they are none . |
28,354 | def _make_pull_imethod_resp ( objs , eos , context_id ) : eos_tup = ( u'EndOfSequence' , None , eos ) enum_ctxt_tup = ( u'EnumerationContext' , None , context_id ) return [ ( "IRETURNVALUE" , { } , objs ) , enum_ctxt_tup , eos_tup ] | Create the correct imethod response for the open and pull methods |
28,355 | def _open_response ( self , objects , namespace , pull_type , ** params ) : max_obj_cnt = params [ 'MaxObjectCount' ] if max_obj_cnt is None : max_obj_cnt = _DEFAULT_MAX_OBJECT_COUNT default_server_timeout = 40 timeout = default_server_timeout if params [ 'OperationTimeout' ] is None else params [ 'OperationTimeout' ] ... | Build an open ... response once the objects have been extracted from the repository . |
28,356 | def _pull_response ( self , namespace , req_type , ** params ) : self . _validate_namespace ( namespace ) context_id = params [ 'EnumerationContext' ] try : context_data = self . enumeration_contexts [ context_id ] except KeyError : raise CIMError ( CIM_ERR_INVALID_ENUMERATION_CONTEXT , _format ( "EnumerationContext {0... | Common method for all of the Pull methods . Since all of the pull methods operate independent of the type of data this single function severs as common code |
28,357 | def _validate_open_params ( ** params ) : if not params [ 'FilterQueryLanguage' ] and params [ 'FilterQuery' ] : raise CIMError ( CIM_ERR_INVALID_PARAMETER , "FilterQuery without FilterQueryLanguage definition is " "invalid" ) if params [ 'FilterQueryLanguage' ] : if params [ 'FilterQueryLanguage' ] != 'DMTF:FQL' : rai... | Validate the fql parameters and if invalid generate exception |
28,358 | def _fake_openassociatorinstances ( self , namespace , ** params ) : self . _validate_namespace ( namespace ) self . _validate_open_params ( ** params ) params [ 'ObjectName' ] = params [ 'InstanceName' ] del params [ 'InstanceName' ] result = self . _fake_associators ( namespace , ** params ) objects = [ ] if result i... | Implements WBEM server responder for WBEMConnection . OpenAssociatorInstances with data from the instance repository . |
28,359 | def send_http_error ( self , http_code , cim_error = None , cim_error_details = None , headers = None ) : self . send_response ( http_code , http_client . responses . get ( http_code , '' ) ) self . send_header ( "CIMExport" , "MethodResponse" ) if cim_error is not None : self . send_header ( "CIMError" , cim_error ) i... | Send an HTTP response back to the WBEM server that indicates an error at the HTTP level . |
28,360 | def send_error_response ( self , msgid , methodname , status_code , status_desc , error_insts = None ) : resp_xml = cim_xml . CIM ( cim_xml . MESSAGE ( cim_xml . SIMPLEEXPRSP ( cim_xml . EXPMETHODRESPONSE ( methodname , cim_xml . ERROR ( str ( status_code ) , status_desc , error_insts ) , ) , ) , msgid , IMPLEMENTED_PR... | Send a CIM - XML response message back to the WBEM server that indicates error . |
28,361 | def send_success_response ( self , msgid , methodname ) : resp_xml = cim_xml . CIM ( cim_xml . MESSAGE ( cim_xml . SIMPLEEXPRSP ( cim_xml . EXPMETHODRESPONSE ( methodname ) , ) , msgid , IMPLEMENTED_PROTOCOL_VERSION ) , IMPLEMENTED_CIM_VERSION , IMPLEMENTED_DTD_VERSION ) resp_body = '<?xml version="1.0" encoding="utf-8... | Send a CIM - XML response message back to the WBEM server that indicates success . |
28,362 | def log ( self , format_ , args , level = logging . INFO ) : self . server . listener . logger . log ( level , format_ , * args ) | This function is called for anything that needs to get logged . It logs to the logger of this listener . |
28,363 | def start ( self ) : if self . _http_port : if not self . _http_server : try : server = ThreadedHTTPServer ( ( self . _host , self . _http_port ) , ListenerRequestHandler ) except Exception as exc : if getattr ( exc , 'errno' , None ) == errno . EADDRINUSE : msg = _format ( "WBEM listener port {0} already in use" , sel... | Start the WBEM listener threads if they are not yet running . |
28,364 | def stop ( self ) : if self . _http_server : self . _http_server . shutdown ( ) self . _http_server . server_close ( ) self . _http_server = None self . _http_thread = None if self . _https_server : self . _https_server . shutdown ( ) self . _https_server . server_close ( ) self . _https_server = None self . _https_thr... | Stop the WBEM listener threads if they are running . |
28,365 | def deliver_indication ( self , indication , host ) : for callback in self . _callbacks : try : callback ( indication , host ) except Exception as exc : self . logger . log ( logging . ERROR , "Indication delivery callback " "function raised %s: %s" , exc . __class__ . __name__ , exc ) | This function is called by the listener threads for each received indication . It is not supposed to be called by the user . |
28,366 | def add_callback ( self , callback ) : if callback not in self . _callbacks : self . _callbacks . append ( callback ) | Add a callback function to the listener . |
28,367 | def cmpname ( name1 , name2 ) : if name1 is None and name2 is None : return 0 if name1 is None : return - 1 if name2 is None : return 1 lower_name1 = name1 . lower ( ) lower_name2 = name2 . lower ( ) if lower_name1 == lower_name2 : return 0 return - 1 if lower_name1 < lower_name2 else 1 | Compare two CIM names for equality and ordering . |
28,368 | def _qualifiers_tomof ( qualifiers , indent , maxline = MAX_MOF_LINE ) : if not qualifiers : return u'' mof = [ ] mof . append ( _indent_str ( indent ) ) mof . append ( u'[' ) line_pos = indent + 1 mof_quals = [ ] for q in qualifiers . itervalues ( ) : mof_quals . append ( q . tomof ( indent + 1 + MOF_INDENT , maxline ... | Return a MOF string with the qualifier values including the surrounding square brackets . The qualifiers are ordered by their name . |
28,369 | def _mof_escaped ( strvalue ) : r escaped_str = strvalue escaped_str = escaped_str . replace ( '\\' , '\\\\' ) escaped_str = escaped_str . replace ( '\b' , '\\b' ) . replace ( '\t' , '\\t' ) . replace ( '\n' , '\\n' ) . replace ( '\f' , '\\f' ) . replace ( '\r' , '\\r' ) escaped_str = escaped_str . replace ( u'\u0001' ... | r Return a MOF - escaped string from the input string . |
28,370 | def _scalar_value_tomof ( value , type , indent = 0 , maxline = MAX_MOF_LINE , line_pos = 0 , end_space = 0 , avoid_splits = False ) : if value is None : return mofval ( u'NULL' , indent , maxline , line_pos , end_space ) if type == 'string' : if isinstance ( value , six . string_types ) : return mofstr ( value , inden... | Return a MOF string representing a scalar CIM - typed value . |
28,371 | def _infer_type ( value , element_kind , element_name ) : if value is None : raise ValueError ( _format ( "Cannot infer CIM type of {0} {1!A} from its value when " "the value is None" , element_kind , element_name ) ) try : return cimtype ( value ) except TypeError as exc : raise ValueError ( _format ( "Cannot infer CI... | Infer the CIM type name of the value based upon its Python type . |
28,372 | def _check_array_parms ( is_array , array_size , value , element_kind , element_name ) : if value is not None : value_is_array = isinstance ( value , ( list , tuple ) ) if not is_array and value_is_array : raise ValueError ( _format ( "The is_array parameter of {0} {1!A} is False but " "value {2!A} is an array." , elem... | Check whether array - related parameters are ok . |
28,373 | def _check_embedded_object ( embedded_object , type , value , element_kind , element_name ) : if embedded_object not in ( 'instance' , 'object' ) : raise ValueError ( _format ( "{0} {1!A} specifies an invalid value for " "embedded_object: {2!A} (must be 'instance' or 'object')" , element_kind , element_name , embedded_... | Check whether embedded - object - related parameters are ok . |
28,374 | def _kbstr_to_cimval ( key , val ) : if val [ 0 ] == '"' and val [ - 1 ] == '"' : cimval = val [ 1 : - 1 ] cimval = re . sub ( r'\\(.)' , r'\1' , cimval ) try : cimval = CIMInstanceName . from_wbem_uri ( cimval ) except ValueError : try : cimval = CIMDateTime ( cimval ) except ValueError : cimval = _ensure_unicode ( ci... | Convert a keybinding value string as found in a WBEM URI into a CIM object or CIM data type and return it . |
28,375 | def update ( self , * args , ** kwargs ) : for mapping in args : if hasattr ( mapping , 'items' ) : for key , value in mapping . items ( ) : self [ key ] = value else : for ( key , value ) in mapping : self [ key ] = value for key , value in kwargs . items ( ) : self [ key ] = value | Update the properties of this CIM instance . |
28,376 | def update_existing ( self , * args , ** kwargs ) : for mapping in args : if hasattr ( mapping , 'items' ) : for key , value in mapping . items ( ) : try : prop = self . properties [ key ] except KeyError : continue prop . value = value else : for ( key , value ) in mapping : try : prop = self . properties [ key ] exce... | Update already existing properties of this CIM instance . |
28,377 | def get ( self , key , default = None ) : prop = self . properties . get ( key , None ) return default if prop is None else prop . value | Return the value of a particular property of this CIM instance or a default value . |
28,378 | def items ( self ) : return [ ( key , v . value ) for key , v in self . properties . items ( ) ] | Return a copied list of the property names and values of this CIM instance . |
28,379 | def iteritems ( self ) : for key , val in self . properties . iteritems ( ) : yield ( key , val . value ) | Iterate through the property names and values of this CIM instance . |
28,380 | def tomof ( self , indent = 0 , maxline = MAX_MOF_LINE ) : if indent != 0 : msg = "The 'indent' parameter of CIMInstance.tomof() is " "deprecated." if DEBUG_WARNING_ORIGIN : msg += "\nTraceback:\n" + '' . join ( traceback . format_stack ( ) ) warnings . warn ( msg , DeprecationWarning , stacklevel = _stacklevel_above_m... | Return a MOF string with the specification of this CIM instance . |
28,381 | def tomof ( self , maxline = MAX_MOF_LINE ) : mof = [ ] mof . append ( _qualifiers_tomof ( self . qualifiers , MOF_INDENT , maxline ) ) mof . append ( u'class ' ) mof . append ( self . classname ) mof . append ( u' ' ) if self . superclass is not None : mof . append ( u': ' ) mof . append ( self . superclass ) mof . ap... | Return a MOF string with the declaration of this CIM class . |
28,382 | def tomof ( self , is_instance = True , indent = 0 , maxline = MAX_MOF_LINE , line_pos = 0 ) : mof = [ ] if is_instance : mof . append ( _indent_str ( indent ) ) mof . append ( self . name ) else : if self . qualifiers : mof . append ( _qualifiers_tomof ( self . qualifiers , indent + MOF_INDENT , maxline ) ) mof . appe... | Return a MOF string with the declaration of this CIM property for use in a CIM class or the specification of this CIM property for use in a CIM instance . |
28,383 | def tomof ( self , indent = 0 , maxline = MAX_MOF_LINE ) : mof = [ ] if self . qualifiers : mof . append ( _qualifiers_tomof ( self . qualifiers , indent + MOF_INDENT , maxline ) ) mof . append ( _indent_str ( indent ) ) mof . append ( moftype ( self . return_type , None ) ) mof . append ( u' ' ) mof . append ( self . ... | Return a MOF string with the declaration of this CIM method for use in a CIM class declaration . |
28,384 | def tomof ( self , indent = 0 , maxline = MAX_MOF_LINE ) : mof = [ ] if self . qualifiers : mof . append ( _qualifiers_tomof ( self . qualifiers , indent + MOF_INDENT , maxline ) ) mof . append ( _indent_str ( indent ) ) mof . append ( moftype ( self . type , self . reference_class ) ) mof . append ( u' ' ) mof . appen... | Return a MOF string with the declaration of this CIM parameter for use in a CIM method declaration . |
28,385 | def tomof ( self , indent = MOF_INDENT , maxline = MAX_MOF_LINE , line_pos = 0 ) : mof = [ ] mof . append ( self . name ) mof . append ( u' ' ) if isinstance ( self . value , list ) : mof . append ( u'{' ) else : mof . append ( u'(' ) line_pos += len ( u'' . join ( mof ) ) val_str , line_pos = _value_tomof ( self . val... | Return a MOF string with the specification of this CIM qualifier as a qualifier value . |
28,386 | def tomof ( self , maxline = MAX_MOF_LINE ) : mof = [ ] mof . append ( u'Qualifier ' ) mof . append ( self . name ) mof . append ( u' : ' ) mof . append ( self . type ) if self . is_array : mof . append ( u'[' ) if self . array_size is not None : mof . append ( six . text_type ( self . array_size ) ) mof . append ( u']... | Return a MOF string with the declaration of this CIM qualifier type . |
28,387 | def main ( ) : print ( "Python version %s" % sys . version ) print ( "Testing compatibility for function defined with *args" ) test_func_args ( func_old_args ) test_func_args ( func_new ) print ( "Testing compatibility for function defined with **kwargs" ) test_func_kwargs ( func_old_kwargs ) test_func_kwargs ( func_ne... | Main function calls the test functs |
28,388 | def _validate_qualifiers ( qualifier_list , qual_repo , new_class , scope ) : for qname , qvalue in qualifier_list . items ( ) : if qname not in qual_repo : raise CIMError ( CIM_ERR_INVALID_PARAMETER , _format ( "Qualifier {0|A} in new_class {1|A} in " "CreateClass not in repository." , ( qname , new_class . classnam )... | Validate a list of qualifiers against the Qualifier decl in the repository . |
28,389 | def _init_qualifier ( qualifier , qual_repo ) : qual_dict_entry = qual_repo [ qualifier . name ] qualifier . propagated = False if qualifier . tosubclass is None : if qual_dict_entry . tosubclass is None : qualifier . tosubclass = True else : qualifier . tosubclass = qual_dict_entry . tosubclass if qualifier . overrida... | Initialize the flavors of a qualifier from the qualifier repo and initialize propagated . |
28,390 | def _init_qualifier_decl ( qualifier_decl , qual_repo ) : assert qualifier_decl . name not in qual_repo if qualifier_decl . tosubclass is None : qualifier_decl . tosubclass = True if qualifier_decl . overridable is None : qualifier_decl . overridable = True if qualifier_decl . translatable is None : qualifier_decl . tr... | Initialize the flavors of a qualifier declaration if they are not already set . |
28,391 | def _set_new_object ( self , new_obj , inherited_obj , new_class , superclass , qualifier_repo , propagated , type_str ) : assert isinstance ( new_obj , ( CIMMethod , CIMProperty , CIMParameter ) ) if inherited_obj : inherited_obj_qual = inherited_obj . qualifiers else : inherited_obj_qual = None if propagated : assert... | Set the object attributes for a single object and resolve the qualifiers . This sets attributes for Properties Methods and Parameters . |
28,392 | def _resolve_qualifiers ( self , new_quals , inherited_quals , new_class , super_class , obj_name , obj_type , qualifier_repo , propagate = False , verbose = False ) : superclassname = super_class . classname if super_class else None if verbose : print ( "\nRESOLVE sc_name=%s nc_name=%s, obj_name=%s obj_type=%s " " pr... | Process the override of qualifiers from the inherited_quals dictionary to the new_quals dict following the override rules in DSP0004 . |
28,393 | def _validateIterCommonParams ( MaxObjectCount , OperationTimeout ) : if MaxObjectCount is None or MaxObjectCount <= 0 : raise ValueError ( _format ( "MaxObjectCount must be > 0 but is {0}" , MaxObjectCount ) ) if OperationTimeout is not None and OperationTimeout < 0 : raise ValueError ( _format ( "OperationTimeout mus... | Validate common parameters for an iter ... operation . |
28,394 | def _validatePullParams ( MaxObjectCount , context ) : if ( not isinstance ( MaxObjectCount , six . integer_types ) or MaxObjectCount < 0 ) : raise ValueError ( _format ( "MaxObjectCount parameter must be integer >= 0 but is " "{0!A}" , MaxObjectCount ) ) if context is None or len ( context ) < 2 : raise ValueError ( _... | Validate the input paramaters for the PullInstances PullInstancesWithPath and PullInstancePaths requests . |
28,395 | def is_subclass ( ch , ns , super_class , sub ) : lsuper = super_class . lower ( ) if isinstance ( sub , CIMClass ) : subname = sub . classname subclass = sub else : subname = sub subclass = None if subname . lower ( ) == lsuper : return True if subclass is None : subclass = ch . GetClass ( subname , ns , LocalOnly = T... | Determine if one class is a subclass of another class . |
28,396 | def _set_default_namespace ( self , default_namespace ) : if default_namespace is not None : default_namespace = default_namespace . strip ( '/' ) else : default_namespace = DEFAULT_NAMESPACE self . _default_namespace = _ensure_unicode ( default_namespace ) | Internal setter function . |
28,397 | def _configure_detail_level ( cls , detail_level ) : if isinstance ( detail_level , six . string_types ) : if detail_level not in LOG_DETAIL_LEVELS : raise ValueError ( _format ( "Invalid log detail level string: {0!A}; must be " "one of: {1!A}" , detail_level , LOG_DETAIL_LEVELS ) ) elif isinstance ( detail_level , in... | Validate the detail_level parameter and return it . |
28,398 | def _configure_logger_handler ( cls , log_dest , log_filename ) : if log_dest is None : return None msg_format = '%(asctime)s-%(name)s-%(message)s' if log_dest == 'stderr' : handler = logging . StreamHandler ( ) handler . setFormatter ( logging . Formatter ( msg_format ) ) elif log_dest == 'file' : if not log_filename ... | Return a logging handler for the specified log_dest or None if log_dest is None . |
28,399 | def _activate_logger ( cls , logger_name , simple_name , detail_level , handler , connection , propagate ) : if handler is not None : assert isinstance ( handler , logging . Handler ) logger = logging . getLogger ( logger_name ) for hdlr in logger . handlers : logger . removeHandler ( hdlr ) logger . addHandler ( handl... | Configure the specified logger and activate logging and set detail level for connections . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.