예제 #1
0
def main():
    parser = argparse.ArgumentParser(description=DESCRIPTION)
    parser.add_argument("hostname", nargs='?',
                        help="hostname to resolve as ip (can be empty)")
    args = parser.parse_args()
    if args.hostname is None:
        res = get_real_ip()
    else:
        res = get_ip_for_hostname(args.hostname)
    if res is not None:
        print(res)
    else:
        sys.exit(1)
예제 #2
0
def main():
    parser = argparse.ArgumentParser(description=DESCRIPTION)
    parser.add_argument("hostname",
                        nargs='?',
                        help="hostname to resolve as ip (can be empty)")
    args = parser.parse_args()
    if args.hostname is None:
        res = get_real_ip()
    else:
        res = get_ip_for_hostname(args.hostname)
    if res is not None:
        print(res)
    else:
        sys.exit(1)
예제 #3
0
 def test_get_ip_for_hostname(self):
     tmp = get_ip_for_hostname(socket.gethostname())
     self.assertTrue("." in tmp)
     self.assertTrue(isinstance(tmp, str))
예제 #4
0
 def test_get_ip_for_hostname_not_found(self):
     tmp = get_ip_for_hostname("foo.bar")
     self.assertTrue(tmp is None)
예제 #5
0
 def test_get_ip_for_hostname_localhost(self):
     tmp = get_ip_for_hostname("localhost")
     self.assertEquals(tmp, "127.0.0.1")
     self.assertTrue(isinstance(tmp, str))
예제 #6
0
 def test_get_ip_for_hostname_auto(self):
     tmp = get_ip_for_hostname("AUTO")
     self.assertEquals(tmp, "AUTO")
     self.assertTrue(isinstance(tmp, str))
예제 #7
0
파일: test_net.py 프로젝트: frdcms/mfcom
 def test_get_ip_for_hostname(self):
     tmp = get_ip_for_hostname(socket.gethostname())
     self.assertTrue("." in tmp)
     self.assertTrue(isinstance(tmp, str))
예제 #8
0
파일: test_net.py 프로젝트: frdcms/mfcom
 def test_get_ip_for_hostname_not_found(self):
     tmp = get_ip_for_hostname("foo.bar")
     self.assertTrue(tmp is None)
예제 #9
0
파일: test_net.py 프로젝트: frdcms/mfcom
 def test_get_ip_for_hostname_localhost(self):
     tmp = get_ip_for_hostname("localhost")
     self.assertEquals(tmp, "127.0.0.1")
     self.assertTrue(isinstance(tmp, str))
예제 #10
0
파일: test_net.py 프로젝트: frdcms/mfcom
 def test_get_ip_for_hostname_auto(self):
     tmp = get_ip_for_hostname("AUTO")
     self.assertEquals(tmp, "AUTO")
     self.assertTrue(isinstance(tmp, str))