mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-10 01:17:42 +01:00
fix cli.py
reverted back spell check for activation of plugins as metadata package does mix '_' with '-'
This commit is contained in:
parent
22d629c7a8
commit
334e9e7335
5 changed files with 143 additions and 9 deletions
|
@ -1 +1 @@
|
|||
__version__ = "4.0.1.16"
|
||||
__version__ = "4.0.1.17.a2"
|
||||
|
|
|
@ -223,9 +223,9 @@ def plugins_add(package_name):
|
|||
try:
|
||||
p_metadata= metadata(package_name)
|
||||
p_name=p_metadata['Name']
|
||||
if p_name != package_name:
|
||||
print("Error. Package name {} does not exist. Did you mean {}".format(package_name,p_name))
|
||||
installation = False
|
||||
#if p_name != package_name:
|
||||
# print("Error. Package name {} does not exist. Did you mean {}".format(package_name,p_name))
|
||||
# installation = False
|
||||
except Exception as e:
|
||||
print("Error. Package {} cannot be found in installed packages".format(package_name))
|
||||
installation = False
|
||||
|
|
|
@ -269,11 +269,12 @@ class FermentationController:
|
|||
except Exception as e:
|
||||
self.logger.error(e)
|
||||
|
||||
async def update_step(self, id, step):
|
||||
async def update_step(self, id, step: FermenterStep):
|
||||
item = self._find_by_id(id)
|
||||
item = list(map(lambda old: item if old.id == step.id else old, item.steps))
|
||||
item.steps = list(map(lambda old: step if old.id == step.id else old, item.steps))
|
||||
self.save()
|
||||
|
||||
|
||||
async def delete_step(self, id, stepid):
|
||||
item = self._find_by_id(id)
|
||||
item.steps = list(filter(lambda item: item.id != stepid, item.steps))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from cbpi.controller.fermentation_controller import FermentationController
|
||||
from cbpi.api.dataclasses import Fermenter, Step, Props
|
||||
from cbpi.api.dataclasses import Fermenter, Step, Props, FermenterStep
|
||||
from aiohttp import web
|
||||
from cbpi.api import *
|
||||
import logging
|
||||
|
@ -283,3 +283,135 @@ class FermentationHttpEndpoints():
|
|||
data = await request.json()
|
||||
await self.controller.set_target_temp(id,data.get("temp"))
|
||||
return web.Response(status=204)
|
||||
|
||||
@request_mapping(path="/{id}/addstep", method="POST", auth_required=False)
|
||||
async def http_add_step(self, request):
|
||||
|
||||
"""
|
||||
|
||||
---
|
||||
description: Add Fermenterstep
|
||||
tags:
|
||||
- Fermenter
|
||||
parameters:
|
||||
- name: "id"
|
||||
in: "path"
|
||||
description: "Fermenter ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
- in: body
|
||||
name: body
|
||||
description: Create a fermenterstep
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
responses:
|
||||
"200":
|
||||
description: successful operation
|
||||
"""
|
||||
|
||||
data = await request.json()
|
||||
fermenterid= request.match_info['id']
|
||||
step = FermenterStep(name=data.get("name"), props=Props(data.get("props", {})), type=data.get("type"))
|
||||
response_data = await self.controller.create_step(fermenterid,step)
|
||||
return web.json_response(data=response_data.to_dict())
|
||||
|
||||
@request_mapping(path="/{fermenterid}/{stepid}", method="PUT", auth_required=False)
|
||||
async def http_updatestep(self, request):
|
||||
|
||||
"""
|
||||
---
|
||||
description: Update FermenterStep
|
||||
tags:
|
||||
- Fermenter
|
||||
parameters:
|
||||
- name: "fermenterid"
|
||||
in: "path"
|
||||
description: "Fermenter ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
- name: "stepid"
|
||||
in: "path"
|
||||
description: "Step ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
- in: body
|
||||
name: body
|
||||
description: Update a Femrenterstep
|
||||
required: false
|
||||
schema:
|
||||
type: object
|
||||
responses:
|
||||
"200":
|
||||
description: successful operation
|
||||
"""
|
||||
|
||||
data = await request.json()
|
||||
stepid = request.match_info['stepid']
|
||||
fermenterid = request.match_info['fermenterid']
|
||||
step = FermenterStep(stepid, data.get("name"), None, Props(data.get("props", {})), data.get("type"))
|
||||
await self.controller.update_step(fermenterid,step)
|
||||
return web.Response(status=200)
|
||||
|
||||
@request_mapping(path="/{fermenterid}/{stepid}", method="DELETE", auth_required=False)
|
||||
async def http_deletestep(self, request):
|
||||
"""
|
||||
---
|
||||
description: Delete Fermenterstep
|
||||
tags:
|
||||
- Fermenter
|
||||
parameters:
|
||||
- name: "fermenterid"
|
||||
in: "path"
|
||||
description: "Fermenter ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
- name: "stepid"
|
||||
in: "path"
|
||||
description: "Step ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
responses:
|
||||
"204":
|
||||
description: successful operation
|
||||
"""
|
||||
stepid = request.match_info['stepid']
|
||||
fermenterid = request.match_info['fermenterid']
|
||||
await self.controller.delete_step(fermenterid,stepid)
|
||||
return web.Response(status=204)
|
||||
|
||||
@request_mapping(path="/movestep", method="PUT", auth_required=False)
|
||||
async def http_movestep(self, request):
|
||||
|
||||
"""
|
||||
---
|
||||
description: Move Fermenterstep
|
||||
tags:
|
||||
- Fermenter
|
||||
parameters:
|
||||
- in: body
|
||||
name: body
|
||||
description: Created an kettle
|
||||
required: false
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
fermenterid:
|
||||
type: string
|
||||
stepid:
|
||||
type: string
|
||||
direction:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
responses:
|
||||
"204":
|
||||
description: successful operation
|
||||
"""
|
||||
data = await request.json()
|
||||
await self.controller.move_step(data["fermenterid"],data["stepid"], data["direction"])
|
||||
return web.Response(status=204)
|
|
@ -1,3 +1,4 @@
|
|||
import re
|
||||
from aiohttp import web
|
||||
from aiohttp import streamer
|
||||
from cbpi.job.aiohttp import get_scheduler_from_app
|
||||
|
@ -7,7 +8,7 @@ from cbpi.utils import json_dumps
|
|||
from cbpi import __version__
|
||||
import pathlib
|
||||
import os
|
||||
import json
|
||||
from cbpi.controller.system_controller import SystemController
|
||||
|
||||
class SystemHttpEndpoints:
|
||||
|
||||
|
|
Loading…
Reference in a new issue