Python Forum
Re Try loop for "net use..." failures
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Re Try loop for "net use..." failures
#1
Greetings to you all!
I’m trying to get some files from the remote hosts.
I’m using a ‘net use’ string for mapping drives and getting files.
Some of the hosts intermittently refused a connection.
I thought I would have a retry loop in the code to solve the problem, I’d like to see the number of retries.
For some reason, the snipped does not want to retry… Wall
Here is a "retry" part of the code:
for retry in range(25):
    try:
        print(f" Try - {retry}")
        call("net use Z: /delete /yes")
        call("net use Z: "+"\\\\"+ips+"\\c$\\S_Files /u:SomeUser Somepass") 
        break
    except:
        print ("Connection failed, retrying...") 
        pass            
Thank you in advance!
Any help is appreciated.
Reply


Messages In This Thread
Re Try loop for "net use..." failures - by tester_V - Mar-01-2024, 11:08 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020