utilities class for application server file system

本文介绍了如何在ABAP环境中实现服务器端的文件访问功能。通过详细的步骤和示例,帮助读者理解并掌握这一关键技能。
http://forums.sdn.sap.com/thread.jspa?threadID=1682315
sdn contribution : ABAP Server Side File Access, by Thomas Jung

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/1932
ABAP Server Side File Access
PowerShell 7 环境已加载 (版本: 7.3.6) PowerShell 7 环境已加载 (版本: 7.3.6) PS C:\Users\Administrator\Desktop> # E:\AI_System\core\config_loader.py PS C:\Users\Administrator\Desktop> import sys import: The term 'import' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> import os import: The term 'import' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> import json import: The term 'import' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> from pathlib import Path ParserError: Line | 1 | from pathlib import Path | ~~~~ | The 'from' keyword is not supported in this version of the language. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> class ConfigLoader: >> def __init__(self, config_dir=None): ParserError: Line | 2 | def __init__(self, config_dir=None): | ~ | Missing 'class' body in 'class' declaration. PS C:\Users\Administrator\Desktop> # 设置默认配置目录 PS C:\Users\Administrator\Desktop> if not config_dir: ParserError: Line | 1 | if not config_dir: | ~ | Missing '(' after 'if' in if statement. PS C:\Users\Administrator\Desktop> config_dir = Path(__file__).resolve().parent.parent / "config" __file__: The term '__file__' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> self.config_dir = Path(config_dir) config_dir: The term 'config_dir' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> self.configs = {} self.configs: The term 'self.configs' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> def load_config(self, config_name): ParserError: Line | 1 | def load_config(self, config_name): | ~ | Missing argument in parameter list. PS C:\Users\Administrator\Desktop> """加载指定配置文件""" "加载指定配置文件" PS C:\Users\Administrator\Desktop> # 支持多种文件格式 PS C:\Users\Administrator\Desktop> possible_extensions = [".json", ".yaml", ".yml", ".py"] possible_extensions: The term 'possible_extensions' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> config_path = None config_path: The term 'config_path' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 查找存在的配置文件 PS C:\Users\Administrator\Desktop> for ext in possible_extensions: ParserError: Line | 1 | for ext in possible_extensions: | ~ | Missing opening '(' after keyword 'for'. PS C:\Users\Administrator\Desktop> test_path = self.config_dir / f"{config_name}{ext}" test_path: The term 'test_path' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> if test_path.exists(): ParserError: Line | 1 | if test_path.exists(): | ~ | Missing '(' after 'if' in if statement. PS C:\Users\Administrator\Desktop> config_path = test_path config_path: The term 'config_path' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> break PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> if not config_path: ParserError: Line | 1 | if not config_path: | ~ | Missing '(' after 'if' in if statement. PS C:\Users\Administrator\Desktop> raise FileNotFoundError(f"配置文件不存在: {config_name} in {self.config_dir}") f配置文件不存在: {config_name} in {self.config_dir}: The term 'f配置文件不存在: {config_name} in {self.config_dir}' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 根据文件类型加载配置 PS C:\Users\Administrator\Desktop> if config_path.suffix == ".json": ParserError: Line | 1 | if config_path.suffix == ".json": | ~ | Missing '(' after 'if' in if statement. PS C:\Users\Administrator\Desktop> with open(config_path, 'r', encoding='utf-8') as f: ParserError: Line | 1 | with open(config_path, 'r', encoding='utf-8') as f: | ~ | Missing argument in parameter list. PS C:\Users\Administrator\Desktop> self.configs[config_name] = json.load(f) f: The term 'f' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> elif config_path.suffix in [".yaml", ".yml"]: elif: The term 'elif' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> try: try:: The term 'try:' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> import yaml import: The term 'import' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> with open(config_path, 'r', encoding='utf-8') as f: ParserError: Line | 1 | with open(config_path, 'r', encoding='utf-8') as f: | ~ | Missing argument in parameter list. PS C:\Users\Administrator\Desktop> self.configs[config_name] = yaml.safe_load(f) f: The term 'f' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> except ImportError: except: The term 'except' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> raise ImportError("请安装 PyYAML 库以支持 YAML 配置") raise: The term 'raise' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> elif config_path.suffix == ".py": elif: The term 'elif' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> # 动态导入 Python 配置文件 PS C:\Users\Administrator\Desktop> spec = importlib.util.spec_from_file_location(config_name, config_path) ParserError: Line | 1 | … spec = importlib.util.spec_from_file_location(config_name, config_ … | ~ | Missing argument in parameter list. PS C:\Users\Administrator\Desktop> module = importlib.util.module_from_spec(spec) spec: The term 'spec' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> spec.loader.exec_module(module) spec.loader.exec_module: The term 'spec.loader.exec_module' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> self.configs[config_name] = module.__dict__ self.configs[config_name]: The term 'self.configs[config_name]' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> return self.configs[config_name] self.configs[config_name]: The term 'self.configs[config_name]' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> def get_config(self, config_name, default=None): ParserError: Line | 1 | def get_config(self, config_name, default=None): | ~ | Missing argument in parameter list. PS C:\Users\Administrator\Desktop> """获取已加载的配置""" "获取已加载的配置" PS C:\Users\Administrator\Desktop> return self.configs.get(config_name, default or {}) ParserError: Line | 1 | return self.configs.get(config_name, default or {}) | ~ | Missing argument in parameter list. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> def reload_config(self, config_name): ParserError: Line | 1 | def reload_config(self, config_name): | ~ | Missing argument in parameter list. PS C:\Users\Administrator\Desktop> """重新加载配置""" "重新加载配置" PS C:\Users\Administrator\Desktop> if config_name in self.configs: ParserError: Line | 1 | if config_name in self.configs: | ~ | Missing '(' after 'if' in if statement. PS C:\Users\Administrator\Desktop> del self.configs[config_name] PS C:\Users\Administrator\Desktop> return self.load_config(config_name) config_name: The term 'config_name' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 创建全局配置加载器实例 PS C:\Users\Administrator\Desktop> config_loader = ConfigLoader() ParserError: Line | 1 | config_loader = ConfigLoader() | ~ | An expression was expected after '('. PS C:\Users\Administrator\Desktop> # E:\AI_System\Start-Server.ps1 PS C:\Users\Administrator\Desktop> param( >> [switch]$DebugMode, >> [int]$Port = 5000, >> [string]$Env = "dev" >> ) PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 1. 设置项目根目录 PS C:\Users\Administrator\Desktop> $projectRoot = $PSScriptRoot PS C:\Users\Administrator\Desktop> Set-Location $projectRoot PS C:\Users\Administrator> PS C:\Users\Administrator> # 2. 激活虚拟环境 PS C:\Users\Administrator> $venvPath = Join-Path $projectRoot "web_ui\.venv" Join-Path: Cannot bind argument to parameter 'Path' because it is an empty string. PS C:\Users\Administrator> if (-not (Test-Path (Join-Path $venvPath "Scripts\Activate.ps1"))) { >> Write-Host "创建虚拟环境..." -ForegroundColor Yellow >> python -m venv $venvPath >> } InvalidOperation: The variable '$venvPath' cannot be retrieved because it has not been set. PS C:\Users\Administrator> PS C:\Users\Administrator> . (Join-Path $venvPath "Scripts\Activate.ps1") InvalidOperation: The variable '$venvPath' cannot be retrieved because it has not been set. PS C:\Users\Administrator> Write-Host "虚拟环境已激活 ($(python --version))" -ForegroundColor Green 虚拟环境已激活 (Python 3.10.10) PS C:\Users\Administrator> PS C:\Users\Administrator> # 3. 安装依赖 PS C:\Users\Administrator> $requirements = Join-Path $projectRoot "requirements.txt" Join-Path: Cannot bind argument to parameter 'Path' because it is an empty string. PS C:\Users\Administrator> if (Test-Path $requirements) { >> pip install -r $requirements >> } InvalidOperation: The variable '$requirements' cannot be retrieved because it has not been set. PS C:\Users\Administrator> PS C:\Users\Administrator> # 4. 设置环境变量 PS C:\Users\Administrator> $env:AI_ENV = $Env PS C:\Users\Administrator> $env:FLASK_APP = "server.py" PS C:\Users\Administrator> $env:FLASK_ENV = if ($DebugMode) { "development" } else { "production" } PS C:\Users\Administrator> PS C:\Users\Administrator> # 5. 启动服务器 PS C:\Users\Administrator> if ($DebugMode) { >> Write-Host "启动调试模式 (端口: $Port)..." -ForegroundColor Cyan >> python -m debugpy --listen 0.0.0.0:$Port -m flask run --port $Port >> } else { >> Write-Host "启动生产模式 (端口: $Port)..." -ForegroundColor Cyan >> python -m flask run --port $Port >> } 启动生产模式 (端口: 5000)... Disabling PyTorch because PyTorch >= 2.1 is required but found 2.0.0 None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used. Traceback (most recent call last): File "E:\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "E:\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "E:\Python310\lib\site-packages\flask\__main__.py", line 3, in <module> main() File "E:\Python310\lib\site-packages\flask\cli.py", line 1131, in main cli.main() File "E:\Python310\lib\site-packages\click\core.py", line 1363, in main rv = self.invoke(ctx) File "E:\Python310\lib\site-packages\click\core.py", line 1830, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "E:\Python310\lib\site-packages\click\core.py", line 1226, in invoke return ctx.invoke(self.callback, **ctx.params) File "E:\Python310\lib\site-packages\click\core.py", line 794, in invoke return callback(*args, **kwargs) File "E:\Python310\lib\site-packages\click\decorators.py", line 93, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "E:\Python310\lib\site-packages\click\core.py", line 794, in invoke return callback(*args, **kwargs) File "E:\Python310\lib\site-packages\flask\cli.py", line 979, in run_command raise e from None File "E:\Python310\lib\site-packages\flask\cli.py", line 963, in run_command app: WSGIApplication = info.load_app() # pyright: ignore File "E:\Python310\lib\site-packages\flask\cli.py", line 349, in load_app app = locate_app(import_name, name) File "E:\Python310\lib\site-packages\flask\cli.py", line 245, in locate_app __import__(module_name) File "C:\Users\Administrator\server.py", line 3, in <module> from transformers import pipeline File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist File "E:\Python310\lib\site-packages\transformers\utils\import_utils.py", line 2292, in __getattr__ module = self._get_module(self._class_to_module[name]) File "E:\Python310\lib\site-packages\transformers\utils\import_utils.py", line 2322, in _get_module raise e File "E:\Python310\lib\site-packages\transformers\utils\import_utils.py", line 2320, in _get_module return importlib.import_module("." + module_name, self.__name__) File "E:\Python310\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "E:\Python310\lib\site-packages\transformers\pipelines\__init__.py", line 29, in <module> from ..models.auto.image_processing_auto import IMAGE_PROCESSOR_MAPPING, AutoImageProcessor File "E:\Python310\lib\site-packages\transformers\models\auto\image_processing_auto.py", line 28, in <module> from ...image_processing_utils_fast import BaseImageProcessorFast File "E:\Python310\lib\site-packages\transformers\image_processing_utils_fast.py", line 43, in <module> from .processing_utils import Unpack File "E:\Python310\lib\site-packages\transformers\processing_utils.py", line 36, in <module> from .audio_utils import load_audio File "E:\Python310\lib\site-packages\transformers\audio_utils.py", line 39, in <module> import soundfile as sf File "E:\Python310\lib\site-packages\soundfile.py", line 212, in <module> _snd = _ffi.dlopen(_explicit_libname) OSError: cannot load library 'libsndfile.dll': error 0x7e PS C:\Users\Administrator> # E:\AI_System\web_ui\server.py PS C:\Users\Administrator> import os import: The term 'import' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> import sys import: The term 'import' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> from pathlib import Path ParserError: Line | 1 | from pathlib import Path | ~~~~ | The 'from' keyword is not supported in this version of the language. PS C:\Users\Administrator> from flask import Flask, jsonify ParserError: Line | 1 | from flask import Flask, jsonify | ~~~~ | The 'from' keyword is not supported in this version of the language. PS C:\Users\Administrator> PS C:\Users\Administrator> # 添加项目根目录到搜索路径 PS C:\Users\Administrator> project_root = Path(__file__).resolve().parent.parent __file__: The term '__file__' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> sys.path.insert(0, str(project_root)) ParserError: Line | 1 | sys.path.insert(0, str(project_root)) | ~ | Missing expression after ','. PS C:\Users\Administrator> PS C:\Users\Administrator> print(f"项目根目录: {project_root}") f项目根目录: {project_root}: The term 'f项目根目录: {project_root}' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> PS C:\Users\Administrator> # 导入配置加载器 PS C:\Users\Administrator> from core.config_loader import config_loader ParserError: Line | 1 | from core.config_loader import config_loader | ~~~~ | The 'from' keyword is not supported in this version of the language. PS C:\Users\Administrator> PS C:\Users\Administrator> app = Flask(__name__) __name__: The term '__name__' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> PS C:\Users\Administrator> # 加载配置 PS C:\Users\Administrator> try: try:: The term 'try:' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> system_config = config_loader.load_config("system_config") system_config: The term 'system_config' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> hardware_config = config_loader.load_config("hardware_config") hardware_config: The term 'hardware_config' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> model_config = config_loader.load_config("model_registry") model_config: The term 'model_config' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> except Exception as e: except: The term 'except' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> print(f"配置加载错误: {e}") f配置加载错误: {e}: The term 'f配置加载错误: {e}' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> system_config = {} system_config: The term 'system_config' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> hardware_config = {} hardware_config: The term 'hardware_config' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> model_config = {} model_config: The term 'model_config' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> PS C:\Users\Administrator> @app.route('/') ParserError: Line | 1 | @app.route('/') | ~~~~ | The splatting operator '@' cannot be used to reference variables in an expression. '@app' can be used only as an | argument to a command. To reference variables in an expression use '$app'. PS C:\Users\Administrator> def index(): ParserError: Line | 1 | def index(): | ~ | An expression was expected after '('. PS C:\Users\Administrator> return jsonify({ >> "status": "running", >> "project_root": str(project_root), >> "system_config": system_config >> }) ParserError: Line | 2 | "status": "running", | ~ | Unexpected token ':' in expression or statement. PS C:\Users\Administrator> PS C:\Users\Administrator> @app.route('/config/<name>') ParserError: Line | 1 | @app.route('/config/<name>') | ~~~~ | The splatting operator '@' cannot be used to reference variables in an expression. '@app' can be used only as an | argument to a command. To reference variables in an expression use '$app'. PS C:\Users\Administrator> def get_config(name): name: The term 'name' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> config = config_loader.get_config(name, {}) ParserError: Line | 1 | config = config_loader.get_config(name, {}) | ~ | Missing argument in parameter list. PS C:\Users\Administrator> return jsonify(config) config: The term 'config' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> PS C:\Users\Administrator> if __name__ == '__main__': ParserError: Line | 1 | if __name__ == '__main__': | ~ | Missing '(' after 'if' in if statement. PS C:\Users\Administrator> port = int(os.getenv('FLASK_PORT', 5000)) InvalidOperation: The function or command was called as if it were a method. Parameters should be separated by spaces. For information about parameters, see the about_Parameters Help topic. PS C:\Users\Administrator> app.run(host='0.0.0.0', port=port) ParserError: Line | 1 | app.run(host='0.0.0.0', port=port) | ~ | Missing argument in parameter list. PS C:\Users\Administrator> # 创建启动脚本 PS C:\Users\Administrator> $startScript = @' >> param( >> [switch]$DebugMode, >> [int]$Port = 5000, >> [string]$Env = "dev" >> ) >> >> $projectRoot = $PSScriptRoot >> Set-Location $projectRoot >> >> # ... 完整脚本内容 ... >> '@ PS C:\Users\Administrator> PS C:\Users\Administrator> Set-Content -Path "E:\AI_System\Start-Server.ps1" -Value $startScript -Encoding UTF8 PS C:\Users\Administrator> PS C:\Users\Administrator> # 创建快捷函数 PS C:\Users\Administrator> function Start-AIServer { >> param( >> [switch]$Debug, >> [int]$Port = 5000 >> ) >> >> & "E:\AI_System\Start-Server.ps1" -DebugMode:$Debug -Port $Port >> } PS C:\Users\Administrator> PS C:\Users\Administrator> # 添加到配置文件 PS C:\Users\Administrator> $profileContent = @" >> # AI 系统快捷命令 >> function Start-AIServer { >> param([switch]`$Debug, [int]`$Port = 5000) >> & "E:\AI_System\Start-Server.ps1" -DebugMode:`$Debug -Port `$Port >> } >> >> Set-Alias aistart Start-AIServer >> "@ PS C:\Users\Administrator> PS C:\Users\Administrator> Add-Content -Path $PROFILE -Value $profileContent -Encoding UTF8 PS C:\Users\Administrator> # 1. 打开 PowerShell PS C:\Users\Administrator> & "$env:ProgramFiles\PowerShell\7\pwsh.exe" PowerShell 7.3.6 A new PowerShell stable release is available: v7.5.2 Upgrade now, or check out the release page at: https://aka.ms/PowerShell-Release?tag=v7.5.2 PowerShell 7 环境已加载 (版本: 7.3.6) PS C:\Users\Administrator> # 热重载配置 PS C:\Users\Administrator> @app.route('/reload/<name>') ParserError: Line | 1 | @app.route('/reload/<name>') | ~~~~ | The splatting operator '@' cannot be used to reference variables in an expression. '@app' can be used only as an | argument to a command. To reference variables in an expression use '$app'. PS C:\Users\Administrator> def reload_config(name): name: The term 'name' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> try: try:: The term 'try:' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> config_loader.reload_config(name) name: The term 'name' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> return jsonify({"status": "success", "config": name}) ParserError: Line | 1 | return jsonify({"status": "success", "config": name}) | ~ | Unexpected token ':' in expression or statement. PS C:\Users\Administrator> except Exception as e: except: The term 'except' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> return jsonify({"status": "error", "message": str(e)}), 500 ParserError: Line | 1 | return jsonify({"status": "error", "message": str(e)}), 500 | ~ | Unexpected token ':' in expression or statement. PS C:\Users\Administrator> # 根据环境加载不同配置 PS C:\Users\Administrator> env = os.getenv("AI_ENV", "dev") env: The term 'env' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> config_loader.load_config(f"system_config_{env}") fsystem_config_{env}: The term 'fsystem_config_{env}' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> # 配置回退机制 PS C:\Users\Administrator> try: try:: The term 'try:' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> model_config = config_loader.load_config("model_registry") model_config: The term 'model_config' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> except FileNotFoundError: except: The term 'except' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator> model_config = config_loader.load_config("default_model_registry") model_config: The term 'model_config' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. PS C:\Users\Administrator>
08-24
[user@localhost sqlite-autoconf-3310100]$ sqlite3 --version 3.31.1 2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6 [user@localhost sqlite-autoconf-3310100]$ sqlite --version bash: sqlite: command not found... [user@localhost sqlite-autoconf-3310100]$ yangsuite /home/user/.local/lib/python3.6/site-packages/ysdevices/utilities.py:4: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6. from cryptography.fernet import Fernet ERROR:root:Error in loading YANG Suite app "yangsuite-devices": No module named 'copyable_regex_object' ERROR:root:Error in loading YANG Suite app "yangsuite-yangtree": No module named 'copyable_regex_object' ERROR:root:Error in loading YANG Suite app "yangsuite-netconf": No module named 'copyable_regex_object' Traceback (most recent call last): File "/home/user/.local/bin/yangsuite", line 8, in <module> sys.exit(main()) File "/home/user/.local/lib/python3.6/site-packages/yangsuite/application.py", line 213, in main django.setup() File "/home/user/.local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/user/.local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/home/user/.local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/user/.local/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "/home/user/.local/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in <module> class AbstractBaseUser(models.Model): File "/home/user/.local/lib/python3.6/site-packages/django/db/models/base.py", line 117, in __new__ new_class.add_to_class('_meta', Options(meta, app_label)) File "/home/user/.local/lib/python3.6/site-packages/django/db/models/base.py", line 321, in add_to_class value.contribute_to_class(cls, name) File "/home/user/.local/lib/python3.6/site-packages/django/db/models/options.py", line 204, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "/home/user/.local/lib/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "/home/user/.local/lib/python3.6/site-packages/django/db/utils.py", line 201, in __getitem__ backend = load_backend(db['ENGINE']) File "/home/user/.local/lib/python3.6/site-packages/django/db/utils.py", line 110, in load_backend return import_module('%s.base' % backend_name) File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/home/user/.local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 13, in <module> from sqlite3 import dbapi2 as Database File "/usr/local/lib/python3.6/sqlite3/__init__.py", line 23, in <module> from sqlite3.dbapi2 import * File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module> from _sqlite3 import * ModuleNotFoundError: No module named '_sqlite3'
11-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值