예제 #1
0
def get_item(row_id):
    this_item = [
        item for item in InventoryManager().get_items() if item['ID'] == row_id
    ]
    if len(this_item) == 0:
        abort(404)
    return jsonify(this_item)
예제 #2
0
def get_rooms_items(room_id):
    room_items = [
        item for item in InventoryManager().get_items()
        if item['Room'] == room_id
    ]
    if len(room_items) == 0:
        abort(404)
    return jsonify(room_items)
예제 #3
0
def create_item():
    if not request.json \
            or not ('item' in request.json and 'room' in request.json and 'cost' in request.json):
        abort(400)
    new_item = [
        request.json['room'], request.json['item'], request.json['cost']
    ]
    if InventoryManager().insert_item(new_item):
        return jsonify({'item': new_item}), 201
    else:
        # Create did not work
        return jsonify({'item', new_item}), 409
예제 #4
0
def update_item(row_id):
    if not request.json or not row_id \
            or not ('item' in request.json and 'room' in request.json and 'cost' in request.json):
        abort(400)
    updated_item = [
        row_id, request.json['room'], request.json['item'],
        request.json['cost']
    ]
    if InventoryManager().update_item(updated_item):
        return jsonify(updated_item)
    else:
        # Update did not work
        return jsonify(updated_item), 409
예제 #5
0
 def setUpClass(cls):
     cls.my_manager = InventoryManager()
     cls.my_manager.worksheet = cls.my_manager.spreadsheet.add_worksheet(
         'test', 25, 4)
     cls.my_manager.worksheet.insert_row(['ID', 'Room', 'Item', 'Cost'])
예제 #6
0
STACK_NAME = os.environ['STACK_NAME']
IS_SANDBOX = os.environ["IS_SANDBOX"]
DETECTION_API_URL = os.environ["DETECTION_API_URL"]
COMPANY_NAME = os.environ["COMPANY_NAME"]
FOOD_CATEGORY = os.environ["FOOD_CATEGORY"]
NUMBER_CAMERAS = os.environ["NUMBER_CAMERAS"]
AUDIO_CARD = os.environ["AUDIO_CARD"]
AUDIO_DEVICE = os.environ["AUDIO_DEVICE"]
TMP_PATH = "/tmp/"

# GG library
gg_client = greengrasssdk.client('iot-data')

# Reading from shelve in order to read chargePermissionId
local_storage = LocalStorage()
inventory_manager = InventoryManager()


def get_image_name(order_id, id_cam, name):
    return '{}_{}_{}.jpg'.format(order_id, id_cam, name)


def copy_image_to_disk(frame, order_id, id_cam, save_path, name):
    filepath = '{}/{}'.format(save_path,
                              get_image_name(order_id, id_cam, name))
    imwrite(filepath, frame)
    return filepath


def take_photo(order_id, id_cam, save_path):
    logger.info("START")
예제 #7
0
def delete_item(row_id):
    if InventoryManager().delete_item(row_id):
        return jsonify({'response': 'Deleted'})
    else:
        return jsonify({'response': 'Not Deleted'})
예제 #8
0
def get_items():
    return jsonify(InventoryManager().get_items())
예제 #9
0
def update_master(event, context):
    logger.info("START")
    inventory_manager = InventoryManager()
    inventory_manager.update_product_info()
    logger.info("END")