#coding: utf-8 import public,re class projectBase: def check_port(self, port): ''' @name 检查端口是否被占用 @args port:端口号 @return: 被占用返回True,否则返回False @author: lkq 2021-08-28 ''' a = public.ExecShell("netstat -nltp|awk '{print $4}'") if a[0]: if re.search(':' + port + '\n', a[0]): return True else: return False else: return False def is_domain(self, domain): ''' @name 验证域名合法性 @args domain:域名 @return: 合法返回True,否则返回False @author: lkq 2021-08-28 ''' import re domain_regex = re.compile(r'(?:[A-Z0-9_](?:[A-Z0-9-_]{0,247}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,}(?