Internal method to load the action definitions.

        :param str serviceType: the service type to load
        :param int timeout: the timeout for downloading
484365
def _loadSCPD(self, serviceType, timeout):
        

        if serviceType not in self.__deviceServiceDefinitions.keys():
            raise ValueError("Can not load SCPD, no service type defined for: " + serviceType)

        if "scpdURL" not in self.__deviceServiceDefinitions[serviceType].keys():
            raise ValueError("No SCPD URL defined for: " + serviceType)

        # remove actions for given service type
        self.__deviceSCPD.pop(serviceType, None)

        uri = self.__deviceServiceDefinitions[serviceType]["scpdURL"]

        # setup proxies
        proxies = {}
        if self.__httpsProxy:
            proxies = {"https": self.__httpsProxy}

        if self.__httpProxy:
            proxies = {"http": self.__httpProxy}

        # setup authentication
        auth = None
        if self.__password:
            auth = HTTPDigestAuth(self.__username, self.__password)

        # build the URL
        location = self.__protocol + "://" + self.__hostname + ":" + str(self.port) + uri

        # some devices response differently without a User-Agent
        headers = {"User-Agent": "Mozilla/5.0; SimpleTR64-2"}

        # http request
        request = requests.get(location, auth=auth, proxies=proxies, headers=headers, timeout=timeout,
                               verify=self.__verify)

        if request.status_code != 200:
            errorStr = DeviceTR64._extractErrorString(request)
            raise ValueError('Could not load SCPD for "' + serviceType + '" from ' + location + ': ' +
                             str(request.status_code) + ' - ' + request.reason + " -- " + errorStr)

        data = request.text.encode('utf-8')
        if len(data) == 0:
            return

        # parse XML return
        try:
            root = ET.fromstring(data)
        except Exception as e:
            raise ValueError("Can not parse SCPD content for '" + serviceType + "' from '" + location + "': " + str(e))

        actions = {}
        variableTypes = {}
        variableParameterDict = {}

        # iterate through the full XML tree
        for element in root.getchildren():
            tagName = element.tag.lower()

            # go deeper for action lists
            if tagName.endswith("actionlist"):
                # remember the actions and where a specific variable gets referenced
                self._parseSCPDActions(element, actions, variableParameterDict)

            # go deeper for the variable declarations
            elif tagName.endswith("servicestatetable"):
                self._parseSCPDVariableTypes(element, variableTypes)

        # everything have been parsed now merge the variable declarations into the action parameters
        for name in variableParameterDict.keys():
            if name not in variableTypes.keys():
                raise ValueError("Variable reference in action can not be resolved: " + name)

            # iterate through all arguments where this variable have been referenced
            for argument in variableParameterDict[name]:
                # fill in the type of this variable/argument
                argument["dataType"] = variableTypes[name]["dataType"]

                # if the variable declaration includes a default value add it to the action parameter as well
                if "defaultValue" in variableTypes[name].keys():
                    argument["defaultValue"] = variableTypes[name]["defaultValue"]

        self.__deviceSCPD[serviceType] = actions
999736
public static void logLoadedServices(Logger log, Class<?> type, List<?> services)
    {
        log.info("Loaded [" + services.size() + "] " + type.getName() + " [" + NEWLINE
                    + joinTypeNames(new ArrayList<>(services)) + "]");
    }
66488
public DocServiceBuilder exampleHttpHeaders(Class<?> serviceType, HttpHeaders... exampleHttpHeaders) {
        requireNonNull(serviceType, "serviceType");
        return exampleHttpHeaders(serviceType.getName(), exampleHttpHeaders);
    }
1009879
def service_execution(self, *args, **kwargs):
        
        return self._client.service_execution(*args, scope=self.id, **kwargs)
454165
public static <T> Iterable<T> load(Class<T> serviceType) {
    try {
      BundleContext coreBundle = EhcacheActivator.getCoreBundle();
      return coreBundle.getServiceReferences(serviceType, null).stream().map(coreBundle::getService).collect(toList());
    } catch (InvalidSyntaxException e) {
      throw new AssertionError(e);
    }
  }
1246985
@Override
    public <T> List<T> getServices(final Class<T> serviceType) {
        @SuppressWarnings("unchecked")
        List<T> found = (List<T>) servicesLoaded.get(serviceType);
        if (found != null) {
            return found;
        }

        return loadServices(serviceType);
    }
89936
def _declareTimeoutExceeded(self, ev_data: RestartLogData):
        
        logger.info("Timeout exceeded for {}".format(ev_data.when))
        last = self._actionLog.last_event
        if (last and last.ev_type == RestartLog.Events.failed and
                last.data == ev_data):
            return None

        self._action_failed(ev_data,
                            reason="exceeded restart timeout")

        self._unscheduleAction()
        self._actionFailedCallback()
