VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Python Error (https://forums.vandyke.com/showthread.php?t=12142)

Caoimhin 10-28-2015 02:33 PM

Python Error
 
So I have a few scripts that parse through the SecureCRT configuration folder. The scripts were created quite a while ago and had no issues until recently. Here is a sample of the code:

Code:

***FirewallPath = "C:/Users/" + User + "/AppData/Roaming/VanDyke/Config/Sessions/***/Firewalls/US Locations"
StateList = os.listdir(***FirewallPath)

for State in StateList:
        if State != "__FolderData__.ini" and len(State) != 0:
                CitiesPath = ***FirewallPath + "/" + State
                CityList = os.listdir(CitiesPath)
                # crt.Dialog.MessageBox("*** State Data ***\n\n" +
                #                                            "Current State: " + State)
        else:
                continue

        # Drill into the list of cities and create a list of Session files for each city.
        for City in CityList:
                if City != "__FolderData__.ini" and len(City) != 0:
                        SessionPath = CitiesPath + "/" + City
                        SessionList = os.listdir(SessionPath)
                        # crt.Dialog.MessageBox("*** City Data ***\n\n" +
                        #                                          "Current State: " + State +
                        #                                          "\nCurrent City: " + City)
                else:
                        continue

                # For each session define the path that SecureCRT uses.
                for Session in SessionList:
                        if Session != "__FolderData__.ini" and len(Session) != 0:
                                SessionSplit = Session.split(".")
                                FirewallPathInternal = "***/Firewalls/US Locations"
                                FullPathExternal = ***FirewallPath + "/" + State + "/"  + City + "/" + Session
                                FullPathInternal = FirewallPathInternal + "/" + State + "/"  + City + "/" + SessionSplit[0]
                                # crt.Dialog.MessageBox("*** Session Data ***\n\n" +
                                #                                          "Current State: " + State +
                                #                                        "\nCurrent City: " + City +
                                #                                            "\nCurrent Session: " + Session +
                                #                                            "\nCleaned Session: " + SessionSplit[0])
                                for Firewall in MasterList:
                                        FirewallClean = Firewall.rstrip().lstrip().replace("\n", "").replace("\r", "")
                                        SessionClean = SessionSplit[0].rstrip().lstrip().replace("\n", "").replace("\r", "")

Now lately my scripts that use this method to parse the directories for the session files have been giving me syntax errors at:

Code:

StateList = os.listdir(***FirewallPath)
Keep in mind I have never received a syntax error on this line before and I have not altered any of my scripts. It just started up out of the blue. Now to troubleshoot the issue I put a crt.Dialog.MessageBox() to find out where the script was in the directory when it craps out. What I discovered is that the script is failing at a point in the directory where a folder was recently created.

Has anyone encountered this issue before? Does anyone know why this is happening or how it can be corrected? I'm somewhat tempted to recreate the script with Perl but it appears there is an issue with the Active X scripting engine not being included with the 64-bit version of ActivePerl.


All times are GMT -6. The time now is 03:43 AM.