当前位置: 首页>>代码示例>>Python>>正文


Python uuid.getnode函数代码示例

本文整理汇总了Python中uuid.getnode函数的典型用法代码示例。如果您正苦于以下问题:Python getnode函数的具体用法?Python getnode怎么用?Python getnode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getnode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: modified_run

    def modified_run(self):
        import sys

        try:
            try:
                from urllib2 import HTTPHandler, build_opener
                from urllib2 import urlopen, Request
                from urllib import urlencode
            except ImportError:
                from urllib.request import HTTPHandler, build_opener
                from urllib.request import urlopen, Request
                from urllib.parse import urlencode

            os_ver = platform.system()
            py_ver = "_".join(str(x) for x in sys.version_info)
            now_ver = __version__.replace(".", "_")

            code = "os:{0},py:{1},now:{2}".format(os_ver, py_ver, now_ver)
            action = command_subclass.action
            cid = getnode()
            payload = {"v": "1", "tid": "UA-61791314-1", "cid": str(cid), "t": "event", "ec": action, "ea": code}

            url = "http://www.google-analytics.com/collect"
            data = urlencode(payload).encode("utf-8")
            request = Request(url, data=data)
            request.get_method = lambda: "POST"
            connection = urlopen(request)
        except:
            pass
        orig_run(self)
开发者ID:hugobowne,项目名称:noworkflow,代码行数:30,代码来源:setup.py

示例2: OSError

def machine_id:
	# If uuid.getnode() fails to get a valid MAC-adress it returns a random number. 
	# The function is run twice to check for this.
	id = uuid.getnode() 
	if id == uuid.getnode():
		return id
	else raise OSError('machine_id: No MAC-address found')
开发者ID:project6381,项目名称:andetvei,代码行数:7,代码来源:machine_id.py

示例3: getMacAddress

 def getMacAddress(self):
   mac = uuid.getnode()
   if uuid.getnode() == mac:
     mac = ':'.join('%02X' % ((mac >> 8 * i) & 0xff) for i in reversed(xrange(6)))
   else:
     mac = 'UNKNOWN'
   return mac
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:7,代码来源:Facter.py

示例4: write_domogik_configfile

def write_domogik_configfile(advanced_mode, intf):
    # read the sample config file
    newvalues = False
    config = configparser.RawConfigParser()
    config.read( ['/etc/domogik/domogik.cfg.sample'] )
    itf = ['bind_interface', 'interfaces']
    for sect in config.sections():
        info("Starting on section {0}".format(sect))
        if sect != "metrics":
            for item in config.items(sect):
                if item[0] in itf  and not advanced_mode:
                    config.set(sect, item[0], intf)
                    debug("Value {0} in domogik.cfg set to {1}".format(item[0], intf))
                elif is_domogik_advanced(advanced_mode, sect, item[0]):
                    print("- {0} [{1}]: ".format(item[0], item[1])),
                    new_value = sys.stdin.readline().rstrip('\n')
                    if new_value != item[1] and new_value != '':
                        # need to write it to config file
                        config.set(sect, item[0], new_value)
                        newvalues = True

        # manage metrics section
        else:
            config.set(sect, "id", uuid.getnode())   # set an unique id which is hardware dependent
            print("Set [{0}] : {1} = {2}".format(sect, id, uuid.getnode()))
            debug("Value {0} in domogik.cfg > [metrics] set to {1}".format(id, uuid.getnode()))

    # write the config file
    with open('/etc/domogik/domogik.cfg', 'wb') as configfile:
        ok("Writing the config file")
        config.write(configfile)
开发者ID:domogik,项目名称:domogik,代码行数:31,代码来源:install.py

