def connect(self): """ This method causes the `Duct` instance to connect to the service, if it is not already connected. It is not normally necessary for a user to manually call this function, since when a connection is required, it is automatically created. Subclasses should implement `Duct._connect` to do whatever is necessary to bring a connection into being. Compared to base `Duct.connect`, this method will automatically catch the first `DuctAuthenticationError` error triggered by `Duct.connect` if any smartcards have been configured, before trying once more. Returns: `Duct` instance: A reference to the current object. """ try: Duct.connect(self) except DuctServerUnreachable as e: raise_with_traceback(e) except DuctAuthenticationError as e: if self.smartcards and self.prepare_smartcards(): Duct.connect(self) else: raise_with_traceback(e) return self
def connect(self): """ Connect to the remote server. It is not normally necessary for a user to manually call this function, since when a connection is required, it is automatically created. Compared to base `Duct.connect`, this method will automatically catch the first `DuctAuthenticationError` error triggered by `Duct.connect`, and (if smartcards have been configured) attempt to re-initialise the smartcards before trying once more. Returns: `Duct` instance: A reference to the current object. """ try: Duct.connect(self) except DuctServerUnreachable as e: raise_with_traceback(e) except DuctAuthenticationError as e: if self.smartcards and self.prepare_smartcards(): Duct.connect(self) else: raise_with_traceback(e) return self
def connect(self): """ If a connection to the ssh server does not already exist, calling this method creates it. It first attempts to connect directly. If it fails, it attempts to initialise and keys in case they had not already been initialised. (It does not do this before creating the connection so as to minimise needless re-preparation of the keys. NOTE: It is not normally necessary for a user to manually call this function, since when a connection is required, it is automatically made. """ try: Duct.connect(self) except DuctServerUnreachable as e: raise_with_traceback(e) except DuctAuthenticationError as e: if self.smartcards and self.prepare_smartcards(): Duct.connect(self) else: raise_with_traceback(e) return self