Auto bind license, uses dynamic if POS is not found

        :param str license_item_id: license id
        :raises LicenseError: binding license failed, possibly no licenses
        :return: None
542556
def bind_license(self, license_item_id=None):
        
        params = {'license_item_id': license_item_id}
        self.make_request(
            LicenseError,
            method='create',
            resource='bind',
            params=params)
805689
def update_license(license_id, **kwargs):
    
    updated_license = pnc_api.licenses.get_specific(id=license_id).content

    for key, value in iteritems(kwargs):
        if value:
            setattr(updated_license, key, value)

    response = utils.checked_api_call(
        pnc_api.licenses,
        'update',
        id=int(license_id),
        body=updated_license)
    if response:
        return utils.format_json(response.content)
1308005
public void postLicense(final License license, final String user, final String password) throws GrapesCommunicationException, AuthenticationException {
        final Client client = getClient(user, password);
        final WebResource resource = client.resource(serverURL).path(RequestUtils.licenseResourcePath());
        final ClientResponse response = resource.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, license);

        client.destroy();
        if(ClientResponse.Status.CREATED.getStatusCode() != response.getStatus()){
            final String message = "Failed to POST license";
            if(LOG.isErrorEnabled()) {
                LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
            }
            throw new GrapesCommunicationException(message, response.getStatus());
        }
    }
1095509
def add_to_cart(item_id):
    
    cart = Cart(session['cart'])
    if cart.change_item(item_id, 'add'):
        session['cart'] = cart.to_dict()
    return list_products()
573897
private function link_license_2_user( $license_id, $user_id ) {
            $license_ids = $this->get_user_linked_license_ids( $user_id );

            if ( in_array( $license_id, $license_ids ) ) {
                // License already linked.
                return;
            }

            $license_ids[] = $license_id;

            $this->set_user_linked_license_ids( $user_id, $license_ids );
        }
564470
public Object displayLicenseFile(InputStream licenseFile, CommandConsole commandConsole) {
        Object e = LicenseUtility.class;
        if (licenseFile != null) {
            e = showLicenseFile(licenseFile, commandConsole);
        }
        if (e != null) {
            commandConsole.printErrorMessage(CommandUtils.getMessage("LICENSE_NOT_FOUND"));
        }
        return e;
    }
991245
def update_license_file(data_dir):
    
    license_file = os.path.join(data_dir, LICENSE_FILENAME)
    temp_dir = tempfile.mkdtemp()
    gh_license_filename = os.path.join(temp_dir, LICENSE_FILENAME)
    try:
        _, headers = urlretrieve(LICENSE_URL, gh_license_filename)
    except IOError as e:
        # Python 2 uses the unhelpful IOError for this. Re-raise as the more
        # appropriate URLError.
        raise URLError(e.strerror)

    with open(gh_license_filename, 'rb') as f:
        github_license = f.read()

    try:
        with open(license_file, 'rb') as f:
            current_license = f.read()
    except (IOError, OSError):
        current_license = b''

    github_digest = hashlib.sha256(github_license).hexdigest()
    current_digest = hashlib.sha256(current_license).hexdigest()

    if github_digest == current_digest:
        return False

    shutil.copyfile(gh_license_filename, license_file)
    shutil.rmtree(temp_dir, ignore_errors=True)
    return True
849807
def select_licence(default_licence = FalkorLib::Config::Bootstrap::DEFAULTS[:metadata][:license],
                       _options = {})
      list_license = FalkorLib::Config::Bootstrap::DEFAULTS[:licenses].keys
      idx = list_license.index(default_licence) unless default_licence.nil?
      select_from(list_license,
                  'Select the license index for this project:',
                  (idx.nil?) ? 1 : idx + 1)
      #licence
    end
377143
def get_existing_item_id(self, api):
        
        resp = api.get_existing_item(self)
        items = resp.json()
        num_items = len(items)
        if num_items == 0:
            return None
        else:
            return items[0]['id']
73381
def license(self, license_id: str, token: dict = None, prot: str = "https") -> dict:
        
        # handling request parameters
        payload = {"lid": license_id}

        # search request
        license_url = "{}://v1.{}.isogeo.com/licenses/{}".format(
            prot, self.api_url, license_id
        )
        license_req = self.get(
            license_url,
            headers=self.header,
            params=payload,
            proxies=self.proxies,
            verify=self.ssl,
        )

        # checking response
        checker.check_api_response(license_req)

        # end of method
        return license_req.json()
1222529
def activate_license(self, key):
        
        root = self._create_dynamic_xml('LICENSE', 'RIB_INFO', 'write')
        element = root.find('LOGIN/RIB_INFO/LICENSE')
        etree.SubElement(element, 'ACTIVATE', KEY=key)
        d = self._request_ilo(root)
        self._parse_output(d)
1295148
def delete(self, item_id):
        
        try:
            response = self._request("tasks/delete/{id}".format(id=item_id))

            if response.status_code == 200:
                return True

        except sandboxapi.SandboxError:
            pass

        return False
