python - Peculiar error downloading keys/files from S3 bucket - [Errno 1] Operation not permitted -
i'm using python script files in s3 bucket. relevant code snippet follow:
print ("downloading files...") f in files: cwd=os.getcwd() fname=cwd+"/" fname = fname+f.name dir = os.path.dirname(fname) if not os.path.exists(dir): print dir os.makedirs(dir) try: f.get_contents_to_filename(fname) except oserror,e: print e
when on bucket used store log files, error on folders in bucket. e.g. logs folder here:
downloading files... /private/tmp/test/logs [errno 1] operation not permitted: '/private/tmp/test/logs/
despite error, directories , files downloaded.
why happen? not happen on other buckets, except bucket log files other buckets sent to. or code? or permissions on bucket. has default permissions, nothing have changed.
taking @pavel_form's suggestion, figured out problem. trying write directory file. fixed code using block, checking if basename empty:
if (not os.path.basename(fname)==""): try: f.get_contents_to_filename(fname) except oserror,e: print e
Comments
Post a Comment