示例5: getBaseInfo

    def getBaseInfo(self):

        #pythoncom.CoInitialize()

        try:
            

            info={}
            info["infoid"] = str(uuid.uuid1())
            info["machineid"] = str(uuid.getnode())
            info["timestamp"] =  time.strftime("%Y%m%d%H%M%S", time.localtime())
            info["appkey"] = self.AppKey

            hardware = {}         
            hardware["cpu"] = self.getCpus()
            hardware["memory"] = self.getMemory()
            hardware["disk"] = self.getDrives()

            software = {}
            software["os"] = self.getOs()

            info["machineid"] = str(uuid.getnode())
            info["hardware"] = hardware
            info["software"] = software
            return info
        finally:
            #pythoncom.CoUninitialize()
            pass
开发者ID:haijunxiong,项目名称:dstat,代码行数:28,代码来源:baseinfo.py

示例6: test_getnode

    def test_getnode(self):
        node1 = uuid.getnode()
        self.assertTrue(0 < node1 < (1 << 48), '%012x' % node1)

        # Test it again to ensure consistency.
        node2 = uuid.getnode()
        self.assertEqual(node1, node2, '%012x != %012x' % (node1, node2))
开发者ID:Connor124,项目名称:Gran-Theft-Crop-Toe,代码行数:7,代码来源:test_uuid.py

示例7: test_getnode

    def test_getnode(self):
        node1 = uuid.getnode()
        self.check_node(node1, "getnode1")

        # Test it again to ensure consistency.
        node2 = uuid.getnode()
        self.check_node(node2, "getnode2")

        self.assertEqual(node1, node2)
开发者ID:ActiveState,项目名称:php-buildpack-legacy,代码行数:9,代码来源:test_uuid.py

示例8: register

def register(request):
    if request.method == "POST":
        form = EntryForm(request.POST)
        if form.is_valid():
            entry = form.save(commit=False)
            entry.mac = ':'.join(re.findall('..', '%012x' % uuid.getnode()))
            entry.save()
            return redirect('registration.views.thanks')
        
    else:
        mac = ':'.join(re.findall('..', '%012x' % uuid.getnode()))
    return render(request, 'registration/register.html', {'form': EntryForm(), 'mac':mac, 'var':Entry.objects.filter(mac=mac).exists()})
开发者ID:jmkaluzka,项目名称:MACregistration,代码行数:12,代码来源:views.py

示例9: gen_session_hash

def gen_session_hash(user):
    salt = os.urandom(16)
    if PY3:
        key = b''.join([uuid.getnode().to_bytes(), user, time().to_bytes()])
    else:
        key = b''.join([str(uuid.getnode()), user, str(time())])

    s = hashlib.sha1()
    s.update(key)
    s.update(salt)

    return s.digest()
开发者ID:payingattention,项目名称:neurons,代码行数:12,代码来源:session.py

示例10: test_getnode

    def test_getnode(self):
        import sys
        print("""    WARNING: uuid.getnode is unreliable on many platforms.
        It is disabled until the code and/or test can be fixed properly.""", file=sys.__stdout__)
        return

        node1 = uuid.getnode()
        self.check_node(node1, "getnode1")

        # Test it again to ensure consistency.
        node2 = uuid.getnode()
        self.check_node(node2, "getnode2")

        self.assertEqual(node1, node2)
开发者ID:LinkedModernismProject,项目名称:web_code,代码行数:14,代码来源:test_uuid.py

示例11: _get_key_default

def _get_key_default():
    'Uses uuid to get a system identifier.'

    mac_address = uuid.getnode()

    # in accordance with the RFC, the UUID module may return a random
    # number if unable to discover the machine's MAC address. this doesn't
    # make for a very good key.
    if mac_address == uuid.getnode():
        return str(mac_address)
    else:
        # this value is dependent on the computer's hostname. a weak
        import platform
        return os.environ.get('processor_identifier', 'OMG WHERE AM I') + ''.join(platform.uname())
开发者ID:AlexUlrich,项目名称:digsby,代码行数:14,代码来源:sysident.py

