Beispiel #1
0
 def check_args(self):
     global ipv4_list
     if arg_handle.get_args('device_count') > 1 and not arg_handle.get_args('self_IP'):
         cprint.error_p(
             "if device count big than 1, self_IP start must assign")
         sys.exit()
     elif arg_handle.get_args('device_count') > 1:
         ipv4s = common_APIs.get_local_ipv4()
         ip_prefix = '.'.join(arg_handle.get_args(
             'self_IP').split('.')[0:-1])
         ip_start = arg_handle.get_args('self_IP').split('.')[-1]
         cprint.notice_p("Start ip: %s" % (ip_start))
         ipv4s = [ip for ip in ipv4s if re.search(
             r'%s' % (ip_prefix), ip) and int(ip.split('.')[-1]) >= int(ip_start)]
         if len(ipv4s) < arg_handle.get_args('device_count'):
             cprint.error_p("Local ips: %d not enough" % (len(ipv4s)))
             sys.exit()
         else:
             ipv4_list = ipv4s
             for ip in ipv4_list:
                 cprint.notice_p("Use Local ip: %s" % (ip))
     else:
         ip = ''
         if arg_handle.get_args('self_IP'):
             ip = arg_handle.get_args('self_IP')
         ipv4_list = [ip]
Beispiel #2
0
    def check_args(self):
        global ipv4_list
        ipv4_list = []

        if arg_handle.get_args('self_IP'):
            ipv4s = common_APIs.get_local_ipv4()
            ip_prefix = '.'.join(
                arg_handle.get_args('self_IP').split('.')[0:-1])
            ip_start = int(arg_handle.get_args('self_IP').split('.')[-1])
            ipv4_list = [
                ip for ip in ipv4s if re.search(r'%s' % (ip_prefix), ip)
                and int(ip.split('.')[-1]) >= ip_start
            ]

            ipv4_list.sort()
            for ipv4 in ipv4_list:
                cprint.notice_p("find ip: " + ipv4)