use working directory

This commit is contained in:
Jenny Tam 2017-08-24 10:24:21 -07:00
parent fe6f5b2a8f
commit 8177786ddf
2 changed files with 13 additions and 1 deletions

View file

@ -100,8 +100,12 @@ if __name__ == '__main__':
app_name = args.APPNAME
header = 'msodbcsql.h'
cwd = os.getcwd()
# make sure all required source and header files are present
work_dir = os.path.dirname(os.path.realpath(__file__))
os.chdir(work_dir)
if not os.path.exists(os.path.join(work_dir, header)):
print('Error: {0} not found!'.format(header))
exit(1)
@ -114,4 +118,7 @@ if __name__ == '__main__':
compile_KSP(ksp_name)
configure_KSP(app_name)
os.chdir(cwd)

View file

@ -32,9 +32,12 @@ if __name__ == '__main__':
args = parser.parse_args()
app_name = 'ksp_app'
cwd = os.getcwd()
# first check if the ksp app is present
work_dir = os.path.dirname(os.path.realpath(__file__))
os.chdir(work_dir)
if platform.system() == 'Windows':
path = os.path.join(work_dir, app_name + '.exe')
executable = app_name
@ -50,3 +53,5 @@ if __name__ == '__main__':
os.system('{0} 1 {1} {2} {3} {4}'.format(executable, args.SERVER, args.DBNAME, args.UID, args.PWD))
else:
os.system('{0} 0 {1} {2} {3} {4}'.format(executable, args.SERVER, args.DBNAME, args.UID, args.PWD))
os.chdir(cwd)