Browse Source

修改配置

gushoubang 4 days ago
parent
commit
60e999d445

+ 0 - 34
encrypt/data_decrypted.json

@@ -1,34 +0,0 @@
-{
-    "db": {
-        "host": "192.168.60.2",
-        "port": "5432",
-        "schema": "vector",
-        "schema_base": "base",
-        "user": "postgres",
-        "password": "postgres",
-        "name": "real3d"
-    },
-    "redis": {
-        "host": "192.168.60.220",
-        "port": 6379,
-        "db": 0
-    },
-    "geoserver": {
-        "url": "http://192.168.60.2:28085/geoserver",
-        "username": "admin",
-        "password": "geoserver",
-        "default_workspace": "demo",
-        "cachestart": "0",
-        "cacheend": "15"
-    },
-    "ftp": {
-        "host": "192.168.60.2",
-        "port": 2021,
-        "username": "user1",
-        "password": "password"
-    },
-    "model": {
-        "viewer_uri": "http://192.168.60.2:8091/website/#model=",
-        "base_uri": "http://192.168.60.2:8090"
-    }
-}

+ 2 - 0
encrypt/siwei_config.json

@@ -1,4 +1,6 @@
 {
+  "host":"http://192.168.60.2",
+  "port": 8090,
   "db": {
     "host": "192.168.60.2",
     "port": "5432",

+ 7 - 6
processing/algs/gdal/DataStorageStatistics.py

@@ -8,6 +8,7 @@ import psycopg2
 import matplotlib.pyplot as plt
 from matplotlib import font_manager
 import numpy as np
+import siwei_config
 
 from PyQt5.QtWidgets import QDialog, QVBoxLayout
 from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
@@ -42,7 +43,7 @@ class DataStorageStatistics(QgsProcessingAlgorithm):
 
     def initAlgorithm(self, config=None):
         self.addParameter(QgsProcessingParameterProviderConnection(
-            self.DATABASE, '数据库连接', 'postgres', defaultValue='192.168.60.2'))
+            self.DATABASE, '数据库连接', 'postgres', defaultValue=siwei_config['db']['host']))
 
         self.addParameter(QgsProcessingParameterDatabaseSchema(
             self.SCHEMA, '模式', connectionParameterName=self.DATABASE, defaultValue='base'))
@@ -58,11 +59,11 @@ class DataStorageStatistics(QgsProcessingAlgorithm):
 
     def processAlgorithm(self, parameters, context, feedback):
         connection_params = {
-            'host': '192.168.60.2',
-            'port': '5432',
-            'dbname': 'real3d',
-            'user': 'postgres',
-            'password': 'postgis'
+            'host': siwei_config['db']['host'],
+            'port': siwei_config['db']['port'],
+            'dbname': siwei_config['db']['name'],
+            'user': siwei_config['db']['user'],
+            'password': siwei_config['db']['password'],
         }
 
         schema = self.parameterAsString(parameters, self.SCHEMA, context)

+ 7 - 6
processing/algs/gdal/ImportOSGBToPostGIS.py

@@ -3,6 +3,7 @@ __date__ = 'May 2025'
 __copyright__ = '(C) 2025, liying'
 
 import uuid
+import siwei_config
 from qgis.core import (
     QgsProcessingAlgorithm,
     QgsProcessingParameterFile,
@@ -48,7 +49,7 @@ class ImportOSGBToPostGIS(QgsProcessingAlgorithm):
             self.DATABASE,
             self.tr('数据库连接'),
             'postgres',
-            defaultValue='192.168.60.2'
+            defaultValue=siwei_config['db']['host']
         ))
 
         self.addParameter(QgsProcessingParameterDatabaseSchema(
@@ -172,11 +173,11 @@ class ImportOSGBToPostGIS(QgsProcessingAlgorithm):
 
         # 连接数据库
         conn_params = {
-            'host': "192.168.60.2",
-            'port': "5432",
-            'dbname': "real3d",
-            'user': "postgres",
-            'password': "postgis"
+            'host': siwei_config['db']['host'],
+            'port': siwei_config['db']['port'],
+            'dbname': siwei_config['db']['name'],
+            'user': siwei_config['db']['user'],
+            'password': siwei_config['db']['password'],
         }
 
         feedback.pushInfo("连接数据库...")

+ 13 - 10
processing/algs/gdal/ImportSingleOSGBToPostGIS.py

@@ -2,11 +2,15 @@ __author__ = 'liying'
 __date__ = 'May 2025'
 __copyright__ = '(C) 2025, liying'
 
-import uuid
 import os
-import psycopg2
+import uuid
 from datetime import datetime
+
+import psycopg2
+import siwei_config
+from processing.tools.PostgreSQL.PostgreSQL import PostgreSQL
 from psycopg2 import sql
+from qgis.PyQt.QtCore import QCoreApplication
 from qgis.core import (
     QgsProcessingAlgorithm,
     QgsProcessingParameterFile,
@@ -18,8 +22,6 @@ from qgis.core import (
     QgsProcessingParameterBoolean,
     QgsProcessingParameterCrs
 )
-from qgis.PyQt.QtCore import QCoreApplication
-from processing.tools.PostgreSQL.PostgreSQL import PostgreSQL
 
 
 class ImportSingleOSGBToPostGIS(QgsProcessingAlgorithm):
@@ -49,7 +51,7 @@ class ImportSingleOSGBToPostGIS(QgsProcessingAlgorithm):
             self.DATABASE,
             self.tr('数据库连接'),
             'postgres',
-            defaultValue='192.168.60.2'
+            defaultValue=siwei_config.CONFIG['db']['host']
         ))
 
         self.addParameter(QgsProcessingParameterDatabaseSchema(
@@ -163,12 +165,13 @@ class ImportSingleOSGBToPostGIS(QgsProcessingAlgorithm):
         else:
             feedback.pushWarning(f"未找到名称为 {resource_catalog} 的BSM值")
 
+        db_config = siwei_config.CONFIG['db']
         conn_params = {
-            'host': "192.168.60.2",
-            'port': "5432",
-            'dbname': "real3d",
-            'user': "postgres",
-            'password': "postgis"
+            'host': db_config['host'],
+            'port': db_config['port'],
+            'dbname': db_config['name'],
+            'user': db_config['user'],
+            'password': db_config['password']
         }
 
         conn = psycopg2.connect(**conn_params)

+ 7 - 6
processing/algs/gdal/ImportTableToPostGIS.py

@@ -4,6 +4,7 @@ __copyright__ = '(C) 2025, liying'
 
 
 import uuid
+import siwei_config
 from qgis.core import (
     QgsProcessingAlgorithm,
     QgsProcessingParameterFile,
@@ -38,7 +39,7 @@ class ImportTableToPostGIS(QgsProcessingAlgorithm):
 
     def initAlgorithm(self, config=None):
         self.addParameter(QgsProcessingParameterProviderConnection(
-            self.DATABASE, '数据库连接', 'postgres', defaultValue='192.168.60.2'))
+            self.DATABASE, '数据库连接', 'postgres', defaultValue=siwei_config['db']['host']))
         self.addParameter(QgsProcessingParameterDatabaseSchema(
             self.SCHEMA, '模式', connectionParameterName=self.DATABASE, defaultValue='base'))
         self.addParameter(QgsProcessingParameterString(
@@ -91,11 +92,11 @@ class ImportTableToPostGIS(QgsProcessingAlgorithm):
         resource_catalog = bsm_result[0][0] if bsm_result else resource_catalog_name
 
         conn_params = {
-            'host': "192.168.60.2",
-            'port': "5432",
-            'dbname': "real3d",
-            'user': "postgres",
-            'password': "postgis"
+            'host': siwei_config['db']['host'],
+            'port': siwei_config['db']['port'],
+            'dbname': siwei_config['db']['name'],
+            'user': siwei_config['db']['user'],
+            'password': siwei_config['db']['password'],
         }
         conn = psycopg2.connect(**conn_params)
         cursor = conn.cursor()

+ 4 - 3
processing/app.py

@@ -4,12 +4,13 @@ import uuid
 import requests
 from PIL import Image
 from io import BytesIO
+import siwei_config
 
 app = Flask(__name__)
 
 # 设置静态文件夹(如果您想指定路径)
 app.config['UPLOAD_FOLDER'] = 'predict/output'
-host = 'http://192.168.60.2'
+host = siwei_config.CONFIG['host']
 
 uploadPath = 'predict/upload/'
 outputPath = 'predict/output/'
@@ -71,7 +72,7 @@ def save_image():
     img1 = data['img1']
     img2 = data['img2']
 
-    response1 = requests.get('http://192.168.60.2' + img1)
+    response1 = requests.get(host + img1)
     if response1.status_code != 200:
         return jsonify({
             "message": "图片1不存在",
@@ -83,7 +84,7 @@ def save_image():
     img1Path = uploadPath + str(uuid.uuid4()) + '.png'
     img1.save(img1Path, format='PNG')
 
-    response2 = requests.get('http://192.168.60.2' + img2)
+    response2 = requests.get(host + img2)
     if response2.status_code != 200:
         return jsonify({
             "message": "图片2不存在",

+ 3 - 1
processing/tools/CustomWebView/Manager.py

@@ -11,6 +11,7 @@ from PyQt5.QtWebChannel import QWebChannel
 import sys
 from requests.auth import HTTPBasicAuth
 from PyQt5.QtCore import QObject
+import siwei_config
 
 # 创建一个QWebEngineProfile实例
 # profile = QWebEngineProfile.defaultProfile()
@@ -18,7 +19,8 @@ from PyQt5.QtCore import QObject
 
 # 创建一个QWebEnginePage实例
 # page = QWebEnginePage(QWebEngineProfile())
-pageURI = 'http://192.168.60.2:8082/index'
+
+pageURI = f"{siwei_config['host']}:{siwei_config['port']}/index"
 
 
 def main():

+ 8 - 9
processing/tools/GeoServer/Geoserver.py

@@ -7,17 +7,16 @@ __revision__ = '1.0'
 
 # inbuilt libraries
 import os
-from typing import List, Optional, Set, Union, Dict, Iterable, Any
 from pathlib import Path
-
+from typing import List, Optional, Set, Dict, Iterable, Any
+import siwei_config
 # third-party libraries
 import requests
-from xmltodict import parse, unparse
-
 # custom functions
 from processing.tools.GeoServer.Calculation_gdal import raster_value
 from processing.tools.GeoServer.Style import catagorize_xml, classified_xml, coverage_style_xml, outline_only_xml
 from processing.tools.GeoServer.supports import prepare_zip_file, is_valid_xml, is_surrounded_by_quotes
+from xmltodict import parse, unparse
 
 default_gridset_name = "WebMercatorQuadx2"  # 默认切片方案
 default_seed_type = "seed"  # 默认切片请求类型 Type can be seed (add tiles), reseed (replace tiles), or truncate (remove tiles)
@@ -65,9 +64,9 @@ class FileReader:
 class Geoserver:
     def __init__(
             self,
-            service_url: str = "http://192.168.60.2:28085/geoserver",  # default deployment url during installation
-            username: str = "admin",  # default username during geoserver installation
-            password: str = "geoserver",  # default password during geoserver installation
+            service_url: str = siwei_config.CONFIG['geoserver']['url'],  # default deployment url during installation
+            username: str = siwei_config.CONFIG['geoserver']['username'],  # default username during geoserver installation
+            password: str = siwei_config.CONFIG['geoserver']['password'],  # default password during geoserver installation
             request_options: Dict[str, Any] = None  # additional parameters to be sent with each request
     ):
         self.service_url = service_url
@@ -416,7 +415,7 @@ class Geoserver:
             return r.json()
         else:
             return None
-            #raise GeoserverException(r.status_code, r.content)
+            # raise GeoserverException(r.status_code, r.content)
 
     def create_layergroup(
             self,
@@ -681,7 +680,7 @@ class Geoserver:
             return "Layer group deleted successfully"
         else:
             return "Layer group deleted successfully"
-            #raise GeoserverException(r.status_code, r.content)
+            # raise GeoserverException(r.status_code, r.content)
 
     def add_layer_to_layergroup(
             self,

+ 1 - 0
processing/tools/PostgreSQL/PgExxcute.py

@@ -6,6 +6,7 @@ __copyright__ = '(C) 2024 by siwei'
 __revision__ = '1.0'
 
 import psycopg2
+import siwei_config
 
 # 配置数据库连接参数并指定schema
 connparams = {