python - Apache: Errno 13 file permission denied -


i use aws ec2 run application "neural network in art". send images deploy website based on flask + virtualenv + apache. after sending image on server starts script, print each iteration , want store in out.txt

__init__.py:

#... def apply_style(image_name, style_name, iterations):     command = ['"python ~/neural_artistic_style/neural_artistic_style.py', \             ' --subject ', '/var/www/superapp/superapp/uploads/' + image_name, \             ' --style ', '/var/www/superapp/superapp/uploads/' + style_name, \             ' --iterations ', iterations, \             ' --network ~/neural_artistic_style/imagenet-vgg-verydeep-19.mat"']     str = ''.join(command)     network = popen(str, shell=true, stdout=pipe)     stats = []     out in network.stdout:         stats.append(out)     line = ' '.join(stats)     return line  @app.route('/upload', methods=['get', 'post']) def upload():     if request.method == 'post':         image = request.files['image']         style = request.files['style']         iterations = request.form['iter']         if file , style: #saving images...                             result = apply_style(image_name, style_name, iterations)             f = open('out.txt', 'w')             f.write(result)             f.close()             return 'finished' #... 

well, can upload image via http without writing result in out.txt, when do, apache log shows this:

[wed jun 01 ...] [:error] [pid 2360:tid 14...]     return self.view_functions[rule.endpoint](**req.view_args) [wed jun 01 ...] [:error] [pid 2360:tid 14...]   file "/var/www/superapp/superapp/__init__.py", line 72, in upload [wed jun 01 ...] [:error] [pid 2360:tid 14...]     f = open('out.txt', 'w') [wed jun 01 ...] [:error] [pid 2360:tid 14...] ioerror: [errno 13] permission denied: 'out.txt' 

all files in directory have 777 permission. when try write using simple script script.py:

f = open('out.txt', 'w') f.write('some words') f.close() 

everithing works. apache doesn't. has ideas how fix it?

the problem apache runs code in have different working directory, 1 not intend write file into. must supply full path file.

f = open('/path/to/my/out.txt', 'w') 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo