idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
28,400 | def _iparam_namespace_from_namespace ( self , obj ) : if isinstance ( obj , six . string_types ) : namespace = obj . strip ( '/' ) elif obj is None : namespace = obj else : raise TypeError ( _format ( "The 'namespace' argument of the WBEMConnection " "operation has invalid type {0} (must be None, or a " "string)" , typ... | Determine the namespace from a namespace string or None . The default namespace of the connection object is used if needed . |
28,401 | def _iparam_namespace_from_objectname ( self , objectname , arg_name ) : if isinstance ( objectname , ( CIMClassName , CIMInstanceName ) ) : namespace = objectname . namespace elif isinstance ( objectname , six . string_types ) : namespace = None elif objectname is None : namespace = objectname else : raise TypeError (... | Determine the namespace from an object name that can be a class name string a CIMClassName or CIMInstanceName object or None . The default namespace of the connection object is used if needed . |
28,402 | def _get_rslt_params ( self , result , namespace ) : rtn_objects = [ ] end_of_sequence = False enumeration_context = None end_of_sequence_found = False enumeration_context_found = False for p in result : if p [ 0 ] == 'EndOfSequence' : if isinstance ( p [ 2 ] , six . string_types ) : p2 = p [ 2 ] . lower ( ) if p2 in [... | Common processing for pull results to separate end - of - sequence enum - context and entities in IRETURNVALUE . |
28,403 | def GetInstance ( self , InstanceName , LocalOnly = None , IncludeQualifiers = None , IncludeClassOrigin = None , PropertyList = None , ** extra ) : exc = None instance = None method_name = 'GetInstance' if self . _operation_recorders : self . operation_recorder_reset ( ) self . operation_recorder_stage_pywbem_args ( m... | Retrieve an instance . |
28,404 | def ModifyInstance ( self , ModifiedInstance , IncludeQualifiers = None , PropertyList = None , ** extra ) : exc = None method_name = 'ModifyInstance' if self . _operation_recorders : self . operation_recorder_reset ( ) self . operation_recorder_stage_pywbem_args ( method = method_name , ModifiedInstance = ModifiedInst... | Modify the property values of an instance . |
28,405 | def CreateInstance ( self , NewInstance , namespace = None , ** extra ) : exc = None instancename = None method_name = 'CreateInstance' if self . _operation_recorders : self . operation_recorder_reset ( ) self . operation_recorder_stage_pywbem_args ( method = method_name , NewInstance = NewInstance , namespace = namesp... | Create an instance in a namespace . |
28,406 | def Associators ( self , ObjectName , AssocClass = None , ResultClass = None , Role = None , ResultRole = None , IncludeQualifiers = None , IncludeClassOrigin = None , PropertyList = None , ** extra ) : exc = None objects = None method_name = 'Associators' if self . _operation_recorders : self . operation_recorder_rese... | Retrieve the instances associated to a source instance or the classes associated to a source class . |
28,407 | def InvokeMethod ( self , MethodName , ObjectName , Params = None , ** params ) : exc = None result_tuple = None if self . _operation_recorders : self . operation_recorder_reset ( ) self . operation_recorder_stage_pywbem_args ( method = 'InvokeMethod' , MethodName = MethodName , ObjectName = ObjectName , Params = Param... | Invoke a method on a target instance or on a target class . |
28,408 | def ExecQuery ( self , QueryLanguage , Query , namespace = None , ** extra ) : exc = None instances = None method_name = 'ExecQuery' if self . _operation_recorders : self . operation_recorder_reset ( ) self . operation_recorder_stage_pywbem_args ( method = method_name , QueryLanguage = QueryLanguage , Query = Query , n... | Execute a query in a namespace . |
28,409 | def OpenAssociatorInstancePaths ( self , InstanceName , AssocClass = None , ResultClass = None , Role = None , ResultRole = None , FilterQueryLanguage = None , FilterQuery = None , OperationTimeout = None , ContinueOnError = None , MaxObjectCount = None , ** extra ) : exc = None result_tuple = None method_name = 'OpenA... | Open an enumeration session to retrieve the instance paths of the instances associated to a source instance . |
28,410 | def OpenQueryInstances ( self , FilterQueryLanguage , FilterQuery , namespace = None , ReturnQueryResultClass = None , OperationTimeout = None , ContinueOnError = None , MaxObjectCount = None , ** extra ) : @ staticmethod def _GetQueryRsltClass ( result ) : for p in result : if p [ 0 ] == 'QueryResultClass' : class_obj... | Open an enumeration session to execute a query in a namespace and to retrieve the instances representing the query result . |
28,411 | def EnumerateClasses ( self , namespace = None , ClassName = None , DeepInheritance = None , LocalOnly = None , IncludeQualifiers = None , IncludeClassOrigin = None , ** extra ) : exc = None classes = None method_name = 'EnumerateClasses' if self . _operation_recorders : self . operation_recorder_reset ( ) self . opera... | Enumerate the subclasses of a class or the top - level classes in a namespace . |
28,412 | def EnumerateClassNames ( self , namespace = None , ClassName = None , DeepInheritance = None , ** extra ) : exc = None classnames = None method_name = 'EnumerateClassNames' if self . _operation_recorders : self . operation_recorder_reset ( ) self . operation_recorder_stage_pywbem_args ( method = method_name , namespac... | Enumerate the names of subclasses of a class or of the top - level classes in a namespace . |
28,413 | def ModifyClass ( self , ModifiedClass , namespace = None , ** extra ) : exc = None method_name = 'ModifyClass' if self . _operation_recorders : self . operation_recorder_reset ( ) self . operation_recorder_stage_pywbem_args ( method = method_name , ModifiedClass = ModifiedClass , namespace = namespace , ** extra ) try... | Modify a class . |
28,414 | def DeleteClass ( self , ClassName , namespace = None , ** extra ) : exc = None method_name = 'DeleteClass' if self . _operation_recorders : self . operation_recorder_reset ( ) self . operation_recorder_stage_pywbem_args ( method = method_name , ClassName = ClassName , namespace = namespace , ** extra ) try : stats = s... | Delete a class . |
28,415 | def connectionMade ( self ) : self . factory . request_xml = str ( self . factory . payload ) self . sendCommand ( 'POST' , '/cimom' ) self . sendHeader ( 'Host' , '%s:%d' % ( self . transport . addr [ 0 ] , self . transport . addr [ 1 ] ) ) self . sendHeader ( 'User-Agent' , 'pywbem/twisted' ) self . sendHeader ( 'Con... | Send a HTTP POST command with the appropriate CIM over HTTP headers and payload . |
28,416 | def handleResponse ( self , data ) : self . factory . response_xml = data if self . status == '200' : self . factory . parseErrorAndResponse ( data ) self . factory . deferred = None self . transport . loseConnection ( ) | Called when all response data has been received . |
28,417 | def handleStatus ( self , version , status , message ) : self . status = status self . message = message | Save the status code for processing when we get to the end of the headers . |
28,418 | def handleHeader ( self , key , value ) : if key == 'CIMError' : self . CIMError = urllib . parse . unquote ( value ) if key == 'PGErrorDetail' : self . PGErrorDetail = urllib . parse . unquote ( value ) | Handle header values . |
28,419 | def handleEndHeaders ( self ) : if self . status != '200' : if not hasattr ( self , 'cimerror' ) or not hasattr ( self , 'errordetail' ) : self . factory . deferred . errback ( CIMError ( 0 , 'HTTP error %s: %s' % ( self . status , self . message ) ) ) else : self . factory . deferred . errback ( CIMError ( 0 , '%s: %s... | Check whether the status was OK and raise an error if not using previously saved header information . |
28,420 | def imethodcallPayload ( self , methodname , localnsp , ** kwargs ) : param_list = [ pywbem . IPARAMVALUE ( x [ 0 ] , pywbem . tocimxml ( x [ 1 ] ) ) for x in kwargs . items ( ) ] payload = cim_xml . CIM ( cim_xml . MESSAGE ( cim_xml . SIMPLEREQ ( cim_xml . IMETHODCALL ( methodname , cim_xml . LOCALNAMESPACEPATH ( [ ci... | Generate the XML payload for an intrinsic methodcall . |
28,421 | def methodcallPayload ( self , methodname , obj , namespace , ** kwargs ) : if isinstance ( obj , CIMInstanceName ) : path = obj . copy ( ) path . host = None path . namespace = None localpath = cim_xml . LOCALINSTANCEPATH ( cim_xml . LOCALNAMESPACEPATH ( [ cim_xml . NAMESPACE ( ns ) for ns in namespace . split ( '/' )... | Generate the XML payload for an extrinsic methodcall . |
28,422 | def parseErrorAndResponse ( self , data ) : xml = fromstring ( data ) error = xml . find ( './/ERROR' ) if error is None : self . deferred . callback ( self . parseResponse ( xml ) ) return try : code = int ( error . attrib [ 'CODE' ] ) except ValueError : code = 0 self . deferred . errback ( CIMError ( code , error . ... | Parse returned XML for errors then convert into appropriate Python objects . |
28,423 | def start ( self ) : thread = threading . Thread ( target = reactor . run ) thread . start ( ) | doesn t work |
28,424 | def MI_associatorNames ( self , env , objectName , assocClassName , resultClassName , role , resultRole ) : logger = env . get_logger ( ) logger . log_debug ( 'CIMProvider2 MI_associatorNames called. ' 'assocClass: %s' % ( assocClassName ) ) if not assocClassName : raise pywbem . CIMError ( pywbem . CIM_ERR_FAILED , "E... | Return instances names associated to a given object . |
28,425 | def _get_callable ( self , classname , cname ) : callable = None if classname in self . provregs : provClass = self . provregs [ classname ] if hasattr ( provClass , cname ) : callable = getattr ( provClass , cname ) elif hasattr ( self . provmod , cname ) : callable = getattr ( self . provmod , cname ) if callable is ... | Return a function or method object appropriate to fulfill a request |
28,426 | def _reload_if_necessary ( self , env ) : try : mod = sys . modules [ self . provider_module_name ] except KeyError : mod = None if ( mod is None or mod . provmod_timestamp != os . path . getmtime ( self . provid ) ) : logger = env . get_logger ( ) logger . log_debug ( "Need to reload provider at %s" % self . provid ) ... | Check timestamp of loaded python provider module and if it has changed since load then reload the provider module . |
28,427 | def _real_key ( self , key ) : if key is not None : try : return key . lower ( ) except AttributeError : raise TypeError ( _format ( "NocaseDict key {0!A} must be a string, " "but is {1}" , key , type ( key ) ) ) if self . allow_unnamed_keys : return None raise TypeError ( _format ( "NocaseDict key None (unnamed key) i... | Return the normalized key to be used for the internal dictionary from the input key . |
28,428 | def copy ( self ) : result = NocaseDict ( ) result . _data = self . _data . copy ( ) return result | Return a copy of the dictionary . |
28,429 | def t_error ( t ) : msg = _format ( "Illegal character {0!A}" , t . value [ 0 ] ) t . lexer . last_msg = msg t . lexer . skip ( 1 ) return t | Lexer error callback from PLY Lexer with token in error . |
28,430 | def p_error ( p ) : if p is None : raise MOFParseError ( msg = 'Unexpected end of file' ) msg = p . lexer . last_msg p . lexer . last_msg = None raise MOFParseError ( parser_token = p , msg = msg ) | YACC Error Callback from the parser . The parameter is the token in error and contains information on the file and position of the error . If p is None PLY is returning eof error . |
28,431 | def _fixStringValue ( s , p ) : s = s [ 1 : - 1 ] rv = '' esc = False i = - 1 while i < len ( s ) - 1 : i += 1 ch = s [ i ] if ch == '\\' and not esc : esc = True continue if not esc : rv += ch continue if ch == '"' : rv += '"' elif ch == 'n' : rv += '\n' elif ch == 't' : rv += '\t' elif ch == 'b' : rv += '\b' elif ch ... | Clean up string value including special characters etc . |
28,432 | def _build_flavors ( p , flist , qualdecl = None ) : flavors = { } if ( 'disableoverride' in flist and 'enableoverride' in flist ) or ( 'restricted' in flist and 'tosubclass' in flist ) : raise MOFParseError ( parser_token = p , msg = "Conflicting flavors are" "invalid" ) if qualdecl is not None : flavors = { 'overrida... | Build and return a dictionary defining the flavors from the flist argument . |
28,433 | def _find_column ( input_ , token ) : i = token . lexpos while i > 0 : if input_ [ i ] == '\n' : break i -= 1 column = token . lexpos - i - 1 return column | Find the column in file where error occured . This is taken from token . lexpos converted to the position on the current line by finding the previous EOL . |
28,434 | def _get_error_context ( input_ , token ) : try : line = input_ [ token . lexpos : input_ . index ( '\n' , token . lexpos ) ] except ValueError : line = input_ [ token . lexpos : ] i = input_ . rfind ( '\n' , 0 , token . lexpos ) if i < 0 : i = 0 line = input_ [ i : token . lexpos ] + line lines = [ line . strip ( '\r\... | Build a context string that defines where on the line the defined error occurs . This consists of the characters ^ at the position and for the length defined by the lexer position and token length |
28,435 | def _build ( verbose = False ) : if verbose : print ( _format ( "Building LEX/YACC modules for MOF compiler in: {0}" , _tabdir ) ) _yacc ( verbose ) _lex ( verbose ) | Build the LEX and YACC table modules for the MOF compiler if they do not exist yet or if their table versions do not match the installed version of the ply package . |
28,436 | def _yacc ( verbose = False ) : return yacc . yacc ( optimize = _optimize , tabmodule = _tabmodule , outputdir = _tabdir , debug = True , debuglog = yacc . NullLogger ( ) , errorlog = yacc . PlyLogger ( sys . stdout ) ) | Return YACC parser object for the MOF compiler . |
28,437 | def _lex ( verbose = False ) : return lex . lex ( optimize = _optimize , lextab = _lextab , outputdir = _tabdir , debug = False , errorlog = lex . PlyLogger ( sys . stdout ) ) | Return LEX analyzer object for the MOF Compiler . |
28,438 | def _setns ( self , value ) : if self . conn is not None : self . conn . default_namespace = value else : self . __default_namespace = value | Set the default repository namespace to be used . |
28,439 | def CreateInstance ( self , * args , ** kwargs ) : inst = args [ 0 ] if args else kwargs [ 'NewInstance' ] try : self . instances [ self . default_namespace ] . append ( inst ) except KeyError : self . instances [ self . default_namespace ] = [ inst ] return inst . path | Create a CIM instance in the local repository of this class . |
28,440 | def GetClass ( self , * args , ** kwargs ) : cname = args [ 0 ] if args else kwargs [ 'ClassName' ] try : cc = self . classes [ self . default_namespace ] [ cname ] except KeyError : if self . conn is None : ce = CIMError ( CIM_ERR_NOT_FOUND , cname ) raise ce cc = self . conn . GetClass ( * args , ** kwargs ) try : se... | Retrieve a CIM class from the local repository of this class . |
28,441 | def EnumerateQualifiers ( self , * args , ** kwargs ) : if self . conn is not None : rv = self . conn . EnumerateQualifiers ( * args , ** kwargs ) else : rv = [ ] try : rv += list ( self . qualifiers [ self . default_namespace ] . values ( ) ) except KeyError : pass return rv | Enumerate the qualifier types in the local repository of this class . |
28,442 | def GetQualifier ( self , * args , ** kwargs ) : qualname = args [ 0 ] if args else kwargs [ 'QualifierName' ] try : qual = self . qualifiers [ self . default_namespace ] [ qualname ] except KeyError : if self . conn is None : raise CIMError ( CIM_ERR_NOT_FOUND , qualname , conn_id = self . conn_id ) qual = self . conn... | Retrieve a qualifier type from the local repository of this class . |
28,443 | def SetQualifier ( self , * args , ** kwargs ) : qual = args [ 0 ] if args else kwargs [ 'QualifierDeclaration' ] try : self . qualifiers [ self . default_namespace ] [ qual . name ] = qual except KeyError : self . qualifiers [ self . default_namespace ] = NocaseDict ( { qual . name : qual } ) | Create or modify a qualifier type in the local repository of this class . |
28,444 | def rollback ( self , verbose = False ) : for ns , insts in self . instances . items ( ) : insts . reverse ( ) for inst in insts : try : if verbose : print ( _format ( "Deleting instance {0}" , inst . path ) ) self . conn . DeleteInstance ( inst . path ) except CIMError as ce : print ( _format ( "Error deleting instanc... | Remove classes and instances from the underlying repository that have been created in the local repository of this class . |
28,445 | def compile_string ( self , mof , ns , filename = None ) : lexer = self . lexer . clone ( ) lexer . parser = self . parser try : oldfile = self . parser . file except AttributeError : oldfile = None self . parser . file = filename try : oldmof = self . parser . mof except AttributeError : oldmof = None self . parser . ... | Compile a string of MOF statements into a namespace of the associated CIM repository . |
28,446 | def compile_file ( self , filename , ns ) : if self . parser . verbose : self . parser . log ( _format ( "Compiling file {0!A}" , filename ) ) if not os . path . exists ( filename ) : rfilename = self . find_mof ( os . path . basename ( filename [ : - 4 ] ) . lower ( ) ) if rfilename is None : raise IOError ( _format (... | Compile a MOF file into a namespace of the associated CIM repository . |
28,447 | def find_mof ( self , classname ) : classname = classname . lower ( ) for search in self . parser . search_paths : for root , dummy_dirs , files in os . walk ( search ) : for file_ in files : if file_ . endswith ( '.mof' ) and file_ [ : - 4 ] . lower ( ) == classname : return os . path . join ( root , file_ ) return No... | Find the MOF file that defines a particular CIM class in the search path of the MOF compiler . |
28,448 | def configure_loggers_from_string ( log_configuration_str , log_filename = DEFAULT_LOG_FILENAME , connection = None , propagate = False ) : log_specs = log_configuration_str . split ( ',' ) for log_spec in log_specs : spec_split = log_spec . strip ( '=' ) . split ( "=" ) simple_name = spec_split [ 0 ] if not simple_nam... | Configure the pywbem loggers and optionally activate WBEM connections for logging and setting a log detail level from a log configuration string . |
28,449 | def display_paths ( instances , type_str ) : print ( '%ss: count=%s' % ( type_str , len ( instances ) , ) ) for path in [ instance . path for instance in instances ] : print ( '%s: %s' % ( type_str , path ) ) if len ( instances ) : print ( '' ) | Display the count and paths for the list of instances in instances . |
28,450 | def get_default_ca_certs ( ) : if not hasattr ( get_default_ca_certs , '_path' ) : for path in get_default_ca_cert_paths ( ) : if os . path . exists ( path ) : get_default_ca_certs . _path = path break else : get_default_ca_certs . _path = None return get_default_ca_certs . _path | Try to find out system path with ca certificates . This path is cached and returned . If no path is found out None is returned . |
28,451 | def get_cimobject_header ( obj ) : if isinstance ( obj , six . string_types ) : return obj if isinstance ( obj , CIMClassName ) : return obj . to_wbem_uri ( format = 'cimobject' ) if isinstance ( obj , CIMInstanceName ) : return obj . to_wbem_uri ( format = 'cimobject' ) raise TypeError ( _format ( "Invalid object type... | Return the value for the CIM - XML extension header field CIMObject using the given object . |
28,452 | def print_profile_info ( org_vm , inst ) : org = org_vm . tovalues ( inst [ 'RegisteredOrganization' ] ) name = inst [ 'RegisteredName' ] vers = inst [ 'RegisteredVersion' ] print ( " %s %s Profile %s" % ( org , name , vers ) ) | Print the registered org name version for the profile defined by inst |
28,453 | def explore_server ( server_url , username , password ) : print ( "WBEM server URL:\n %s" % server_url ) conn = WBEMConnection ( server_url , ( username , password ) , no_verification = True ) server = WBEMServer ( conn ) print ( "Brand:\n %s" % server . brand ) print ( "Version:\n %s" % server . version ) print ( "... | Demo of exploring a cim server for characteristics defined by the server class |
28,454 | def create_namespace ( self , namespace ) : std_namespace = _ensure_unicode ( namespace . strip ( '/' ) ) ws_profiles = self . get_selected_profiles ( 'DMTF' , 'WBEM Server' ) if ws_profiles : ws_profiles_sorted = sorted ( ws_profiles , key = lambda prof : prof [ 'RegisteredVersion' ] ) ws_profile_inst = ws_profiles_so... | Create the specified CIM namespace in the WBEM server and update this WBEMServer object to reflect the new namespace there . |
28,455 | def delete_namespace ( self , namespace ) : std_namespace = _ensure_unicode ( namespace . strip ( '/' ) ) self . _determine_namespaces ( ) if std_namespace not in self . namespaces : raise CIMError ( CIM_ERR_NOT_FOUND , _format ( "Specified namespace does not exist: {0!A}" , std_namespace ) , conn_id = self . conn . co... | Delete the specified CIM namespace in the WBEM server and update this WBEMServer object to reflect the removed namespace there . |
28,456 | def _traverse ( self , start_paths , traversal_path ) : assert len ( traversal_path ) >= 2 assoc_class = traversal_path [ 0 ] far_class = traversal_path [ 1 ] total_next_paths = [ ] for path in start_paths : next_paths = self . _conn . AssociatorNames ( ObjectName = path , AssocClass = assoc_class , ResultClass = far_c... | Traverse a multi - hop traversal path from a list of start instance paths and return the resulting list of instance paths . |
28,457 | def _validate_interop_ns ( self , interop_ns ) : test_classname = 'CIM_Namespace' try : self . _conn . EnumerateInstanceNames ( test_classname , namespace = interop_ns ) except CIMError as exc : if exc . status_code in ( CIM_ERR_INVALID_CLASS , CIM_ERR_NOT_FOUND ) : pass else : raise self . _interop_ns = interop_ns | Validate whether the specified Interop namespace exists in the WBEM server by communicating with it . |
28,458 | def _determine_profiles ( self ) : mp_insts = self . _conn . EnumerateInstances ( "CIM_RegisteredProfile" , namespace = self . interop_ns ) self . _profiles = mp_insts | Determine the WBEM management profiles advertised by the WBEM server by communicating with it and enumerating the instances of CIM_RegisteredProfile . |
28,459 | def _represent_undefined ( self , data ) : raise RepresenterError ( _format ( "Cannot represent an object: {0!A} of type: {1}; " "yaml_representers: {2!A}, " "yaml_multi_representers: {3!A}" , data , type ( data ) , self . yaml_representers . keys ( ) , self . yaml_multi_representers . keys ( ) ) ) | Raises flag for objects that cannot be represented |
28,460 | def open_file ( filename , file_mode = 'w' ) : if six . PY2 : return codecs . open ( filename , mode = file_mode , encoding = 'utf-8' ) return open ( filename , file_mode , encoding = 'utf8' ) | A static convenience function that performs the open of the recorder file correctly for different versions of Python . |
28,461 | def reset ( self , pull_op = None ) : self . _pywbem_method = None self . _pywbem_args = None self . _pywbem_result_ret = None self . _pywbem_result_exc = None self . _http_request_version = None self . _http_request_url = None self . _http_request_target = None self . _http_request_method = None self . _http_request_h... | Reset all the attributes in the class . This also allows setting the pull_op attribute that defines whether the operation is to be a traditional or pull operation . This does NOT reset _conn . id as that exists through the life of the connection . |
28,462 | def stage_pywbem_args ( self , method , ** kwargs ) : self . _pywbem_method = method self . _pywbem_args = kwargs | Set requst method and all args . Normally called before the cmd is executed to record request parameters |
28,463 | def stage_pywbem_result ( self , ret , exc ) : self . _pywbem_result_ret = ret self . _pywbem_result_exc = exc | Set Result return info or exception info |
28,464 | def stage_http_request ( self , conn_id , version , url , target , method , headers , payload ) : self . _http_request_version = version self . _http_request_conn_id = conn_id self . _http_request_url = url self . _http_request_target = target self . _http_request_method = method self . _http_request_headers = headers ... | Set request HTTP information including url headers etc . |
28,465 | def stage_http_response1 ( self , conn_id , version , status , reason , headers ) : self . _http_response_version = version self . _http_response_status = status self . _http_response_reason = reason self . _http_response_headers = headers | Set response http info including headers status etc . conn_id unused here . Used in log |
28,466 | def record_staged ( self ) : if self . enabled : pwargs = OpArgs ( self . _pywbem_method , self . _pywbem_args ) pwresult = OpResult ( self . _pywbem_result_ret , self . _pywbem_result_exc ) httpreq = HttpRequest ( self . _http_request_version , self . _http_request_url , self . _http_request_target , self . _http_requ... | Encode staged information on request and result to output |
28,467 | def set_detail_level ( self , detail_levels ) : if detail_levels is None : return self . detail_levels = detail_levels if 'api' in detail_levels : self . api_detail_level = detail_levels [ 'api' ] if 'http' in detail_levels : self . http_detail_level = detail_levels [ 'http' ] if isinstance ( self . api_detail_level , ... | Sets the detail levels from the input dictionary in detail_levels . |
28,468 | def stage_pywbem_args ( self , method , ** kwargs ) : self . _pywbem_method = method if self . enabled and self . api_detail_level is not None and self . apilogger . isEnabledFor ( logging . DEBUG ) : kwstr = ', ' . join ( [ ( '{0}={1!r}' . format ( key , kwargs [ key ] ) ) for key in sorted ( six . iterkeys ( kwargs )... | Log request method and all args . Normally called before the cmd is executed to record request parameters . This method does not support the summary detail_level because that seems to add little info to the log that is not also in the response . |
28,469 | def stage_pywbem_result ( self , ret , exc ) : def format_result ( ret , max_len ) : if self . api_detail_level == 'summary' : if isinstance ( ret , list ) : if ret : ret_type = type ( ret [ 0 ] ) . __name__ if ret else "" return _format ( "list of {0}; count={1}" , ret_type , len ( ret ) ) return "Empty" ret_type = ty... | Log result return or exception parameter . This method provides varied type of formatting based on the detail_level parameter and the data in ret . |
28,470 | def stage_http_request ( self , conn_id , version , url , target , method , headers , payload ) : if self . enabled and self . http_detail_level is not None and self . httplogger . isEnabledFor ( logging . DEBUG ) : if 'Authorization' in headers : authtype , cred = headers [ 'Authorization' ] . split ( ' ' ) headers [ ... | Log request HTTP information including url headers etc . |
28,471 | def stage_http_response2 ( self , payload ) : if not self . _http_response_version and not payload : return if self . enabled and self . http_detail_level is not None and self . httplogger . isEnabledFor ( logging . DEBUG ) : if self . _http_response_headers : header_str = ' ' . join ( '{0}:{1!r}' . format ( k , v ) fo... | Log complete http response including response1 and payload |
28,472 | def _to_int ( self , val_str ) : val = _integerValue_to_int ( val_str ) if val is None : raise ValueError ( _format ( "The value-mapped {0} has an invalid integer " "representation in a ValueMap entry: {1!A}" , self . _element_str ( ) , val_str ) ) return val | Conver val_str to an integer or raise ValueError |
28,473 | def _element_str ( self ) : if isinstance ( self . element , CIMProperty ) : return _format ( "property {0!A} in class {1!A} (in {2!A})" , self . propname , self . classname , self . namespace ) elif isinstance ( self . element , CIMMethod ) : return _format ( "method {0!A} in class {1!A} (in {2!A})" , self . methodnam... | Return a string that identifies the value - mapped element . |
28,474 | def tovalues ( self , element_value ) : if not isinstance ( element_value , ( six . integer_types , CIMInt ) ) : raise TypeError ( _format ( "The value for value-mapped {0} is not " "integer-typed, but has Python type: {1}" , self . _element_str ( ) , type ( element_value ) ) ) try : return self . _b2v_single_dict [ el... | Return the Values string for an element value based upon this value mapping . |
28,475 | def tobinary ( self , values_str ) : if not isinstance ( values_str , six . string_types ) : raise TypeError ( _format ( "The values string for value-mapped {0} is not " "string-typed, but has Python type: {1}" , self . _element_str ( ) , type ( values_str ) ) ) try : return self . _v2b_dict [ values_str ] except KeyEr... | Return the integer value or values for a Values string based upon this value mapping . |
28,476 | def _get_server ( self , server_id ) : if server_id not in self . _servers : raise ValueError ( _format ( "WBEM server {0!A} not known by subscription manager" , server_id ) ) return self . _servers [ server_id ] | Internal method to get the server object given a server_id . |
28,477 | def add_server ( self , server ) : if not isinstance ( server , WBEMServer ) : raise TypeError ( "Server argument of add_server() must be a " "WBEMServer object" ) server_id = server . url if server_id in self . _servers : raise ValueError ( _format ( "WBEM server already known by listener: {0!A}" , server_id ) ) self ... | Register a WBEM server with the subscription manager . This is a prerequisite for adding listener destinations indication filters and indication subscriptions to the server . |
28,478 | def remove_server ( self , server_id ) : server = self . _get_server ( server_id ) if server_id in self . _owned_subscriptions : inst_list = self . _owned_subscriptions [ server_id ] for i in six . moves . range ( len ( inst_list ) - 1 , - 1 , - 1 ) : inst = inst_list [ i ] server . conn . DeleteInstance ( inst . path ... | Remove a registered WBEM server from the subscription manager . This also unregisters listeners from that server and removes all owned indication subscriptions owned indication filters and owned listener destinations . |
28,479 | def remove_all_servers ( self ) : for server_id in list ( self . _servers . keys ( ) ) : self . remove_server ( server_id ) | Remove all registered WBEM servers from the subscription manager . This also unregisters listeners from these servers and removes all owned indication subscriptions owned indication filters and owned listener destinations . |
28,480 | def add_listener_destinations ( self , server_id , listener_urls , owned = True ) : if isinstance ( listener_urls , list ) : dest_insts = [ ] for listener_url in listener_urls : new_dest_insts = self . add_listener_destinations ( server_id , listener_url ) dest_insts . extend ( new_dest_insts ) return dest_insts listen... | Register WBEM listeners to be the target of indications sent by a WBEM server . |
28,481 | def get_owned_destinations ( self , server_id ) : self . _get_server ( server_id ) return list ( self . _owned_destinations [ server_id ] ) | Return the listener destinations in a WBEM server owned by this subscription manager . |
28,482 | def get_all_destinations ( self , server_id ) : server = self . _get_server ( server_id ) return server . conn . EnumerateInstances ( DESTINATION_CLASSNAME , namespace = server . interop_ns ) | Return all listener destinations in a WBEM server . |
28,483 | def remove_destinations ( self , server_id , destination_paths ) : server = self . _get_server ( server_id ) conn_id = server . conn . conn_id if server . conn is not None else None if isinstance ( destination_paths , list ) : for dest_path in destination_paths : self . remove_destinations ( server_id , dest_path ) ret... | Remove listener destinations from a WBEM server by deleting the listener destination instances in the server . |
28,484 | def get_owned_filters ( self , server_id ) : self . _get_server ( server_id ) return list ( self . _owned_filters [ server_id ] ) | Return the indication filters in a WBEM server owned by this subscription manager . |
28,485 | def get_all_filters ( self , server_id ) : server = self . _get_server ( server_id ) return server . conn . EnumerateInstances ( 'CIM_IndicationFilter' , namespace = server . interop_ns ) | Return all indication filters in a WBEM server . |
28,486 | def remove_filter ( self , server_id , filter_path ) : server = self . _get_server ( server_id ) conn_id = server . conn . conn_id if server . conn is not None else None ref_paths = server . conn . ReferenceNames ( filter_path , ResultClass = SUBSCRIPTION_CLASSNAME ) if ref_paths : raise CIMError ( CIM_ERR_FAILED , "Th... | Remove an indication filter from a WBEM server by deleting the indication filter instance in the WBEM server . |
28,487 | def get_owned_subscriptions ( self , server_id ) : self . _get_server ( server_id ) return list ( self . _owned_subscriptions [ server_id ] ) | Return the indication subscriptions in a WBEM server owned by this subscription manager . |
28,488 | def get_all_subscriptions ( self , server_id ) : server = self . _get_server ( server_id ) return server . conn . EnumerateInstances ( SUBSCRIPTION_CLASSNAME , namespace = server . interop_ns ) | Return all indication subscriptions in a WBEM server . |
28,489 | def _create_destination ( self , server_id , dest_url , owned ) : server = self . _get_server ( server_id ) host , port , ssl = parse_url ( dest_url , allow_defaults = False ) schema = 'https' if ssl else 'http' listener_url = '{0}://{1}:{2}' . format ( schema , host , port ) this_host = getfqdn ( ) ownership = "owned"... | Create a listener destination instance in the Interop namespace of a WBEM server and return that instance . |
28,490 | def _create_subscription ( self , server_id , dest_path , filter_path , owned ) : server = self . _get_server ( server_id ) sub_path = CIMInstanceName ( SUBSCRIPTION_CLASSNAME , namespace = server . interop_ns ) sub_inst = CIMInstance ( SUBSCRIPTION_CLASSNAME ) sub_inst . path = sub_path sub_inst [ 'Filter' ] = filter_... | Create an indication subscription instance in the Interop namespace of a WBEM server and return that instance . |
28,491 | def CreateClass ( self , * args , ** kwargs ) : cc = args [ 0 ] if args else kwargs [ 'NewClass' ] namespace = self . getns ( ) try : self . compile_ordered_classnames . append ( cc . classname ) self . classes [ self . default_namespace ] [ cc . classname ] = cc except KeyError : self . classes [ namespace ] = NocaseD... | Override the CreateClass method in MOFWBEMConnection |
28,492 | def _get_class ( self , superclass , namespace = None , local_only = False , include_qualifiers = True , include_classorigin = True ) : return self . GetClass ( superclass , namespace = namespace , local_only = local_only , include_qualifiers = include_qualifiers , include_classorigin = include_classorigin ) | This method is just rename of GetClass to support same method with both MOFWBEMConnection and FakedWBEMConnection |
28,493 | def xml_to_tupletree_sax ( xml_string , meaning , conn_id = None ) : handler = CIMContentHandler ( ) xml_string = _ensure_bytes ( xml_string ) try : xml . sax . parseString ( xml_string , handler , None ) except xml . sax . SAXParseException as exc : org_tb = sys . exc_info ( ) [ 2 ] _chk_str = check_invalid_utf8_seque... | Parse an XML string into tupletree with SAX parser . |
28,494 | def check_invalid_xml_chars ( xml_string , meaning , conn_id = None ) : context_before = 16 context_after = 16 try : assert isinstance ( xml_string , six . text_type ) except AssertionError : raise TypeError ( _format ( "xml_string parameter is not a unicode string, but has " "type {0}" , type ( xml_string ) ) ) ixc_li... | Examine an XML string and raise a pywbem . XMLParseError exception if the string contains characters that cannot legally be represented as XML characters . |
28,495 | def wrapped_spawn ( self , cmdElements , tag ) : import uuid a = uuid . uuid1 ( ) print ( "travis_fold:start:%s-%s" % ( tag , a ) ) try : spawn0 ( self , cmdElements ) finally : print ( "travis_fold:end:%s-%s" % ( tag , a ) ) | wrap spawn with unique - ish travis fold prints |
28,496 | def _build ( self , build_method ) : logger . info ( "building image '%s'" , self . image ) self . ensure_not_built ( ) self . temp_dir = tempfile . mkdtemp ( ) temp_path = os . path . join ( self . temp_dir , BUILD_JSON ) try : with open ( temp_path , 'w' ) as build_json : json . dump ( self . build_args , build_json ... | build image from provided build_args |
28,497 | def _load_results ( self , container_id ) : if self . temp_dir : dt = DockerTasker ( ) results = BuildResults ( ) results . build_logs = dt . logs ( container_id , stream = False ) results . container_id = container_id return results | load results from recent build |
28,498 | def commit_buildroot ( self ) : logger . info ( "committing buildroot" ) self . ensure_is_built ( ) commit_message = "docker build of '%s' (%s)" % ( self . image , self . uri ) self . buildroot_image_name = ImageName ( repo = "buildroot-%s" % self . image , tag = datetime . datetime . now ( ) . strftime ( '%Y-%m-%d-%H-... | create image from buildroot |
28,499 | def create_main_synopsis ( self , parser ) : self . add_usage ( parser . usage , parser . _actions , parser . _mutually_exclusive_groups , prefix = '' ) usage = self . _format_usage ( None , parser . _actions , parser . _mutually_exclusive_groups , '' ) usage = usage . replace ( '%s ' % self . _prog , '' ) usage = '.SH... | create synopsis from main parser |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.