• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python uuid.getnode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __flush__

 def __flush__(self):
     if DEBUG: print "class Experiment_Sync_Group, func __flush__"
     lsx=open(file_locations.file_locations['last_xtsm'][uuid.getnode()]+"last_xtsm.xtsm","w")
     lsx.write(self.last_successful_xtsm)
     lsx.close()
     self.compiled_xtsm.flush()
     self.compiled_xtsm.filestream.__flush__() 
开发者ID:gemelkelabs,项目名称:timing_system_software,代码行数:7,代码来源:experiment_synchronization.py


示例17: send

    def send(self, msg):
        try:
            log = {}
            log['log'] = {}
            log['log']['metadata'] = {}
            log['log']['fields'] = {}
            log['log']['fields']['raw_msg'] = msg

            if self.whitelist:
                log['log']['field_whitelist'] = self.whitelist
            else:
                log['log']['field_whitelist'] = []

            try:
                mac_addr = getnode()
                mac_addr = ':'.join(("%012X" % mac_addr)[i:i+2] for i in range(0, 12, 2))
                log['log']['metadata']['loghost_mac'] = mac_addr
                log['log']['metadata']['loghost_ip'] = socket.gethostbyname(socket.gethostname())
            except:
                pass
            r = requests.post(self.url, json=log)
            if r.status_code == 200:
                return True
            else:
                return False
        except:
            return False
开发者ID:jadacyrus,项目名称:syslog-ng-seclog,代码行数:27,代码来源:seclog_post.py


示例18: save_pangenome_and_report

 def save_pangenome_and_report(self, genome_refs, orthologs):
     self.log_line("Saving pangenome object")
     output_obj_name = self.params["output_pangenome_id"]
     pangenome = {"genome_refs": genome_refs, "id": output_obj_name, "name": 
                  output_obj_name, "orthologs": orthologs, "type": "orthomcl"}
     input_ws_objects = []
     if "input_genomeset_ref" in self.params and self.params["input_genomeset_ref"] is not None:
         input_ws_objects.append(self.params["input_genomeset_ref"])
     if "input_genome_refs" in self.params and self.params["input_genome_refs"] is not None:
         for genome_ref in self.params["input_genome_refs"]:
             if genome_ref is not None:
                 input_ws_objects.append(genome_ref)
     self.provenance[0]["input_ws_objects"] = input_ws_objects
     self.provenance[0]["description"] = "Orthologous groups construction using OrthoMCL tool"
     info = self.ws.save_objects({"workspace": self.params["output_workspace"], "objects":
         [{"type": "KBaseGenomes.Pangenome", "name": output_obj_name, 
           "data": pangenome, "provenance": self.provenance}]})[0]
     pangenome_ref = str(info[6]) + "/" + str(info[0]) + "/" + str(info[4])
     report = "Input genomes: " + str(len(genome_refs)) + "\n" + \
         "Output orthologs: " + str(len(orthologs)) + "\n"
     report_obj = {"objects_created": [{"ref": pangenome_ref, 
         "description": "Pangenome object"}], "text_message": report}
     report_name = "orthomcl_report_" + str(hex(uuid.getnode()))
     report_info = self.ws.save_objects({"workspace": self.params["output_workspace"],
         "objects": [{"type": "KBaseReport.Report", "data": report_obj, 
             "name": report_name, "meta": {}, "hidden": 1, "provenance": self.provenance}]})[0]
     return {"pangenome_ref": pangenome_ref, 
             "report_name": report_name, "report_ref": str(report_info[6]) + "/" + 
             str(report_info[0]) + "/" + str(report_info[4])}
开发者ID:rsutormin,项目名称:PangenomeOrthomcl,代码行数:29,代码来源:PangenomeOrthomclBuilder.py


示例19: handle_exception

    def handle_exception(cls, exc):
        (etype, evalue, tb), canvas = exc
        exception = traceback.format_exception_only(etype, evalue)[-1].strip()
        stacktrace = ''.join(traceback.format_exception(etype, evalue, tb))

        def _find_last_frame(tb):
            while tb.tb_next:
                tb = tb.tb_next
            return tb

        frame = _find_last_frame(tb)
        err_module = '{}:{}'.format(
            frame.tb_frame.f_globals.get('__name__', frame.tb_frame.f_code.co_filename),
            frame.tb_lineno)

        def _find_widget_frame(tb):
            while tb:
                if isinstance(tb.tb_frame.f_locals.get('self'), OWWidget):
                    return tb
                tb = tb.tb_next

        widget_module, widget, frame = None, None, _find_widget_frame(tb)
        if frame:
            widget = frame.tb_frame.f_locals['self'].__class__
            widget_module = '{}:{}'.format(widget.__module__, frame.tb_lineno)

        # If this exact error was already reported in this session,
        # just warn about it
        if (err_module, widget_module) in cls._cache:
            QMessageBox(QMessageBox.Warning, 'Error Encountered',
                        'Error encountered{}:<br><br><tt>{}</tt>'.format(
                            ' in widget <b>{}</b>'.format(widget.name) if widget else '',
                            stacktrace.replace('\n', '<br>').replace(' ', '&nbsp;')),
                        QMessageBox.Ignore).exec()
            return

        F = cls.DataField
        data = OrderedDict()
        data[F.EXCEPTION] = exception
        data[F.MODULE] = err_module
        if widget:
            data[F.WIDGET_NAME] = widget.name
            data[F.WIDGET_MODULE] = widget_module
        if canvas:
            filename = mkstemp(prefix='ows-', suffix='.ows.xml')[1]
            # Prevent excepthook printing the same exception when
            # canvas tries to instantiate the broken widget again
            with patch('sys.excepthook', lambda *_: None):
                canvas.save_scheme_to(canvas.current_document().scheme(), filename)
            data[F.WIDGET_SCHEME] = filename
            with open(filename) as f:
                data['_' + F.WIDGET_SCHEME] = f.read()
        data[F.VERSION] = VERSION_STR
        data[F.ENVIRONMENT] = 'Python {} on {} {} {} {}'.format(
            platform.python_version(), platform.system(), platform.release(),
            platform.version(), platform.machine())
        data[F.MACHINE_ID] = str(uuid.getnode())
        data[F.STACK_TRACE] = stacktrace

        cls(data=data).exec()
开发者ID:tomazc,项目名称:orange3,代码行数:60,代码来源:errorreporting.py


示例20: mac

 def mac(self):
     """
     Get the MAC address of the current container.
     """
     imac = getnode()
     mac = ':'.join(("%012X" % imac)[i:i+2] for i in range(0, 12, 2))
     return mac.lower()
开发者ID:thavel,项目名称:docker-mesh,代码行数:7,代码来源:data.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python uuid.should_receive函数代码示例发布时间:2022-05-26
下一篇:
Python uuid.get_mac函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap