linux - Relative path not working in Python -
my python script can't resolve relative path on linux server in following script:
import boto3 import os conn = boto3.client('s3', region_name="eu-west-1", endpoint_url="https://example.com", config=config(signature_version="s3", s3={'addressing_style': 'path'})) conn.download_file('mytestbucket22', 'file.csv', os.path.join(os.getcwd(), 'static', 'filecache', 'file.csv')) error:
[errno 2] no such file or directory: '/home/vcap/app/static/filecache/file.csv.d3e3d7af' however when works , saves file path of script.
conn.download_file('mytestbucket22', 'file.csv', 'file.csv') my folder , file structure looks this:
--script.py --static ----filecache how can save file folder filecache? thanks
conn.download_file('mytestbucket22', 'file.csv', os.path.join(os.getcwd(), 'static', 'filecache', 'file.csv')) documentation references modules, constants , functions used above:
- the
os,os.pathmodules. - the
__file__constant os.path.realpath(path)(returns "the canonical path of specified filename, eliminating symbolic links encountered in path")os.path.dirname(path)(returns "the directory name of pathnamepath")os.getcwd()(returns "a string representing current working directory")os.chdir(path)("change current working directorypath")
Comments
Post a Comment