ovos-yaml-editor 0.0.1__py3-none-any.whl → 0.0.2a1__py3-none-any.whl

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.

@@ -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
- config = Configuration()
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(config, indent=2, ensure_ascii=False), media_type="text/plain")
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(config), default_flow_style=False, sort_keys=False), media_type="text/plain")
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
- Configuration.reload()
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}"}
@@ -1,6 +1,6 @@
1
1
  # START_VERSION_BLOCK
2
2
  VERSION_MAJOR = 0
3
3
  VERSION_MINOR = 0
4
- VERSION_BUILD = 1
5
- VERSION_ALPHA = 0
4
+ VERSION_BUILD = 2
5
+ VERSION_ALPHA = 1
6
6
  # END_VERSION_BLOCK
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ovos-yaml-editor
3
- Version: 0.0.1
3
+ Version: 0.0.2a1
4
4
  Summary: Simple YAML editor for OpenVoiceOS with FastAPI backend
5
5
  Home-page: https://github.com/OpenVoiceOS/ovos-yaml-editor
6
6
  Classifier: Programming Language :: Python :: 3
@@ -0,0 +1,8 @@
1
+ ovos_yaml_editor/__init__.py,sha256=oZ7FAIVHKdnqlbgVZHRv5eY5YTlk3VIDsWT0avi3gPc,12073
2
+ ovos_yaml_editor/version.py,sha256=tnwL6H7F2rKiYfzZqG80Wt82MT0mHbzZ38RjwaJcsgs,114
3
+ ovos_yaml_editor-0.0.2a1.dist-info/LICENSE,sha256=5UnMsFEC8cZXbexGu4fwi7ZaVUonwJsLP3S9PCSQL_g,11343
4
+ ovos_yaml_editor-0.0.2a1.dist-info/METADATA,sha256=iFyOwfur6BX9O3h-LPlbrNGEj_E87rYIkuYu49GpuBo,422
5
+ ovos_yaml_editor-0.0.2a1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
6
+ ovos_yaml_editor-0.0.2a1.dist-info/entry_points.txt,sha256=uTYj6XXGR24EOHeq5qvd-vELvv60xskZDLJeF_sL9Gc,59
7
+ ovos_yaml_editor-0.0.2a1.dist-info/top_level.txt,sha256=aN7ejEG-SsqfmLO1HvB86BZ05Nga1Qdo3PdMxJLPRag,17
8
+ ovos_yaml_editor-0.0.2a1.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- ovos_yaml_editor/__init__.py,sha256=vjiYR4OqkTsonaNItUDYhM2_xZ_Ro93rBM4Wp03S0dQ,11643
2
- ovos_yaml_editor/version.py,sha256=2AngvTQ2V0oxKc9NmDOM8rBEoiyaHuChugaM8i13Zu4,114
3
- ovos_yaml_editor-0.0.1.dist-info/LICENSE,sha256=5UnMsFEC8cZXbexGu4fwi7ZaVUonwJsLP3S9PCSQL_g,11343
4
- ovos_yaml_editor-0.0.1.dist-info/METADATA,sha256=XRYVocc3IgOth8k0N3DvcyL7sEE7NH1VVpa6K_q5Ddc,420
5
- ovos_yaml_editor-0.0.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
6
- ovos_yaml_editor-0.0.1.dist-info/entry_points.txt,sha256=uTYj6XXGR24EOHeq5qvd-vELvv60xskZDLJeF_sL9Gc,59
7
- ovos_yaml_editor-0.0.1.dist-info/top_level.txt,sha256=aN7ejEG-SsqfmLO1HvB86BZ05Nga1Qdo3PdMxJLPRag,17
8
- ovos_yaml_editor-0.0.1.dist-info/RECORD,,