Код: Выделить всё
CUSTOMER_ORDER = ["Some", "Customers"]
ticket_types = ["analysis_tickets"] # is list because copied from legacy code and only need 1 type here (TODO replace with str.)
[...]
# Get all tickets of each type for each customer of the month
for customer in CUSTOMER_ORDER:
all_tickets[customer] = {}
for ticket_type in ticket_types:
logger.info("Getting '" + ticket_type + "' for customer " + customer + "...")
if ticket_type == "analysis_tickets":
suffix = ANALYSIS_TICKETS_SUFFIX
elif ticket_type == "support_tickets":
suffix = SUPPORT_TICKETS_SUFFIX
elif ticket_type == "engineering_tickets":
suffix = ENGINEERING_TICKETS_SUFFIX
all_tickets[customer][ticket_type] = {}
all_tickets[customer][ticket_type]["tickets"] = []
try:
response = requests.get(
OTRS_URL + "/TicketSearch",
params={
"UserLogin": OTRS_USER,
"Password": OTRS_PW,
"Queues": customer + suffix,
time_older: datetime.datetime.now(),
time_newer: datetime.datetime.now() - datetime.timedelta(days=TIME_RANGE_DAYS),
"Limit": 3000,
},
verify=False,
)
if response.status_code != 200:
logger.error("Could not get tickets for customer " + customer + ". Error: " + str(response.status_code))
sys.exit(1)
if "TicketID" not in response.json():
logger.warning("No tickets found for customer " + customer + " amd ticket type '" + ticket_type + "'.")
all_tickets[customer][ticket_type]["tickets"] = []
else:
all_tickets[customer][ticket_type]["tickets"] = response.json()["TicketID"]
logger.info("Found " + str(len(all_tickets[customer][ticket_type]["tickets"])) + " tickets for customer " + customer + " and ticket type '" + ticket_type + "'.")
ticket_count += len(all_tickets[customer][ticket_type]["tickets"])
# print(ticket_type + " " + ticket_types)
except Exception as e:
logger.error("Could not get tickets for customer " + customer + ". Error: " + traceback.format_exc())
sys.exit(1)
Код: Выделить всё
Code errors: Exception has occurred: TypeError
an integer is required File "C:\Users\user\Documents\GitLab\various-scripts\OTRS Auto-Reporting\Analysts-Locked\otrs_reporting_analysts_locked.py", line 160, in
for ticket_type in ticket_types:
^^^^^^^^^^^^
TypeError: an integer is required
- раскомментировать оператор печати в конце попытки. блок
- удаление блока try/Exception
- запуск скрипта напрямую без отладчика
Может ли кто-нибудь понять это?
Я использую Python 3.12.7 64 бит ( Microsoft Store) и соответствующий плагин VS-Code.
Подробнее здесь: https://stackoverflow.com/questions/791 ... y-in-debug
Мобильная версия