Psftp multiple files

The code will traverse will sftp.get the first file correctly to the local directory then it hangs and never get the secord file inside the for loop. If I remove “sftp.get(remote_f,local_f)” it will traverse for loop correctly. The question is inside sftp.get is it waiting for a Manuel response to get the next file?

import pysftp
from datetime import datetime

now = datetime.now()
myhostname = “union-chapel-baptist.org
myusername = “root”
mypasswd = “r12eggie”
local_dir="/Users/rtruesdale/qeumimages/"
remote_dir= “/home/”
date = now.strftime("%m-%d-%Y")

importing os module

import os

Directory

directory = date

Parent Directory path

parent_dir = local_dir

Path

path = os.path.join(parent_dir, directory)

mode

mode = 777

Create the directory

‘GeeksForGeeks’ in

‘/home / User / Documents’

print(“this is the path”,path)
os.mkdir(path)

with pysftp.Connection(host=myhostname, username=myusername, password=mypasswd) as sftp:
with sftp.cd(’/home’): # temporarily chdir to allcode
# sftp.put(’/pycode/filename’) # upload file to allcode/pycode on remote
# sftp.get(’*.qcow2’) # get a remote file
directory_structure = sftp.listdir()
pattern = “qcow2”
for attr in directory_structure:
if (attr.endswith(‘qcow2’)):
print(attr)
remote_f = remote_dir + attr
local_f = path + ‘/’ + attr + ‘.’ + date
print(date)
print(remote_f)
print(local_f)
sftp.get(remote_f,local_f)