Bladeren bron

取消钉钉状态设置,设置服务器重启机制

maohu 3 weken geleden
bovenliggende
commit
b1510a0db3

+ 3 - 3
Functions/DButilsFunction/__init__.py

@@ -22,9 +22,9 @@ from .createWorkloadtables import createWorkloadtables
 from .createWorkloadtablesFromPg import createWorkloadtablesFromPg
 from .dealLogs import dealLogs
 from .deleteFlight import deleteFlight
-from .dingdingDelete_flight import dingdingDelete_flight
-from .dingdingFlightsts import dingdingFlightsts
-from .dingdinginfoget import dingdinginfoget
+#from .dingdingDelete_flight import dingdingDelete_flight
+#from .dingdingFlightsts import dingdingFlightsts
+#from .dingdinginfoget import dingdinginfoget
 from .flightDB import flightDB
 from .flightplanInsert import FlightPlanInsert
 from .flightsearchInsert import FlightSearchInsert

+ 1 - 1
Functions/DButilsFunction/dingdingDelete_flight.py

@@ -28,7 +28,7 @@ def dingdingDelete_flight(database:flightDB):
                     elif acno not in dmac.keys():
                         dmac[acno] = i[0]
         try:
-            res = requests.post(url="http://124.223.185.200:888/delete_flight/", data=json.dumps(dmac),timeout=5)  # 自己服务器
+            #res = requests.post(url="http://124.223.185.200:888/delete_flight/", data=json.dumps(dmac),timeout=5)  # 自己服务器
             #flightsts = res.json()
             #print(flightsts)
         except Exception as e:

+ 1 - 1
Functions/DButilsFunction/dingdingFlightsts.py

@@ -17,7 +17,7 @@ def dingdingFlightsts(database:flightDB):
         code4 = {"JJDW": 8, "FX": 9, "SJDW": 11, "XJ": 10, "ESDW": 12}
         try:
             #'''
-            resfwq = requests.get(url="http://124.223.185.200:888/search_status/", timeout=10)  # 自己服务器
+            #resfwq = requests.get(url="http://124.223.185.200:888/search_status/", timeout=10)  # 自己服务器
             if resfwq.json() != "":
                 flightsts = resfwq.json()
                 #print(flightsts)

+ 1 - 1
Functions/DButilsFunction/dingdinginfoget.py

@@ -10,7 +10,7 @@ def dingdinginfoget(database:flightDB):
     try:
         infos={}
         try:
-            resfwq = requests.get(url="http://124.223.185.200:4567/get_deal_info/", timeout=10)  # 自己服务器
+            #resfwq = requests.get(url="http://124.223.185.200:4567/get_deal_info/", timeout=10)  # 自己服务器
             if resfwq.json() != "":
                 infos = resfwq.json()
         except Exception as e:

+ 65 - 30
ServerWithJWT.py

@@ -17,7 +17,7 @@ from Functions import utils , DataComputer as DataComputer , ipcall , flaskDBUti
 from Functions.DButilsFunction import flightDB , judge_bc as Judge_bc , initFlightDatabase as InitFlightDatabase , \
     insertTaskDataToTable , sortFlighttime , sortFlighttime2 , checkTFUairplane , \
     createWorkloadtablesFromPg as CreateWorkloadtablesFromPg , \
-    checkFlightAlert , dingdingDelete_flight , dingdingFlightsts , dingdinginfoget , calledChecked as CalledChecked , \
+    checkFlightAlert , calledChecked as CalledChecked , \
     infoConfirm as InfoConfirm , infoConfirm3 as InfoConfirm3 , infoConfirm2 as InfoConfirm2 , \
     maintainAuthCheck as MaintainAuthCheck , \
     checkLoadSingal as CheckLoadSingal , changepassword as Changepassword , postgresql_local , \
@@ -113,7 +113,7 @@ VinB2="328"
 VinB3="328"
 
 SIGNATURE_KEY=b"secret-key-neverout"  # 用于请求签名的密钥
-REQUEST_VALID_DURATION = 10  # 请求有效期(秒)
+REQUEST_VALID_DURATION = 30  # 请求有效期(秒)
 # 获取本地IP地址
 def get_local_ip():
     try:
@@ -125,7 +125,31 @@ def get_local_ip():
     except:
         return socket.gethostbyname(socket.gethostname())
 
