I have a Python script which needs to be run with a batch file, but I've been using cmd to test it. When run through cmd, it works fine. However, the script seems to behave differently when run through the batch file. I've isolated the section of code which seems to be the problem:
CRFOLDER = "some path to all my files"
isReady = False
os.startfile(os.path.join(CRFOLDER,"CLogger.exe"))
while not isReady:
try:
open(os.path.join(CRFOLDER,"CRPYLog.py"))
isReady = True
except:
print "Not ready yet"
time.sleep(0.25)
import CRPYLog as PyLog
This code calls an executable which creates a Python file, which I then import (if you're curious about the reason, check here). As I said, this works fine when run through cmd. However, when I use the batch file, the while loop runs infinitely (or at least for 2 minutes, when run through cmd it hits the except just once). This is weird. I checked this, this, and this question with no luck. The batch file is below.
start Y:\Admin\Anaconda\python.exe "Y:\Projects\Advent - Overhead Projects\Copy - ADV001 - CR Records Management - Copy\Python\CRWizard.py"
I've tried pasting that exact command into cmd and it worked fine, but the batch file does not. Thanks in advance
CRFOLDER? Is it pointing to the same location in both cases (batch file and run directly)?subprocess.call?CRFOLDERis the path to where all my files live. I had it print the value ofos.path.join(CRFOLDER,"clogger.exe")andos.path.join(CRFOLDER,"CRPYLog.py"), they both appeared to be correctstartfilewas the cleanest way to open files in their default programs, but I doubt there's anything holy about itCLogger.exelog absolute location of created file?