示例12: __init__

  def __init__(self):
    """Create an echo gadget.
    """
    device_desc = usb_descriptors.DeviceDescriptor(
        idVendor=usb_constants.VendorID.GOOGLE,
        idProduct=usb_constants.ProductID.GOOGLE_ECHO_GADGET,
        bcdUSB=0x0200,
        iManufacturer=1,
        iProduct=2,
        iSerialNumber=3,
        bcdDevice=0x0100)

    feature = EchoCompositeFeature(
        endpoints=[(0, 4, 0x81, 0x01), (1, 5, 0x82, 0x02), (2, 6, 0x83, 0x03)])

    super(EchoGadget, self).__init__(device_desc, [feature])
    self.AddStringDescriptor(1, 'Google Inc.')
    self.AddStringDescriptor(2, 'Echo Gadget')
    self.AddStringDescriptor(3, '{:06X}'.format(uuid.getnode()))
    self.AddStringDescriptor(4, 'Interrupt Echo')
    self.AddStringDescriptor(5, 'Bulk Echo')
    self.AddStringDescriptor(6, 'Isochronous Echo')

    # Enable Microsoft OS Descriptors for Windows 8 and above.
    self.EnableMicrosoftOSDescriptorsV1(vendor_code=0x01)
    # These are used to force Windows to load WINUSB.SYS for the echo functions.
    self.SetMicrosoftCompatId(0, 'WINUSB')
    self.SetMicrosoftCompatId(1, 'WINUSB')
    self.SetMicrosoftCompatId(2, 'WINUSB')

    self.AddDeviceCapabilityDescriptor(usb_descriptors.ContainerIdDescriptor(
        ContainerID=uuid.uuid4().bytes_le))
开发者ID:Crawping,项目名称:chromium_extract,代码行数:32,代码来源:echo_gadget.py

示例13: handle_system_information

def handle_system_information(username, password):

    mac = uuid.getnode().__str__()
    system = rest_client.get_system_information(mac)
    system_name = None
    # Register a new System if this one isn't recognized
    if system is None:
        hostname = socket.gethostname()
        name_input = raw_input("What do you want to call this system? " +
                               "For example Home, File Server, ect. [%s]: " % hostname)

        name = name_input or hostname
        system_name = rest_client.register_system(RegisterSystem(
            name, mac, hostname, __version__))
        if system_name:
            print("Registered a new system " + name)
        else:
            return (None, None)

    # Login with this new system
    access_token = rest_client.login_user(LoginForm(username, password, mac))

    if access_token is None:
        print("Failed to login with system.")
        return (None, None)

    # If this system is already registered
    if system is not None:
        system_name = system.name
        print("Welcome back! Looks like this box is already registered as " +
              system.name + ".")

    return (access_token, system_name)
开发者ID:pankajps,项目名称:bashhub-client,代码行数:33,代码来源:bashhub_setup.py

示例14: __init__

 def __init__(self):
     super(EarthReaderApp, self).__init__(application_id=APP_ID)
     self.session = Session('er-gtk-{0:x}'.format(uuid.getnode()))
     self.repository = FileSystemRepository(
         '/home/dahlia/Dropbox/Earth Reader')  # FIXME
     self.stage = Stage(self.session, self.repository)
     self.connect('activate', self.on_activate)
开发者ID:earthreader,项目名称:gtk,代码行数:7,代码来源:app.py

示例15: _get_mac

    def _get_mac(self):
        """
        Try to get a unique identified, Some providers may change mac on stop/start
        Use a low timeout to speed up agent start when no meta-data url
        """
        uuid = None
        try:
            import urllib

            socket.setdefaulttimeout(2)
            urlopen = urllib.urlopen("http://169.254.169.254/latest/meta-data/instance-id")
            socket.setdefaulttimeout(10)

            for line in urlopen.readlines():
                if "i-" in line:
                    uuid = hex(line)
            urlopen.close()

        except:
            pass

        # Use network mac
        if not uuid:
            from uuid import getnode
            uuid = getnode()

        return uuid
开发者ID:gonzalo-radio,项目名称:ecm-agent,代码行数:27,代码来源:config.py


注:本文中的uuid.getnode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。