241935
public SdkClientBuilder connectionCheckoutTimeout(long timeout, TimeUnit unit)
    {
        this.connectionCheckoutTimeoutMs = (int) TimeUnit.MILLISECONDS.convert(timeout, unit);
        return this;
    }
17579
def find_service_by_type(self, service_type):
        
        for service in self._services:
            if service_type == service.type:
                return service
        return None
107602
def get_service_definitions(self, service_type=None):
        
        route_values = {}
        if service_type is not None:
            route_values['serviceType'] = self._serialize.url('service_type', service_type, 'str')
        response = self._send(http_method='GET',
                              location_id='d810a47d-f4f4-4a62-a03f-fa1860585c4c',
                              version='5.0-preview.1',
                              route_values=route_values)
        return self._deserialize('[ServiceDefinition]', self._unwrap_collection(response))
761171
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']

        if len(objects) <= max_obj_cnt:
            eos = u'TRUE'
            context_id = ""
            rtn_inst_names = objects
        else:
            eos = u'FALSE'
            context_id = self._create_contextid()
            # TODO:ks Future. Use the timeout along with response delay. Then
            # user could timeout pulls. This means adding timer test to
            # pulls and close. Timer should be used to close old contexts
            # also.
            self.enumeration_contexts[context_id] = {'pull_type': pull_type,
                                                     'data': objects,
                                                     'namespace': namespace,
                                                     'time': time.clock(),
                                                     'interoptimeout': timeout}
            rtn_inst_names = objects[0:max_obj_cnt]
            del objects[0: max_obj_cnt]

        return self._make_pull_imethod_resp(rtn_inst_names, eos, context_id)
954020
public DocServiceBuilder exampleRequestForMethod(Class<?> serviceType, String methodName,
                                                     Iterable<?> exampleRequests) {
        requireNonNull(serviceType, "serviceType");
        return exampleRequestForMethod(serviceType.getName(), methodName, exampleRequests);
    }
143916
private <T> List<T> loadServices(final Class<T> serviceType) {
        List<T> services = new ArrayList<>();
        try {
            for (T t : ServiceLoader.load(serviceType)) {
                services.add(t);
            }
            services.sort(PriorityAwareServiceProvider::compareServices);
            @SuppressWarnings("unchecked")
            final List<T> previousServices = (List<T>) servicesLoaded.putIfAbsent(serviceType, (List<Object>) services);
            return Collections.unmodifiableList(previousServices != null ? previousServices : services);
        } catch (Exception e) {
            Logger.getLogger(PriorityAwareServiceProvider.class.getName()).log(Level.WARNING,
                    "Error loading services of type " + serviceType, e);
            services.sort(PriorityAwareServiceProvider::compareServices);
            return services;
        }
    }
1305108
public static DatagramPacket getDatagram(String serviceType) {
    StringBuilder sb = new StringBuilder("M-SEARCH * HTTP/1.1\r\n");
    sb.append("HOST: " + SsdpParams.getSsdpMulticastAddress().getHostAddress() + ":" + SsdpParams.getSsdpMulticastPort() + "\r\n");
    sb.append("MAN: \"ssdp:discover\"\r\n");
    sb.append("MX: 3\r\n");
    sb.append("USER-AGENT: Resourcepool SSDP Client\r\n");
    sb.append(serviceType == null ? "ST: ssdp:all\r\n" : "ST: " + serviceType + "\r\n\r\n");
    byte[] content = sb.toString().getBytes(UTF_8);
    return new DatagramPacket(content, content.length, SsdpParams.getSsdpMulticastAddress(), SsdpParams.getSsdpMulticastPort());
  }
212509
def _loadServices(self):
        
        servicesPath = os.path.join(self.path, "service")
        if not os.path.isdir(servicesPath):
            return

        self._scanDirectoryForServices(servicesPath)
1359553
def services_type(loader):
    

    def impl(string):
        t_services = loader.get_models('common.models#Services')
        if set(string) - set("bqtf"):
            raise ValueError
        return t_services(_str=''.join(set(string)))

    return impl
940587
def __register_types(self):
        
        try:
            for entry_point in CINQ_PLUGINS['cloud_inquisitor.plugins.types']['plugins']:
                cls = entry_point.load()
                self.types[ResourceType.get(cls.resource_type).resource_type_id] = cls
                logger.debug('Registered resource type {}'.format(cls.__name__))
        except SQLAlchemyError as ex:
            logger.warning('Failed loading type information: {}'.format(ex))