How to use the pysftp.Connection.put_dir function in pysftp

To help you get started, we’ve selected a few pysftp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fastai / fastec2 / fastec2 / ec2.py View on Github external
def _pysftp_init(self, ssh):
    self._sftp_live = True
    self._transport = ssh.get_transport()
    self._sftp = paramiko.SFTPClient.from_transport(self._transport)

def _put_dir(sftp, fr, to):
    sftp.makedirs(to)
    sftp.put_d(os.path.expanduser(fr), to)

def _put_key(sftp, name):
    sftp.put(os.path.expanduser(f'~/.ssh/{name}'), f'.ssh/{name}')
    sftp.chmod(f'.ssh/{name}', 600)

pysftp.Connection.__init__ = _pysftp_init
pysftp.Connection.put_dir = _put_dir
pysftp.Connection.put_key = _put_key

def interact(region=''):
    os.execvp('ipython', ['ipython', '--autocall=2', '-ic',
                          f'import fastec2; e=fastec2.EC2("{region}")'])