[fs2zammad] retry import due to unpredictable 503
This commit is contained in:
parent
900f8d6a44
commit
807ed89c08
1 changed files with 118 additions and 111 deletions
15
fs2zammad
15
fs2zammad
|
@ -110,7 +110,8 @@ def maybe_create_zammad_user(userdata, zammad_session, attr="login", default=Non
|
||||||
# id, {"roles": roles.append("Agent")}
|
# id, {"roles": roles.append("Agent")}
|
||||||
# )
|
# )
|
||||||
|
|
||||||
def create_zammad_ticket(id, zammad, h2t):
|
def create_zammad_ticket(id, zammad, h2t, retries=3):
|
||||||
|
try:
|
||||||
with open(f"tickets/{id}", "rb") as handle:
|
with open(f"tickets/{id}", "rb") as handle:
|
||||||
rt_ticket = pickle.load(handle)
|
rt_ticket = pickle.load(handle)
|
||||||
|
|
||||||
|
@ -237,6 +238,13 @@ def create_zammad_ticket(id, zammad, h2t):
|
||||||
|
|
||||||
if restore_creator_to != None:
|
if restore_creator_to != None:
|
||||||
zammad.ticket.update(zammad_ticket["id"], {"customer_id": restore_creator_to})
|
zammad.ticket.update(zammad_ticket["id"], {"customer_id": restore_creator_to})
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("Received keyboard interrupt. Exiting.")
|
||||||
|
sys.exit()
|
||||||
|
except:
|
||||||
|
print(f"Failed to import RT-#{id} .. ({retries} retries left)")
|
||||||
|
if retries > 0:
|
||||||
|
create_zammad_ticket(id, zammad, h2t, retries - 1)
|
||||||
|
|
||||||
### main logic ###
|
### main logic ###
|
||||||
|
|
||||||
|
@ -262,9 +270,8 @@ print(f"Found {len(ticket_ids)} tickets on filesystem.")
|
||||||
|
|
||||||
for id in ticket_ids:
|
for id in ticket_ids:
|
||||||
try:
|
try:
|
||||||
create_zammad_ticket(id, zammad, h2t)
|
create_zammad_ticket(id, zammad, h2t, 3)
|
||||||
except KeyboardInterrupt:
|
except SystemExit:
|
||||||
print("Received keyboard interrupt. Exiting.")
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
except:
|
except:
|
||||||
print(f"Failed to import RT#{id}")
|
print(f"Failed to import RT#{id}")
|
||||||
|
|
Loading…
Reference in a new issue