ovos-yaml-editor 0.0.1__tar.gz → 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ovos-yaml-editor might be problematic. Click here for more details.
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/PKG-INFO +1 -1
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/README.md +2 -3
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor/__init__.py +16 -9
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor/version.py +1 -1
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor.egg-info/PKG-INFO +1 -1
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/LICENSE +0 -0
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor.egg-info/SOURCES.txt +0 -0
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor.egg-info/dependency_links.txt +0 -0
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor.egg-info/entry_points.txt +0 -0
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor.egg-info/requires.txt +0 -0
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor.egg-info/top_level.txt +0 -0
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/setup.cfg +0 -0
- {ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/setup.py +0 -0
|
@@ -19,10 +19,9 @@ It allows editing the configuration in two formats:
|
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
22
|
-
1.
|
|
22
|
+
1. Install from pypi:
|
|
23
23
|
```bash
|
|
24
|
-
|
|
25
|
-
pip install ./ovos-yaml-editor
|
|
24
|
+
pip install ovos-yaml-editor
|
|
26
25
|
```
|
|
27
26
|
2. Set up environment variables for authentication:
|
|
28
27
|
```bash
|
|
@@ -17,6 +17,8 @@ PASSWORD = os.getenv("EDITOR_PASSWORD", "password") # Default to "password" if
|
|
|
17
17
|
|
|
18
18
|
security = HTTPBasic()
|
|
19
19
|
|
|
20
|
+
memory_config = Configuration()
|
|
21
|
+
|
|
20
22
|
|
|
21
23
|
def authenticate(credentials: HTTPBasicCredentials = Depends(security)):
|
|
22
24
|
"""Authenticate the user."""
|
|
@@ -280,18 +282,21 @@ async def get_editor(credentials: HTTPBasicCredentials = Depends(authenticate)):
|
|
|
280
282
|
|
|
281
283
|
# Endpoint to get the config as YAML or JSON based on the tab selected
|
|
282
284
|
@app.get("/config/{format}")
|
|
283
|
-
async def get_config(format: str):
|
|
284
|
-
|
|
285
|
+
async def get_config(format: str, credentials: HTTPBasicCredentials = Depends(authenticate)):
|
|
286
|
+
if not credentials:
|
|
287
|
+
return RedirectResponse(url="/login")
|
|
285
288
|
if format == "json":
|
|
286
|
-
return Response(json.dumps(
|
|
289
|
+
return Response(json.dumps(memory_config, indent=2, ensure_ascii=False), media_type="text/plain")
|
|
287
290
|
elif format == "yaml":
|
|
288
|
-
return Response(yaml.dump(dict(
|
|
291
|
+
return Response(yaml.dump(dict(memory_config), default_flow_style=False, sort_keys=False), media_type="text/plain")
|
|
289
292
|
else:
|
|
290
293
|
return {"success": False, "error": "Unsupported format"}
|
|
291
294
|
|
|
292
295
|
|
|
293
296
|
@app.post("/config")
|
|
294
|
-
async def save_config_post(request: Request):
|
|
297
|
+
async def save_config_post(request: Request, credentials: HTTPBasicCredentials = Depends(authenticate)):
|
|
298
|
+
if not credentials:
|
|
299
|
+
return RedirectResponse(url="/login")
|
|
295
300
|
body = await request.json()
|
|
296
301
|
try:
|
|
297
302
|
data = body.get("data", "")
|
|
@@ -309,9 +314,9 @@ async def save_config_post(request: Request):
|
|
|
309
314
|
default_conf = MycroftDefaultConfig()
|
|
310
315
|
for k, v in data.items():
|
|
311
316
|
v2 = default_conf.get(k)
|
|
312
|
-
# only save to file any value that differs from default config
|
|
317
|
+
# only save to file/memory any value that differs from default config
|
|
313
318
|
if v2 is None or v != v2:
|
|
314
|
-
conf[k] = v
|
|
319
|
+
conf[k] = memory_config[k] = v
|
|
315
320
|
conf.store()
|
|
316
321
|
return {"success": True}
|
|
317
322
|
except Exception as e:
|
|
@@ -319,12 +324,14 @@ async def save_config_post(request: Request):
|
|
|
319
324
|
|
|
320
325
|
|
|
321
326
|
@app.post("/config/reset")
|
|
322
|
-
async def reset_config_post(request: Request):
|
|
327
|
+
async def reset_config_post(request: Request, credentials: HTTPBasicCredentials = Depends(authenticate)):
|
|
328
|
+
if not credentials:
|
|
329
|
+
return RedirectResponse(url="/login")
|
|
323
330
|
try:
|
|
324
331
|
conf = LocalConf(USER_CONFIG)
|
|
325
332
|
conf.clear()
|
|
326
333
|
conf.store()
|
|
327
|
-
|
|
334
|
+
memory_config.reset()
|
|
328
335
|
return {"success": True}
|
|
329
336
|
except Exception as e:
|
|
330
337
|
return {"success": False, "error": f"Failed to save config: {e}"}
|
|
File without changes
|
|
File without changes
|
{ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{ovos-yaml-editor-0.0.1 → ovos-yaml-editor-0.0.2}/ovos_yaml_editor.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|