+def generate_signature() :
+    """
+    生成请求签名
+    :param data: 请求的JSON数据
+    :return: (时间戳, 签名)
+    """
+
+    # 1. 获取当前Unix时间戳(秒级)
+    timestamp = str(int(time.time()))
+    data = { "timestamp" : timestamp }
+    # 2. 对数据进行JSON序列化,确保排序一致
+    # sort_keys=True 保证键的顺序一致,否则签名会不匹配
+    data_str = json.dumps(data , sort_keys = True).encode('utf-8')
+
+    # 3. 组合数据:数据字符串 + | + 时间戳
+    signature_base = f"{data_str.decode('utf-8')}|{timestamp}".encode('utf-8')
 
+    # 4. 使用HMAC-SHA256算法生成签名
+    signature = hmac.new(
+        SIGNATURE_KEY ,
+        signature_base ,
+        hashlib.sha256
+    ).hexdigest()
+
+    return timestamp , signature
 def verify_request(timestamp , signature , data) :
     """验证请求的合法性"""
     try :
@@ -160,8 +184,14 @@ def verify_request(timestamp , signature , data) :
 def check_a_availability():
     """检查A服务器的可用性"""
     try:
-        ip = "http://" + mainseverip + ":5001/static/health"
-        response = requests.get(ip, timeout=5)
+        timestamp, signature = generate_signature()
+        header = {'Content-Type' : 'application/json',
+                   'X-Timestamp' : timestamp,
+                   'X-Signature' : signature,
+                   }
+        response = requests.get("http://" + mainseverip +  ':5001/static/health' , headers = header)
+        #ip = "http://" + mainseverip + ":5001/static/health"
+        #response = requests.get(ip, timeout=5)
         return response.status_code != 200  #看是否连接成功
     except Exception as e:
         return True  #出问题了