749292
def showLicense():
    
    print("Trying to recover the contents of the license...\n")
    try:
        # Grab the license online and print it.
        text = urllib.urlopen(LICENSE_URL).read()
        print("License retrieved from " + emphasis(LICENSE_URL) + ".")
        raw_input("\n\tPress " + emphasis("<ENTER>") + " to print it.\n")
        print(text)
    except:
        print(warning("The license could not be downloaded and printed."))
766558
def save_license(license_code):
  
  desc = _get_license_description(license_code)
  fname = "LICENSE"
  if sys.platform == "win32":
    fname += ".txt"  # Windows and file exts
  with open(os.path.join(os.getcwd(), fname), "w") as afile:
    afile.write(desc)
889923
private License getLicense(final String licenseId) {
        License result = null;
        final Set<DbLicense> matchingLicenses = licenseMatcher.getMatchingLicenses(licenseId);

        if (matchingLicenses.isEmpty()) {
            result = DataModelFactory.createLicense("#" + licenseId + "# (to be identified)", NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET);
            result.setUnknown(true);
        } else {
            if (matchingLicenses.size() > 1 && LOG.isWarnEnabled()) {
                LOG.warn(String.format("%s matches multiple licenses %s. " +
                                "Please run the report showing multiple matching on licenses",
                        licenseId, matchingLicenses.toString()));
            }
            result = mapper.getLicense(matchingLicenses.iterator().next());

        }

        return result;
    }
757579
function _sync_licenses( $site_license_id = false, $blog_id = null ) {
            $this->_logger->entrance();

            $is_network_admin = fs_is_network_admin();

            if ( $is_network_admin && is_null( $blog_id ) ) {
                $all_licenses = self::get_all_licenses( $this->_module_id );
            } else {
                $all_licenses = $this->get_user_licenses( $this->_user->id );
            }

            $foreign_licenses = array(
                'ids'          => array(),
                'license_keys' => array()
            );

            $all_licenses_map = array();
            foreach ( $all_licenses as $license ) {
                $all_licenses_map[ $license->id ] = true;
                if ( $license->user_id == $this->_user->id || $license->id == $site_license_id ) {
                    continue;
                }

                $foreign_licenses['ids'][]          = $license->id;
                $foreign_licenses['license_keys'][] = $license->secret_key;
            }

            if ( empty( $foreign_licenses['ids'] ) ) {
                $foreign_licenses = array();
            }

            $licenses = $this->_fetch_licenses( false, $site_license_id, $foreign_licenses, $blog_id );

            if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) {
                $licenses_map = array();
                foreach ( $licenses as $license ) {
                    $licenses_map[ $license->id ] = true;
                }

//                $license_ids_to_keep = $this->get_license_ids_associated_with_installs();
//                foreach ( $license_ids_to_keep as $license_id ) {
//                    if ( isset( $licenses_map[ $license_id ] ) ) {
//                        continue;
//                    }
//
//                    $missing_license = self::_get_license_by_id( $license_id, false );
//                    if ( is_object( $missing_license ) ) {
//                        $licenses[]                           = $missing_license;
//                        $licenses_map[ $missing_license->id ] = true;
//                    }
//                }

                $user_license_ids = $this->get_user_linked_license_ids( $this->_user->id );

                foreach ( $user_license_ids as $key => $license_id ) {
                    if ( ! isset( $licenses_map[ $license_id ] ) ) {
                        // Remove access to licenses that no longer exist.
                        unset( $user_license_ids[ $key ] );
                    }
                }

                if ( ! empty( $user_license_ids ) ) {
                    foreach ( $licenses_map as $license_id => $value ) {
                        if ( ! isset( $all_licenses_map[ $license_id ] ) ) {
                            // Associate new licenses with the user who triggered the license syncing.
                            $user_license_ids[] = $license_id;
                        }
                    }

                    $user_license_ids = array_unique( $user_license_ids );
                } else {
                    $user_license_ids = array_keys( $licenses_map );
                }

                if ( ! $is_network_admin || ! is_null( $blog_id ) ) {
                    $user_licenses = array();
                    foreach ( $licenses as $license ) {
                        if ( ! in_array( $license->id, $user_license_ids ) ) {
                            continue;
                        }

                        $user_licenses[] = $license;
                    }

                    $this->_licenses = $user_licenses;
                } else {
                    $this->_licenses = $licenses;
                }

                $this->set_user_linked_license_ids( $this->_user->id, $user_license_ids );

                $this->_store_licenses( true, $this->_module_id, $licenses );
            }

            // Update current license.
            if ( is_object( $this->_license ) ) {
                $this->_license = $this->_get_license_by_id( $this->_license->id );
            }

            return $this->_licenses;
        }
315179
def get_license_manager(service_instance):
    '''
    
    '''

    log.debug('Retrieving license manager')
    try:
        lic_manager = service_instance.content.licenseManager
    except vim.fault.NoPermission as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareApiError(
            'Not enough permissions. Required privilege: '
            '{0}'.format(exc.privilegeId))
    except vim.fault.VimFault as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareApiError(exc.msg)
    except vmodl.RuntimeFault as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareRuntimeError(exc.msg)
    return lic_manager