Changeset - 2ea1af3149c2
[Not reviewed]
default
0 3 0
Dennis Fink - 2 years ago 2022-03-03 17:40:15
dennis.fink@c3l.lu
Add more debug logging
3 files changed with 12 insertions and 0 deletions:
0 comments (0 inline, 0 general)
stockcli/cli.py
Show inline comments
 
import json
 
import logging
 
import logging.config
 
from operator import itemgetter
 

	
 
@@ -62,6 +63,7 @@ def stockcli(ctx: click.Context, configf
 
        choice = prompt.ask(
 
            "Enter a number to select a task", choices=list(TASK_MAP.keys())
 
        )
 
        logging.debug(f"User selected task: {choice}")
 
        selected_task = TASK_MAP[choice][1]
 

	
 
        rerun = True
stockcli/stock.py
Show inline comments
 
import logging
 
from operator import itemgetter
 
from typing import Any
 

	
 
@@ -130,6 +131,7 @@ def transfer_by_barcode(barcode: str) ->
 
    )
 

	
 
    if not from_id:
 
        logging.debug("User aborted task!")
 
        return
 

	
 
    grid = Table.grid(padding=DEFAULT_PADDING)
 
@@ -159,11 +161,13 @@ def transfer_by_barcode(barcode: str) ->
 
    )
 

	
 
    if not to_id:
 
        logging.debug("User aborted task!")
 
        return
 

	
 
    amount = int_prompt.ask("Amount (Enter 0 to abort)")
 

	
 
    if not amount:
 
        logging.debug("User aborted task!")
 
        return
 

	
 
    data = {"amount": amount, "location_id_from": from_id, "location_id_to": to_id}
 
@@ -200,6 +204,7 @@ def add_by_barcode(barcode: str) -> None
 
    amount = int_prompt.ask("Amount (Enter 0 to abort)")
 

	
 
    if not amount:
 
        logging.debug("User aborted task!")
 
        return
 

	
 
    data = {"amount": amount, "transaction_type": "purchase"}
 
@@ -238,6 +243,7 @@ def update_by_barcode(barcode: str) -> N
 
    amount = int_prompt.ask("Amount (Enter 0 to abort)")
 

	
 
    if not amount:
 
        logging.debug("User aborted task!")
 
        return
 

	
 
    data = {
stockcli/utils.py
Show inline comments
 
@@ -21,8 +21,12 @@ def make_request(method: str, url_path: 
 

	
 
    try:
 
        if data is not None:
 
            logging.debug(
 
                f"Making {method.upper()} request: {requested_url} with {data}"
 
            )
 
            response = method_function(session)(requested_url, json=data)
 
        else:
 
            logging.debug(f"Making {method.upper()} request: {requested_url}")
 
            response = method_function(session)(requested_url)
 
        response.raise_for_status()
 
    except requests.Timeout:
0 comments (0 inline, 0 general)