@@ -306,15 +336,20 @@ def get_access_token():
 '''
 
 # 健康检查接口,暂时不做要求,后期做白名单或者删掉
-@app.route('/static/health')
+@app.route('/static/health')  #签名检测
 def health_check():
-    try:
-        # 检查数据库连接
-        db = flaskDBUtils.flaskDB(host=dbhost,port=dbport,user=dbuser,password=dbpassword,database=database)
-        db.close()
-        return jsonify({"status": "ok", "msg":{"timestamp": datetime.datetime.now().isoformat()}}), 200
-    except Exception as e:
-        return jsonify({"status": "error", "msg": str(e)}), 500
+    signature = request.headers.get('X-Signature')
+    timestamp = request.headers.get('X-Timestamp')
+    if verify_request(timestamp,signature, {"timestamp": timestamp}):
+        try:
+            # 检查数据库连接
+            db = flaskDBUtils.flaskDB(host=dbhost,port=dbport,user=dbuser,password=dbpassword,database=database)
+            db.close()
+            return jsonify({"status": "ok", "msg":{"timestamp": datetime.datetime.now().isoformat()}}), 200
+        except Exception as e:
+            return jsonify({"status": "error", "msg": str(e)}), 500
+    else:
+        return jsonify({"status": "error", "msg": "签名验证未通过"}), 401
 @app.route("/map/<selectedtime>/<token>")
 def index(selectedtime,token):
     return render_template("map.html", selectedtime=selectedtime,token=token)
@@ -346,7 +381,7 @@ def loginTable():
         #print(f'处理时间:{t3-t2}')
         return jsonify(msg=(datetime.datetime.now(),"[%s]%s尝试登录失败" %(remote_addr,username)), data=res1), 401
     else:
-        return jsonify(msg=(datetime.datetime.now(),"[%s]%s尝试登录失败" ), data={"返回值":"fail"}), 401
+        return jsonify(msg=(datetime.datetime.now(),"签名验证未通过" ), data={"返回值":"fail"}), 401
 
 @app.route('/static/remoteCheck', methods=['POST']) #操作系统版本验证 #签名检测
 def remoteCheck():
@@ -363,7 +398,7 @@ def remoteCheck():
         return jsonify(res)
     else:
         res = { "返回值" : "签名验证未通过" }
-        return jsonify(res)
+        return jsonify(res), 401
 
 @app.route('/static/remoteCheck2', methods=['POST']) #电子白板系统版本验证#签名检测
 def remoteCheck2():
@@ -380,7 +415,7 @@ def remoteCheck2():
         return jsonify(res)
     else:
         res = { "返回值" : "签名验证未通过" }
-        return jsonify(res)
+        return jsonify(res), 401
 
 @app.route('/bakupdata')#签名检测
 def bakupdata():
@@ -394,7 +429,7 @@ def bakupdata():
         print(datetime.datetime.now(), "[%s]5分钟间隔自动备份"%remote_addr)
         return jsonify(status="ok")
     else:
-        return jsonify(status="fail",msg= '签名验证失败')
+        return jsonify(status="fail",msg= '签名验证失败'), 401
 
 @app.route('/postgresql')#签名检测
 def postgresql():
@@ -434,7 +469,7 @@ def postgresql():
             print(traceback.format_exc())
             return jsonify(status="fail", msg=("[返回为fail]远端显示中心计算请求失败"))
     else:
-        return jsonify(status="fail",msg= '签名验证失败')
+        return jsonify(status="fail",msg= '签名验证失败'), 401
 
 @app.route('/getFlightData2', methods=['POST'])#签名检测
 async def getFlightData2():
@@ -523,9 +558,9 @@ async def getFlightData2():
                             checkTFUairplane(fdb,onlinefileDB)
                             checkWorkerlaod_new(fdb,workLoad,nowDayStr,nowDay_1)
                             checkFlightAlert(fdb, singlePeopleNotice)
-                            dingdingDelete_flight(fdb)
-                            dingdingFlightsts(fdb)
-                            dingdinginfoget(fdb)
+                            #dingdingDelete_flight(fdb)
+                            #dingdingFlightsts(fdb)
+                            #dingdinginfoget(fdb)
                             CalledChecked(fdb)
                             if Online_flight_sts == "1" and SameDatabase == "0":
                                 res = UpdatePeopleScheduleFromOnline(fdb, onlinefileDB)
@@ -556,9 +591,9 @@ async def getFlightData2():
                             checkTFUairplane(fdb,onlinefileDB)
                             checkWorkerlaod_new(fdb,workLoad,nowDayStr,nowDay_1)
                             checkFlightAlert(fdb, singlePeopleNotice)
-                            dingdingDelete_flight(fdb)
-                            dingdingFlightsts(fdb)
-                            dingdinginfoget(fdb)
+                            #dingdingDelete_flight(fdb)
+                            #dingdingFlightsts(fdb)
+                            #dingdinginfoget(fdb)
                             CalledChecked(fdb)
                             flaskDBUtils.insertinfolog(db,nowStr,str(taskflightdata['code']))
                             if Online_flight_sts == "1":
@@ -578,9 +613,9 @@ async def getFlightData2():
                     checkTFUairplane(fdb,onlinefileDB)
                     checkWorkerlaod_new(fdb,workLoad,nowDayStr,nowDay_1)
                     checkFlightAlert(fdb, singlePeopleNotice)
-                    dingdingDelete_flight(fdb)
-                    dingdingFlightsts(fdb)
-                    dingdinginfoget(fdb)
+                    #dingdingDelete_flight(fdb)
+                    #dingdingFlightsts(fdb)
+                    #dingdinginfoget(fdb)
                     CalledChecked(fdb)
                     if Online_flight_sts == "1" and SameDatabase == "0":
                         res=UpdatePeopleScheduleFromOnline(fdb, onlinefileDB)
@@ -655,7 +690,7 @@ async def getFlightData2():
             else:
                 return "200"
     else:
-        return jsonify(code='未登录',msg= '签名验证失败')
+        return jsonify(code='未登录',msg= '签名验证失败'), 401
 @app.route('/static/linktest')#签名检测
 def linktest():
     signature = request.headers.get('X-Signature')
@@ -663,7 +698,7 @@ def linktest():
     if verify_request(timestamp , signature , { "timestamp": timestamp}) :
         return jsonify(status="ok", msg="linktest")
     else:
-        return jsonify(status="fail",msg= '签名验证失败')
+        return jsonify(status="fail",msg= '签名验证失败'), 401
 
 @app.route('/checkLogin')#签名检测
 def checkLogin():
@@ -696,7 +731,7 @@ def checkLogin():
         else:
             return jsonify(code="0", msg="登录超时")
     else:
-        return jsonify(code="0",msg= '签名验证失败')
+        return jsonify(code="0",msg= '签名验证失败'), 401
 @app.route('/table')#签名检测
 def table():
 
@@ -720,7 +755,7 @@ def table():
         else:
             return jsonify({"data":[],'msg':"无数据"})
     else:
-        return jsonify({"data":[],'msg':"签名验证失败"})
+        return jsonify({"data":[],'msg':"签名验证失败"}), 401
 
 #------------------------------------------------------------------------------------------------
 #受保护的路由

+ 1 - 0
config.ini

@@ -7,6 +7,7 @@ local_port = 9527
 online_host = 192.168.2.53
 #online_host = 222.209.89.138
 online_port =9527
+#online_port =9328
 flightdb4 = flightDB
 UserLoginDatabase = UserLoginDatabase
 databasefileDB=fileDB

+ 140 - 61
scheduleCenter.py

@@ -1,14 +1,27 @@
+import asyncio
 import datetime
 import json
 import time
 import hashlib
+import os
+import win32api
 import hmac
 from concurrent.futures import ThreadPoolExecutor as ConcurrentThreadPoolExecutor
 import requests
 from apscheduler.events import EVENT_JOB_EXECUTED , EVENT_JOB_ERROR
 from apscheduler.executors.pool import ThreadPoolExecutor , ProcessPoolExecutor
 from apscheduler.schedulers.background import BlockingScheduler
-
+from unitls.settings import softVersion
+oldVersion,nowVersion=softVersion()
+current_path = os.getcwd()
+if nowVersion:
+    path = os.path.join(current_path,nowVersion)
+else:
+    path=None
+#oldVersion="ServerWithJWT.exe"
+#nowVersion="ServerWithJWT.exe"
+#path=os.path.join("D:\\flightinfoV3_sever\dist\ServerWithJWT.exe")
+print(path)
 # 配置执行器
 executors = {
     'default': ThreadPoolExecutor(20),  # 默认线程池,20个线程
@@ -29,7 +42,41 @@ scheduler = BlockingScheduler(
     timezone='Asia/Shanghai'
 )
 SIGNATURE_KEY=b"secret-key-neverout"  # 用于请求签名的密钥
-
+RestartSts=False
+
+def restart():
+    global RestartSts
+    if not RestartSts:
+        RestartSts=True
+        print(f"【{datetime.datetime.now()}】尝试关闭服务器")
+        try:
+            if oldVersion:
+                os.system("taskkill /F /IM %s" % oldVersion)
+                print(f"【{datetime.datetime.now()}】旧版关闭服务器成功")
+            else:
+                print(f"【{datetime.datetime.now()}】旧版服务器未设置,暂不关闭")
+        except:
+            print(f"【{datetime.datetime.now()}】尝试关闭旧版服务器失败")
+        try:
+            if nowVersion:
+                os.system("taskkill /F /IM %s" % nowVersion)
+                print(f"【{datetime.datetime.now()}】新版关闭服务器成功")
+            else:
+                print(f"【{datetime.datetime.now()}】新版服务器未设置,暂不关闭")
+        except:
+            print(f"【{datetime.datetime.now()}】尝试关闭新版服务器失败")
+        print(f"【{datetime.datetime.now()}】尝试重启服务器")
+        try:
+            if path:
+                win32api.ShellExecute(0 , 'open' , path , '' , '' , 1)
+                print(f"【{datetime.datetime.now()}】新版启动成功")
+            else:
+                print(f"【{datetime.datetime.now()}】请先设置服务器启动版本")
+        except:
+            print(f"【{datetime.datetime.now()}】新版服务器启动失败")
+        time.sleep(30)
+        RestartSts=False
+        print(f"【{datetime.datetime.now()}】重启环节结束")
 def generate_signature() :
     """
     生成请求签名
@@ -84,72 +131,103 @@ def handle_flight_data_request(req_type):
         print(f"【{datetime.datetime.now()}】{req_type} 请求执行异常: {str(e)}")
 
 def getflightdata():
-    #print('getflightdata time:{}'.format(datetime.datetime.now()))
-    global num
-    """IO密集型任务,使用默认线程池"""
-
-    timestamp , signature = generate_signature()
-    header = {'Content-Type': 'application/json',
-                'X-Timestamp': timestamp,
-                'X-Signature': signature,
-                }
-    response = requests.get(url+'/checkLogin', headers=header)
-    print(f"【{datetime.datetime.now()}】检查账号登录情况;结果为:{response.json()['code']}{response.json()['msg']}")
-    if response.json()['code'] == "0":
-        print(f"【{datetime.datetime.now()}】AMRO未登录")
-    else:
-        with ConcurrentThreadPoolExecutor(max_workers = 2) as executor :
-            if num > 2 :
-                # 异步执行A请求
-                executor.submit(handle_flight_data_request, 'A')
-                print(f"【{datetime.datetime.now()}】A刷新请求;")
+    try:
+        #print('getflightdata time:{}'.format(datetime.datetime.now()))
+        global num
+        """IO密集型任务,使用默认线程池"""
+
+        timestamp , signature = generate_signature()
+        header = {'Content-Type': 'application/json',
+                    'X-Timestamp': timestamp,
+                    'X-Signature': signature,
+                    }
+        response = requests.get(url+'/checkLogin', headers=header)
+        print(f"【{datetime.datetime.now()}】检查账号登录情况;结果为:{response.json()['code']}{response.json()['msg']}")
+        if response.json()['code'] == "0":
+            print(f"【{datetime.datetime.now()}】AMRO未登录")
+        else:
+            with ConcurrentThreadPoolExecutor(max_workers = 2) as executor :
+                if num > 2 :
+                    # 异步执行A请求
+                    executor.submit(handle_flight_data_request, 'A')
+                    print(f"【{datetime.datetime.now()}】A刷新请求;")
+                    num = 1
+                else:
+                    # 异步执行B请求
+                    executor.submit(handle_flight_data_request, 'B')
+                    print(f"【{datetime.datetime.now()}】B刷新请求;")
+                    num += 1
+            '''
+            if num >2:
+                getFlightDataA = requests.post(url+'/getFlightData2', data=json.dumps({'type':'A'}),headers=headers)
+                # result = getFlightDataA.json()
+                print(f"【{datetime.datetime.now()}】A 请求刷新;结果:{getFlightDataA.json()}")
                 num = 1
             else:
