Jul-23-2018, 11:57 PM
I can't get Python to recognize a folder as existing from a batch file or command line. However it works fine within the debugger. Thanks in advance for help.
here's an example of the batch file failing. The folder is not a symbolic link or on a network drive.
here's the relevant portions of the script:
here's an example of the batch file failing. The folder is not a symbolic link or on a network drive.
Error:C:\proj\python\Handle_Final_Test_Logs_V_0.0.3_23_July_2018>Handle_FTLogs_TestProcessor
C:\proj\python\Handle_Final_Test_Logs_V_0.0.3_23_July_2018>python "HFT_V_0.0.3.p
y" -s "C:\proj\python\Handle_Final_Test_Logs\Test_Data\testSource" -d "C:\proj
\python\Handle_Final_Test_Logs\Test_Data\testDest"
Source C:\proj\python\Handle_Final_Test_Logs\Test_Data\testSource is not a folde
rhere's the output from the script executing within the debugger:Quote:process C:\proj\python\Handle_Final_Test_Logs_V_0.0.3_23_July_2018\Test_Data\testSource
23_07_2018_16:45:03 create folder C:\proj\python\Handle_Final_Test_Logs_V_0.0.3_23_July_2018\Test_Data\testDest\H180455
23_07_2018_16:45:03 move file H180455_2018_0718_165519_event_log.sorted.csv to folder H180455
23_07_2018_16:45:03 move file H180455_2018_0718_165519_periodic_log.sorted.csv to folder H180455
23_07_2018_16:45:03 create folder C:\proj\python\Handle_Final_Test_Logs_V_0.0.3_23_July_2018\Test_Data\testDest\H180456
23_07_2018_16:45:03 move file H180456_2018_0718_162618_event_log.sorted.csv to folder H180456
23_07_2018_16:45:03 move file H180456_2018_0718_162618_periodic_log.sorted.csv to folder H180456
check H180455
H180455_2018_0718_165519_event_log.sorted.csv
H180455_2018_0718_165519_periodic_log.sorted.csv
check H180456
H180456_2018_0718_162618_event_log.sorted.csv
H180456_2018_0718_162618_periodic_log.sorted.csv
here's the relevant portions of the script:
import os, sys, shutil, datetime, time, argparse, keyboard
from pathlib import Path
# globals
folders = [] # list of new folders
sourceFolder = ''
destFolder = ''
parser = argparse.ArgumentParser(description = 'Handle Final Test Logs')
parser.prog = 'Handle Final Test Logs, V0.0.2'
parser.add_argument('-s', '--src', help="source folder, default current")
parser.add_argument('-d', '--dest', help="dest folder, default current")
parser.add_argument('-w', '--watch', default = False, help="watch source, default process source")
args = parser.parse_args()
# other stuff omitted
# check source folder.
sourceFolder = args.src
if (sourceFolder == None):
sourceFolder = os.getcwd()
if os.path.exists(sourceFolder):
if os.path.isdir(sourceFolder):
pass
else:
print ('Source %s is not a folder' % sourceFolder)
sys.exit(1)
else:
print ('Source %s does not exist' % sourceFolder)
sys.exit(1)finally, here's the relevant portion of my json file: {
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"stopOnEntry": true,
"args": [
"-sC:\\proj\\python\\Handle_Final_Test_Logs_V_0.0.3_23_July_2018\\Test_Data\\testSource",
"-dC:\\proj\\python\\Handle_Final_Test_Logs_V_0.0.3_23_July_2018\\Test_Data\\testDest",
]
},
