diff --git a/cli/c2 b/cli/c2 new file mode 160000 index 00000000..324c5bc0 --- /dev/null +++ b/cli/c2 @@ -0,0 +1 @@ +Subproject commit 324c5bc05dd27826e863d31f2e3b0caf84878b2c diff --git a/cli/model.py b/cli/model.py index a609b3be..047bd817 100644 --- a/cli/model.py +++ b/cli/model.py @@ -54,9 +54,6 @@ class FileOp: def fileToJson(self, path: str, remark: Optional[str] = "#", separate: Optional[str] = "="): ''' convert file to Json ''' - - print(path) - dict = {} with open(path) as fh: for line in fh: @@ -65,7 +62,8 @@ class FileOp: if line.find(remark) != 0: item, value = line.strip().split(separate, -1) - dict[item] = value + if value != "": + dict[item] = value else: continue fh.close() @@ -81,7 +79,7 @@ class NetOp: def checkPort(self, port: int): '''check the target port's status''' search_key = "port="+str(port) - if str(psutil.net_connections()).find(search_key) != -1: + if str(+psutil.net_connections()).find(search_key) != -1: print(str(port)+" is used") return False else: diff --git a/cli/test.py b/cli/test.py index fd4cd5ab..4da663bc 100644 --- a/cli/test.py +++ b/cli/test.py @@ -1,16 +1,10 @@ -class Card: - def __init__(self, rank, suit): - self.suit = suit - self.rank = rank - self.hard, self.soft = self._points() +import model,re -class NumberCard( Card ): - def _points(self): - return int(self.rank), int(self.rank) - -class AceCard( Card ): - def _points(self): - return 1, 11 +env = {} +fileop=model.FileOp() +env = fileop.fileToJson('c2/.env') + +for key,value in env.items(): + if re.match(pattern,key,re.I) != None: + print(value) -nc=NumberCard(11,12) -print(nc) \ No newline at end of file