def __str__(self): localIdr = self.localIdentifier if self.localIdentifier \ else constant.NOT_ASSIGNED trustAnchor = self.trustAnchor or "" trustAnchorStatus = '(not yet written to Sovrin)' if self.remoteVerkey is not None: if self.remoteIdentifier == self.remoteVerkey: remoteVerKey = constant.REMOTE_VER_KEY_SAME_AS_ID else: remoteVerKey = self.remoteVerkey else: remoteVerKey = constant.UNKNOWN_WAITING_FOR_SYNC remoteEndPoint = self.remoteEndPoint or \ constant.UNKNOWN_WAITING_FOR_SYNC if isinstance(remoteEndPoint, tuple): remoteEndPoint = "{}:{}".format(*remoteEndPoint) linkStatus = 'not verified, remote verkey unknown' linkLastSynced = prettyDateDifference(self.linkLastSynced) or \ constant.LINK_NOT_SYNCHRONIZED if linkLastSynced != constant.LINK_NOT_SYNCHRONIZED and \ remoteEndPoint == constant.UNKNOWN_WAITING_FOR_SYNC: remoteEndPoint = constant.NOT_AVAILABLE if self.isAccepted: trustAnchorStatus = '(confirmed)' if self.remoteVerkey is None: remoteVerKey = constant.REMOTE_VER_KEY_SAME_AS_ID linkStatus = self.linkStatus # TODO: The verkey would be same as the local identifier until we # support key rotation # TODO: This should be set as verkey in case of DID but need it from # wallet verKey = self.localVerkey if self.localVerkey else constant.SIGNER_VER_KEY_EMPTY fixedLinkHeading = "Link" if not self.isAccepted: fixedLinkHeading += " (not yet accepted)" # TODO: Refactor to use string interpolation # try: fixedLinkItems = \ '\n' \ 'Name: ' + self.name + '\n' \ 'Identifier: ' + localIdr + '\n' \ 'Trust anchor: ' + trustAnchor + ' ' + trustAnchorStatus + '\n' \ 'Verification key: ' + verKey + '\n' \ 'Signing key: <hidden>' '\n' \ 'Remote: ' + (self.remoteIdentifier or constant.UNKNOWN_WAITING_FOR_SYNC) + '\n' \ 'Remote Verification key: ' + remoteVerKey + '\n' \ 'Remote endpoint: ' + remoteEndPoint + '\n' \ 'Invitation nonce: ' + self.invitationNonce + '\n' \ 'Invitation status: ' + linkStatus + '\n' optionalLinkItems = "" if len(self.proofRequests) > 0: optionalLinkItems += "Proof Request(s): {}". \ format(", ".join([cr.name for cr in self.proofRequests])) \ + '\n' if self.availableClaims: optionalLinkItems += self.avail_claims_str() if self.linkLastSyncNo: optionalLinkItems += 'Last sync seq no: ' + self.linkLastSyncNo \ + '\n' fixedEndingLines = 'Last synced: ' + linkLastSynced linkItems = fixedLinkItems + optionalLinkItems + fixedEndingLines indentedLinkItems = constant.LINK_ITEM_PREFIX.join( linkItems.splitlines()) return fixedLinkHeading + indentedLinkItems
def __str__(self): localIdr = self.localIdentifier if self.localIdentifier \ else constant.NOT_ASSIGNED trustAnchor = self.trustAnchor or "" trustAnchorStatus = '(not yet written to Indy)' if self.remoteVerkey is not None: if self.remoteIdentifier == self.remoteVerkey: remoteVerKey = constant.REMOTE_VER_KEY_SAME_AS_ID else: remoteVerKey = self.remoteVerkey else: remoteVerKey = constant.UNKNOWN_WAITING_FOR_SYNC remoteEndPoint = self.remoteEndPoint or \ constant.UNKNOWN_WAITING_FOR_SYNC if isinstance(remoteEndPoint, tuple): remoteEndPoint = "{}:{}".format(*remoteEndPoint) connectionStatus = 'not verified, remote verkey unknown' connection_last_synced = prettyDateDifference( self.connection_last_synced ) or constant.CONNECTION_NOT_SYNCHRONIZED if connection_last_synced != constant.CONNECTION_NOT_SYNCHRONIZED and \ remoteEndPoint == constant.UNKNOWN_WAITING_FOR_SYNC: remoteEndPoint = constant.NOT_AVAILABLE if self.isAccepted: trustAnchorStatus = '(confirmed)' if self.remoteVerkey is None: remoteVerKey = constant.REMOTE_VER_KEY_SAME_AS_ID connectionStatus = self.connection_status # TODO: The verkey would be same as the local identifier until we # support key rotation # TODO: This should be set as verkey in case of DID but need it from # wallet verKey = self.localVerkey if self.localVerkey else constant.SIGNER_VER_KEY_EMPTY fixed_connection_heading = "Connection" if not self.isAccepted: fixed_connection_heading += " (not yet accepted)" # TODO: Refactor to use string interpolation # try: fixed_connection_items = \ '\n' \ 'Name: ' + self.name + '\n' \ 'DID: ' + localIdr + '\n' \ 'Trust anchor: ' + trustAnchor + ' ' + trustAnchorStatus + '\n' \ 'Verification key: ' + verKey + '\n' \ 'Signing key: <hidden>' '\n' \ 'Remote: ' + (self.remoteIdentifier or constant.UNKNOWN_WAITING_FOR_SYNC) + '\n' \ 'Remote Verification key: ' + remoteVerKey + '\n' \ 'Remote endpoint: ' + remoteEndPoint + '\n' \ 'Request nonce: ' + self.request_nonce + '\n' \ 'Request status: ' + connectionStatus + '\n' optional_connection_items = "" if len(self.proofRequests) > 0: optional_connection_items += "Proof Request(s): {}". \ format(", ".join([cr.name for cr in self.proofRequests])) \ + '\n' if self.availableClaims: optional_connection_items += self.avail_claims_str() if self.connection_last_sync_no: optional_connection_items += 'Last sync seq no: ' + \ self.connection_last_sync_no + '\n' fixedEndingLines = 'Last synced: ' + connection_last_synced connection_items = fixed_connection_items + \ optional_connection_items + fixedEndingLines indented_connection_items = constant.CONNECTION_ITEM_PREFIX.join( connection_items.splitlines()) return fixed_connection_heading + indented_connection_items
def __str__(self): localIdr = self.localIdentifier if self.localIdentifier \ else constant.NOT_ASSIGNED trustAnchor = self.trustAnchor or "" trustAnchorStatus = '(not yet written to Sovrin)' targetVerKey = constant.UNKNOWN_WAITING_FOR_SYNC targetEndPoint = self.remoteEndPoint or \ constant.UNKNOWN_WAITING_FOR_SYNC if isinstance(targetEndPoint, tuple): targetEndPoint = "{}:{}".format(*targetEndPoint) linkStatus = 'not verified, target verkey unknown' linkLastSynced = prettyDateDifference(self.linkLastSynced) or \ constant.LINK_NOT_SYNCHRONIZED if linkLastSynced != constant.LINK_NOT_SYNCHRONIZED and \ targetEndPoint == constant.UNKNOWN_WAITING_FOR_SYNC: targetEndPoint = constant.NOT_AVAILABLE if self.isAccepted: trustAnchorStatus = '(confirmed)' targetVerKey = constant.TARGET_VER_KEY_SAME_AS_ID linkStatus = self.linkStatus # TODO: The verkey would be same as the local identifier until we # support key rotation # TODO: This should be set as verkey in case of DID but need it from # wallet verKey = constant.SIGNER_VER_KEY_SAME_AS_ID fixedLinkHeading = "Link " if not self.isAccepted: fixedLinkHeading += "(not yet accepted)" # TODO: Refactor to use string interpolation # try: fixedLinkItems = \ '\n' \ 'Name: ' + self.name + '\n' \ 'Identifier: ' + localIdr + '\n' \ 'Trust anchor: ' + trustAnchor + ' ' + trustAnchorStatus + '\n' \ 'Verification key: ' + verKey + '\n' \ 'Signing key: <hidden>' '\n' \ 'Target: ' + (self.remoteIdentifier or constant.UNKNOWN_WAITING_FOR_SYNC) + '\n' \ 'Target Verification key: ' + targetVerKey + '\n' \ 'Target endpoint: ' + targetEndPoint + '\n' \ 'Invitation nonce: ' + self.invitationNonce + '\n' \ 'Invitation status: ' + linkStatus + '\n' # except Exception as ex: # print(ex) # print(targetEndPoint, linkStatus, ) optionalLinkItems = "" if len(self.claimProofRequests) > 0: optionalLinkItems += "Claim Request(s): {}". \ format(", ".join([cr.name for cr in self.claimProofRequests])) \ + '\n' if self.availableClaims: optionalLinkItems += "Available Claim(s): {}". \ format(", ".join([name for name, _, _ in self.availableClaims])) \ + '\n' if self.linkLastSyncNo: optionalLinkItems += 'Last sync seq no: ' + self.linkLastSyncNo \ + '\n' fixedEndingLines = 'Last synced: ' + linkLastSynced linkItems = fixedLinkItems + optionalLinkItems + fixedEndingLines indentedLinkItems = constant.LINK_ITEM_PREFIX.join( linkItems.splitlines()) return fixedLinkHeading + indentedLinkItems