jakewaldron / PlexEmail

This script aggregates all new TV, movie and music releases for the past configured time then optionally writes to your web directory and sends out an email.
206 stars 32 forks source link

Permission Denied on image #50

Open saitoh183 opened 7 years ago

saitoh183 commented 7 years ago

I dont know when it started but everytime i run plexEmail.py, it fails with this message

Traceback (most recent call last):
  File "/opt/plexEmail/scripts/plexEmail.py", line 782, in <module>
    imageInfo = processImage(hash, imageInfo['thumb'], 'movie', 0, 0)
  File "/opt/plexEmail/scripts/plexEmail.py", line 271, in processImage
    shutil.copy(imgLocation, img)
  File "/usr/lib/python2.7/shutil.py", line 119, in copy
    copyfile(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/var/www/html/plexEmail/images/07dff822e4d99b8ae4c5bb693e06ed7adffeb00d_c7f62e627843f4e17e59168370e56fae60e46b65.jpg'

The problem is that 07dff822e4d99b8ae4c5bb693e06ed7adffeb00d_c7f62e627843f4e17e59168370e56fae60e46b65.jpg does not exist in the image folder. Also when i check my Plex metadata folder(plex is on windows) and search for 07dff822e4d99b8ae4c5bb693e06ed7adffeb00d, it referes to a UFC poster. The weird thing is that everytime i get a new UFC poster, 07dff822e4d99b8ae4c5bb693e06ed7adffeb00d points to that new poster and not the previous one. How can i fix this?

jakewaldron commented 7 years ago

I just pushed new changes to the master branch that has a fix for posters. Could you please try it?

saitoh183 commented 7 years ago

It seems to work but did you remove the msg_header_image from the plexemail.py? Because my image is not in the email.

jakewaldron commented 7 years ago

Was that a custom change you made to the script? That field hasn't ever existed.

saitoh183 commented 7 years ago

i dont rememeber...lol..i have been using this same config file since the 0.2.0i guess i will change it header1

saitoh183 commented 7 years ago

@jakewaldron

What is the Fix for the logging because when i try to run python path/to/plexEmail.py -t i get a error that plexemail.log access denied (even if the group and user are the same as the other file). When i add sudo in front, it works.

jakewaldron commented 7 years ago

It adds logging to an external file. I'm guessing the user running the script doesn't have write access to the scripts folder (that's why it works with sudo). I'll have to add some permission checking in the next release.

saitoh183 commented 7 years ago

Humm.. Odd.. My www-data user is the owner and group and my user is part of the www-data group. Can I turn off logging?

jakewaldron commented 7 years ago

Does the group have write access to the folder?

The current release in the main branch cannot disable logging; however I just pushed a new change to the dev branch that adds this ability. Give it a shot and if you have no issues with it I will push it to the main branch.

saitoh183 commented 7 years ago

Ok.. Will give it a try. Yes the group had rw

saitoh183 commented 7 years ago

@jakewaldron

The log disabling works but now i have

WARNING:root:processImage: Failed to copy image - OSError(1, 'Operation not permitted')

Unless i run as sudo...this is if i run from cron or from terminal

Here are my permissions http://pastebin.com/yj7Gci8p

saitoh183 commented 7 years ago

@jakewaldron

any ideas?

striker1983 commented 7 years ago

Using shutil.copyfile instead of shutil.copy on plexemail.py will resolve this issue. The issue happens if the image file in the destination is owned by a use different than the one running the script.

saitoh183 commented 7 years ago

Ok, I will give it a try and post back

ramsnerm commented 7 years ago

I tested it and the solution works for me!