(connection, service_id, interface:Cmd)
| 158 | print(f'[BINDERDB] Failed inserting interface {str(e)}, {traceback.format_exc()}') |
| 159 | |
| 160 | def insert_update_interface(connection, service_id, interface:Cmd): |
| 161 | try: |
| 162 | interface_existing = get_interface(connection, service_id, interface.cmd_id) |
| 163 | if interface_existing is None: |
| 164 | interface_id = insert_interface(connection, service_id, interface) |
| 165 | return interface_id |
| 166 | else: |
| 167 | cursor = connection.cursor() |
| 168 | update_query = """UPDATE interface SET service_id = ?, |
| 169 | cmd_id = ?, |
| 170 | valid = ?, args_enumerated = ? |
| 171 | where id = ? |
| 172 | """ |
| 173 | cursor.execute(update_query, (service_id, interface.cmd_id, int(interface.valid), |
| 174 | int(interface.args_enumerated), interface_existing.db_id)) |
| 175 | connection.commit() |
| 176 | cursor.close() |
| 177 | for arg in interface.args: |
| 178 | insert_update_arg(connection, interface_existing.db_id, arg) |
| 179 | return interface_existing.db_id |
| 180 | except Exception as e: |
| 181 | logging.error(f'[BINDERDB] Failed insert/update of service{str(e)}, {traceback.format_exc()}') |
| 182 | print(f'[BINDERDB] Failed insert/update of service {str(e)}, {traceback.format_exc()}') |
| 183 | |
| 184 | def get_interface(connection, service_id, cmd_id): |
| 185 | try: |
no test coverage detected