websoft9/appmanage/api/utils/network.py

22 lines
518 B
Python
Raw Normal View History

2023-02-22 09:14:44 +08:00
import os, io, sys, platform, shutil, time, json, datetime
2023-02-22 17:18:52 +08:00
from api.utils import shell_execute
2023-02-22 09:14:44 +08:00
# 根据依赖文件提供的port判断是否启动
def get_start_port(port):
print("目前检查"+port+"是否被占用")
2023-02-22 17:18:52 +08:00
use_port = port
output = "ok"
while True:
cmd = "netstat -anp|grep "+use_port
output = shell_execute.execute_CommandReturn(cmd)
if output == "":
break
else:
use_port = use_port+1
2023-02-22 09:14:44 +08:00
return use_port
2023-02-22 17:18:52 +08:00
2023-02-22 09:14:44 +08:00