Did I find the right examples for you? yes no

All Samples(14)  |  Call(11)  |  Derive(0)  |  Import(3)
Convert an integer number to a HEX string of length digits 

        def int_to_hex_str(number, digits):
    """ Convert an integer number to a HEX string of length digits """
    hex_str = ('%.' + str(digits) + 'x') % number
    err_msg = "Hex representation of %d doesn't fit in %s digits" % (number, digits)
    assert len(hex_str) <= digits, err_msg
    return hex_str
        


src/c/o/confine-controller-0.10.5/controller/apps/mgmtnetworks/tinc/ifaces.py   confine-controller(Download)
from IPy import IP
 
from controller.settings import MGMT_IPV6_PREFIX
from controller.utils.ip import int_to_hex_str, split_len
from slices.ifaces import BaseIface
    def ipv6_addr(self, iface):
        """ MGMT_IPV6_PREFIX:N:10ii:ssss:ssss:ssss/64 """
        # Hex representation of the needed values
        nr = '10' + int_to_hex_str(iface.nr, 2)
        node_id = int_to_hex_str(iface.sliver.node_id, 4)
        slice_id = int_to_hex_str(iface.sliver.slice_id, 12)

src/c/o/confine-controller-0.10.5/controller/apps/slices/ifaces.py   confine-controller(Download)
from django.core.exceptions import ValidationError
from IPy import IP
 
from controller.settings import DEBUG_IPV6_PREFIX
from controller.utils.ip import int_to_hex_str, split_len
    def ipv6_addr(self, iface):
        """ DEBUG_IPV6_PREFIX:N:10ii:ssss:ssss:ssss """
        # Hex representation of the needed values
        nr = '10' + int_to_hex_str(iface.nr, 2)
        node_id = int_to_hex_str(iface.sliver.node_id, 4)
        slice_id = int_to_hex_str(iface.sliver.slice_id, 12)
    def ipv6_addr(self, iface):
        """ PRIV_IPV6_PREFIX:0:1000:ssss:ssss:ssss/64 """
        # Hex representation of the needed values
        nr = '10' + int_to_hex_str(iface.nr, 2)
        slice_id = int_to_hex_str(iface.sliver.slice_id, 12)

src/c/o/confine-controller-0.10.5/controller/apps/mgmtnetworks/tinc/models.py   confine-controller(Download)
from controller.models.fields import RSAPublicKeyField
from controller.models.utils import generate_chainer_manager
from controller.utils.ip import split_len, int_to_hex_str
from controller.core.validators import validate_host_name, validate_name, OrValidator
from nodes.models import Server, Node
            # MGMT_IPV6_PREFIX:0:0001:gggg:gggg:gggg/128
            ipv6_words.extend(['0', '0001'])
            ipv6_words.extend(split_len(int_to_hex_str(self.object_id, 12), 4))
            return IP(':'.join(ipv6_words))
 
        if self.content_type.model == 'node':
            # MGMT_IPV6_PREFIX:N:0000::2/64 i
            ipv6_words.append(int_to_hex_str(self.object_id, 4))
            return IP(':'.join(ipv6_words) + '::2')
        elif self.content_type.model == 'host':
            # MGMT_IPV6_PREFIX:0:2000:hhhh:hhhh:hhhh/128
            ipv6_words.extend(['0', '2000'])
            ipv6_words.extend(split_len(int_to_hex_str(self.object_id, 12), 4))