-                # 异步执行B请求
-                executor.submit(handle_flight_data_request, 'B')
-                print(f"【{datetime.datetime.now()}】B刷新请求;")
+                getFlightDataB = requests.post(url+'/getFlightData2', data=json.dumps({'type':'B'}),headers=headers)
+                print(f"【{datetime.datetime.now()}】B 请求刷新;结果:{getFlightDataB.json()}")
                 num += 1
-        '''
-        if num >2:
-            getFlightDataA = requests.post(url+'/getFlightData2', data=json.dumps({'type':'A'}),headers=headers)
-            # result = getFlightDataA.json()
-            print(f"【{datetime.datetime.now()}】A 请求刷新;结果:{getFlightDataA.json()}")
-            num = 1
-        else:
-            getFlightDataB = requests.post(url+'/getFlightData2', data=json.dumps({'type':'B'}),headers=headers)
-            print(f"【{datetime.datetime.now()}】B 请求刷新;结果:{getFlightDataB.json()}")
-            num += 1
-'''
+            '''
+    except:
+         pass
 def getTable():
-    timestamp , signature = generate_signature()
-    header = {'Content-Type': 'application/json',
-                'X-Timestamp': timestamp,
-                'X-Signature': signature,
-                }
-    response = requests.get(url+'/table', headers=header)
-    print(f"【{datetime.datetime.now()}】最近一次刷新为:{response.json()['data'][-1] if response.json()['data'] else response.json()['msg'] }")
-    #print(result)
-
+    try:
+        timestamp , signature = generate_signature()
+        header = {'Content-Type': 'application/json',
+                    'X-Timestamp': timestamp,
+                    'X-Signature': signature,
+                    }
+        response = requests.get(url+'/table', headers=header)
+        print(f"【{datetime.datetime.now()}】最近一次刷新为:{response.json()['data'][-1] if response.json()['data'] else response.json()['msg'] }")
+        #print(result)
+    except:
+        pass
 def postgresqlCheck():
-    timestamp , signature = generate_signature()
-    header = {'Content-Type': 'application/json',
-                'X-Timestamp': timestamp,
-                'X-Signature': signature,
-                }
-    #print('postgresqlCheck time:{}'.format(datetime.datetime.now()))
-    response = requests.get(url+'/postgresql', headers=header)
-    print(f"【{datetime.datetime.now()}】云端计算请求:{response.json()}")
-    #print(result)
+    try:
+        timestamp , signature = generate_signature()
+        header = {'Content-Type': 'application/json',
+                    'X-Timestamp': timestamp,
+                    'X-Signature': signature,
+                    }
+        #print('postgresqlCheck time:{}'.format(datetime.datetime.now()))
+        response = requests.get(url+'/postgresql', headers=header)
+        print(f"【{datetime.datetime.now()}】云端计算请求:{response.json()}")
+        #print(result)
+    except:
+        pass
 
 def backupdata():
-    timestamp , signature = generate_signature()
-    header = {'Content-Type': 'application/json',
-                'X-Timestamp': timestamp,
-                'X-Signature': signature,
-                }
-    #print('backupdata time:{}'.format(datetime.datetime.now()))
-    response = requests.get(url+'/bakupdata', headers=header)
-    print(f"【{datetime.datetime.now()}】5min备份请求:{response.json()}")
+    try:
+        timestamp , signature = generate_signature()
+        header = {'Content-Type': 'application/json',
+                    'X-Timestamp': timestamp,
+                    'X-Signature': signature,
+                    }
+        #print('backupdata time:{}'.format(datetime.datetime.now()))
+        response = requests.get(url+'/bakupdata', headers=header)
+        print(f"【{datetime.datetime.now()}】5min备份请求:{response.json()}")
+    except:
+        pass
+def health_check():
+
+    try:
+        timestamp , signature = generate_signature()
+        header = {'Content-Type': 'application/json',
+                    'X-Timestamp': timestamp,
+                    'X-Signature': signature,
+                    }
+        #print('backupdata time:{}'.format(datetime.datetime.now()))
+        response = requests.get(url+'/static/health', headers=header)
+        print(f"【{datetime.datetime.now()}】监控请求:{response.json()}")
+        if response.status_code != 200:
+            restart()
+        else:
+            print(f"【{datetime.datetime.now()}】服务正常")
+    except Exception as e:
+        print(f"【{datetime.datetime.now()}】服务异常:{e}")
+        restart()
+
+
 
 def cpu_bound_job():
     """CPU密集型任务,使用进程池"""
@@ -159,6 +237,7 @@ scheduler.add_job(getflightdata, 'interval', seconds=30)
 scheduler.add_job(getTable, 'interval', seconds=60)
 scheduler.add_job(postgresqlCheck, 'interval', seconds=60)
 scheduler.add_job(backupdata, 'interval', minutes=5)
+scheduler.add_job(health_check, 'interval', seconds=10)
 # scheduler.add_job(cpu_bound_job, 'interval', seconds=30, executor='processpool')
 print('开启定时任务')
 scheduler.add_listener(my_listener, EVENT_JOB_EXECUTED | EVENT_JOB_ERROR)

+ 15 - 2
unitls/settings.py

@@ -22,9 +22,9 @@ def writeConfig():
     config = ConfigParser()
     config.add_section('DBserver')
     config.set('DBserver', 'local_host','localhost')
-    config.set('DBserver', 'local_port','9527')
+    config.set('DBserver', 'local_port','9328')
     config.set('DBserver', 'online_host','222.209.89.138')
-    config.set('DBserver', 'online_port','9527')
+    config.set('DBserver', 'online_port','9328')
     config.set('DBserver', 'flightDB4','flightDB4')
     with open(ini_path, 'w',encoding='utf-8') as configfile:
         config.write(configfile)
@@ -65,10 +65,12 @@ def DBServer():
         local_port = config.get('DBserver', 'local_port')
         local_user = "user1"           #config.get('DBserver', 'local_user')
         local_password = "a123456s"    #config.get('DBserver', 'local_password')
+        #local_password = "m6kJzXPMbuMq"    #config.get('DBserver', 'local_password')
         online_host = config.get('DBserver', 'online_host')
         online_port = config.get('DBserver', 'online_port')
         online_user = "user1"            #config.get('DBserver', 'online_user')
         online_password = "a123456s"     #config.get('DBserver', 'online_password')
+        #online_password = "m6kJzXPMbuMq"     #config.get('DBserver', 'online_password')
     else:
         local_host = None
         local_port = None
@@ -179,6 +181,17 @@ def Oline_flight():
         print('Not found Oline_flight')
     return SameDatabase,HighRefreh,Online_flight_sts
 
+def softVersion():
+    config = ConfigParser()
+    config.read(ini_path, encoding='utf-8-sig')
+    if config.has_section('softVersion'):
+        old = config.get('softVersion', 'SameDatabase')
+        now= config.get('softVersion', 'HighRefreh')
+    else:
+        old = None
+        now = None
+        print('Not found softVersion')
+    return old,now
 
 def DataTransferMode():
     config = ConfigParser()