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

Python utils.is_mac函数代码示例

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

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



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

示例1: test_matching

 def test_matching(self):
     self.assertTrue(utils.is_mac("00:C0:B7:7E:55:50"))
     self.assertTrue(utils.is_mac("00:c0:b7:7E:55:50"))
     self.assertFalse(utils.is_mac("00.D0.B7.7E.55.50"))
     self.assertFalse(utils.is_mac("testsystem0"))
     self.assertTrue(utils.is_ip("127.0.0.1"))
     self.assertTrue(utils.is_ip("192.168.1.1"))
     self.assertFalse(utils.is_ip("00:C0:B7:7E:55:50"))
     self.assertFalse(utils.is_ip("testsystem0"))
开发者ID:bluemutedwisdom,项目名称:cobbler-2.x,代码行数:9,代码来源:test_basic.py


示例2: set_name

    def set_name(self,name):
        """
        Set the name.  If the name is a MAC or IP, and the first MAC and/or IP is not defined, go ahead
        and fill that value in.  
        """

        if self.name not in ["",None] and self.parent not in ["",None] and self.name == self.parent:
            raise CX(_("self parentage is weird"))
        if not isinstance(name, basestring):
            raise CX(_("name must be a string"))
        for x in name:
            if not x.isalnum() and not x in [ "_", "-", ".", ":", "+" ] :
                raise CX(_("invalid characters in name: %s") % x)

        # Stuff here defaults to eth0. Yes, it's ugly and hardcoded, but so was
        # the default interface behaviour that's now removed. ;)
        # --Jasper Capel
        if utils.is_mac(name):
           intf = self.__get_interface("eth0")
           if intf["mac_address"] == "":
               intf["mac_address"] = name
        elif utils.is_ip(name):
           intf = self.__get_interface("eth0")
           if intf["ip_address"] == "":
               intf["ip_address"] = name
        self.name = name 

        return True
开发者ID:aquette,项目名称:cobbler,代码行数:28,代码来源:item_system.py


示例3: __init__

    def __init__(self, reference_folder=None, screenshot_folder=None,
                 keyword_on_failure='ImageHorizonLibrary.Take A Screenshot'):
        '''ImageHorizonLibrary can be imported with several options.

        ``reference_folder`` is path to the folder where all reference images
        are stored. It must be a _valid absolute path_. As the library
        is suite-specific (ie. new instance is created for every suite),
        different suites can have different folders for it's reference images.

        ``screenshot_folder`` is path to the folder where screenshots are
        saved. If not given, screenshots are saved to the current working
        directory.

        ``keyword_on_failure`` is the keyword to be run, when location-related
        keywords fail. If you wish to not take screenshots, use for example
        `BuiltIn.No Operation`. Keyword must however be a valid keyword.
        '''

        self.reference_folder = reference_folder
        self.screenshot_folder = screenshot_folder
        self.keyword_on_failure = keyword_on_failure
        self.open_applications = OrderedDict()
        self.screenshot_counter = 1
        self.is_windows = utils.is_windows()
        self.is_mac = utils.is_mac()
        self.is_linux = utils.is_linux()
开发者ID:Eficode,项目名称:robotframework-imagehorizonlibrary,代码行数:26,代码来源:__init__.py


示例4: set_mac_address

    def set_mac_address(self,address,interface):
        if address == "random":
           address = utils.get_random_mac(self.config.api)

        # FIXME: move duplicate supression code to the object validation
        # functions to take a harder line on supression?
        if address != "" and not str(self.config._settings.allow_duplicate_macs).lower() in [ "1", "y", "yes"]:
           matched = self.config.api.find_items("system", {"mac_address" : address})
           for x in matched:
               if x.name != self.name:
                   raise CX("MAC address duplicated: %s" % address)

        intf = self.__get_interface(interface)
        if address == "" or utils.is_mac(address):
           intf["mac_address"] = address.strip()
           return True
        raise CX(_("invalid format for MAC address (%s)" % address))
开发者ID:aquette,项目名称:cobbler,代码行数:17,代码来源:item_system.py


示例5: set_name

    def set_name(self, name):
        """
        Set the name.  If the name is a MAC or IP, and the first MAC and/or IP is not defined, go ahead
        and fill that value in.
        """

        if self.name not in ["", None] and self.parent not in ["", None] and self.name == self.parent:
            raise CX(_("self parentage is weird"))
        self.validate_name(name)

        # Stuff here defaults to eth0. Yes, it's ugly and hardcoded, but so was
        # the default interface behaviour that's now removed. ;)
        # --Jasper Capel
        if utils.is_mac(name):
            intf = self.__get_interface("eth0")
            if intf["mac_address"] == "":
                intf["mac_address"] = name
        elif utils.is_ip(name):
            intf = self.__get_interface("eth0")
            if intf["ip_address"] == "":
                intf["ip_address"] = name
        self.name = name

        return True
开发者ID:aronparsons,项目名称:cobbler,代码行数:24,代码来源:item_system.py


示例6: set_mac_address

 def set_mac_address(self,address,interface):
     intf = self.__get_interface(interface)
     if address == "" or utils.is_mac(address):
        intf["mac_address"] = address.strip()
        return True
     raise CX(_("invalid format for MAC address (%s)" % address))
开发者ID:imeyer,项目名称:cobbler,代码行数:6,代码来源:item_system.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.is_name_sane函数代码示例发布时间:2022-05-26
下一篇:
Python utils.is_login函数代码示例发布时间: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