comparison libervia/backend/memory/migration/versions/fe3a02cb4bec_convert_legacypickle_columns_to_json.py @ 4270:0d7bb4df2343

Reformatted code base using black.
author Goffi <goffi@goffi.org>
date Wed, 19 Jun 2024 18:44:57 +0200
parents 79a4870cfbdf
children
comparison
equal deleted inserted replaced
4269:64a85ce8be70 4270:0d7bb4df2343
3 Revision ID: fe3a02cb4bec 3 Revision ID: fe3a02cb4bec
4 Revises: 610345f77e75 4 Revises: 610345f77e75
5 Create Date: 2024-02-22 14:55:59.993983 5 Create Date: 2024-02-22 14:55:59.993983
6 6
7 """ 7 """
8
8 from alembic import op 9 from alembic import op
9 import sqlalchemy as sa 10 import sqlalchemy as sa
10 import pickle 11 import pickle
11 import json 12 import json
13
12 try: 14 try:
13 from libervia.backend.plugins.plugin_xep_0373 import PublicKeyMetadata 15 from libervia.backend.plugins.plugin_xep_0373 import PublicKeyMetadata
14 except Exception: 16 except Exception:
15 PublicKeyMetadata = None 17 PublicKeyMetadata = None
16 print( 18 print(
74 except Exception as e: 76 except Exception as e:
75 print( 77 print(
76 "Warning: Failed to convert Trust Management cache with value " 78 "Warning: Failed to convert Trust Management cache with value "
77 f" {deserialized!r}, using empty array instead: {e}" 79 f" {deserialized!r}, using empty array instead: {e}"
78 ) 80 )
79 deserialized=[] 81 deserialized = []
80 82
81 ret = json.dumps(deserialized, ensure_ascii=False, default=str) 83 ret = json.dumps(deserialized, ensure_ascii=False, default=str)
82 if table == 'history' and ret == "{}": 84 if table == "history" and ret == "{}":
83 # For history, we can remove empty data, but for other tables it may be 85 # For history, we can remove empty data, but for other tables it may be
84 # significant. 86 # significant.
85 ret = None 87 ret = None
86 return ret 88 return ret
87 except Exception as e: 89 except Exception as e: