My python progam is creating wrong file path. The file path formed is wrong : '/autocameratest2\data\TestImages/7_vw_test.png' The correct file path should be: '/autocameratest2/data/TestImages/7_vw_test.png'
The file path is fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/autocameratest2\\data\\TestImages/7_vw_test.png'
172.17.0.1 - - [05/Feb/2022 17:34:22] "POST /places?camid=1&image1test=7_vw_test.png&image2perfect=5_vw_master.png HTTP/1.1" 500 -
In the python api program, the below URL http://127.0.0.1:5000/places?camid=1&image1test=7_vw_test.png&image2perfect=5_vw_master.png returns a json file. The code works fine in VisualStudio code or outside docker. It python code give a path problem inside docker.
image1test_path = os.path.join(IMAGE_FOLD_PATH,'autocameratest2\data\TestImages',image1test)
image2perfect_path = os.path.join(IMAGE_FOLD_PATH,'autocameratest2\data\TestImages',image2perfect)
test_results = generate_report(camid, image1test_path, image2perfect_path)
test_names = ['CamId','Blur','check_scale','noise','scrolled','allign','mirror','blackspots','ssim_score','staticlines','rotation_deg']
The following approach helped my create a file path that I wanted. like this "/autocameratest2/data/TestImages"
image1test_path = os.path.join('data','TestImages',image1test)
image2perfect_path = os.path.join('data','TestImages',image2perfect)
Other techniques which I tried for building the path is below. These are good though it did not solve my problme.
import pathlib
#image1test_path = pathlib.Path.cwd().joinpath('data', 'TestImages', args.image1test)
#image2perfect_path = pathlib.Path.cwd().joinpath('data', 'TestImages', args.image2perfect)
#image1test_path = pathlib.Path('data', 'TestImages', args.image1test)
#image2perfect_path = pathlib.Path('data', 'TestImages', args.image2perfect)