Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-28-2015, 02:33 PM
Caoimhin Caoimhin is offline
Registered User
Join Date: Aug 2014
Posts: 35
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:

***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)

	# 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)

		# 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:

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.

Last edited by Caoimhin; 10-28-2015 at 02:36 PM.
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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