Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can nor use MQTT frame/delete, on a mounted SAMBA share #44

Open
cupid666bg opened this issue Dec 22, 2020 · 12 comments
Open

Can nor use MQTT frame/delete, on a mounted SAMBA share #44

cupid666bg opened this issue Dec 22, 2020 · 12 comments

Comments

@cupid666bg
Copy link

Hello,

So under a folder in my /pi/Pictures I have mounted a SAMBA share where my pictures reside.
This solution along with Pi3D works like charm but I was trying to take it a bit further and install Mosquito, so that I can manipulate the contents of the frame including deleting the pictures I don't like.
I have however stumbled across a problem that I will need your help solving.
I have tested the installation with 3 Mosquito commands that I wanted to use frame/paused, frame/back, frame/delete.
If I set the pictures to be read from a folder residing on the SD card all 3 commands work fine.
But if I try that on the SAMBA share, only frame/paused, frame/back work, as frame/delete seems not to do anything.
Moreover once I use the "frame/delete", then all the other Mosquito commands stop working as well and in order to fix that I need to restart Pi3D.
Here is the command I use to mount the SAMBA share:

sudo mount -t cifs "\\192.168.1.3\dela_i_dokumenti\DELA I DOKUMENTI\frame" "/home/pi/Pictures/NAS4frame" -o rw,file_mode=0777,dir_mode=0777,iocharset=utf8,context=u:object_r:rootfs:s0,,username=admin,password=********

I am using 777 as permission so I expect it is not an access issue.
I have even tried moving/deleting data from the mounted share using commands and it works, so I am clueless.
Can you please help me with some guidance how I could approach debugging the issue?
I see no error messages produced by Pi3D.

Many thanks in advance!

Angel

@paddywwoof
Copy link
Member

Angel, The delete code just uses the python os.rename() function which is basically a wrapper round linux mv so it ought to work I would have thought. Try the following and see what happens:

import os
move_to_dir = os.path.expanduser("/home/pi/DeletedPictures") # check that directory was created OK by previous attempts
os.rename("/home/pi/Pictures/NAS4frame/testpic1.jpg", os.path.join(move_to_dir, "testpic1.jpg"))
os.system("mv /home/pi/Pictures/NAS4frame/testpic2.jpg {}".format(os.path.join(move_to_dir, "testpic2.jpg")))

you can try that in a python3 teminal by typing $ python3 see what works or what error messages you get. If it doesn't work you could try sudo mv

@cupid666bg
Copy link
Author

cupid666bg commented Dec 23, 2020 via email

@paddywwoof
Copy link
Member

paddywwoof commented Dec 23, 2020

Even though you set the permission in theory to allow the user pi to do the deletion I think the fact that you mount with sudo might complicate it. It's also further complicated by the way the drive is formatted, as I have found in the past when trying to run programs from mounted drives!

@cupid666bg
Copy link
Author

cupid666bg commented Dec 23, 2020 via email

@paddywwoof
Copy link
Member

No I'm pretty sure you can't, but the fact that you have to use sudo possibly has consequences - or might not! If the sudo mv worked on the command line then it could well work inside os.system() I had to do that with the directory creation because the python wrapped version couldn't do some things (sudo make a directory with ownership of pi). So maybe the deletion should do that too to cope with SMB or mounted drives.

@cupid666bg
Copy link
Author

cupid666bg commented Dec 23, 2020 via email

@paddywwoof
Copy link
Member

paddywwoof commented Dec 23, 2020

Angel, if mv worked then it's worth trying a fall back to that. Could you try editing PictureFrame2020.py around line 330

      elif message.topic == "{}delete".format(id):
        f_to_delete = iFiles[pic_num][0]
        f_name_to_delete = os.path.split(f_to_delete)[1]
        move_to_dir = os.path.expanduser("/home/pi/DeletedPictures")
        if not os.path.exists(move_to_dir):
          #os.makedirs(move_to_dir) # creates directory owned by root if picture frame run with sudo so...
          os.system("sudo -u pi mkdir {}".format(move_to_dir))
        #os.rename(f_to_delete, os.path.join(move_to_dir, f_name_to_delete))
        os.system("sudo mv {} {}".format(f_to_delete, os.path.join(move_to_dir, f_name_to_delete)))
        iFiles.pop(pic_num)
        nFi -= 1
        refresh = True

i.e. comment out the os.rename and add the line os.system("sudo mv... If it works I will change the code for the next issue.

@cupid666bg
Copy link
Author

cupid666bg commented Dec 23, 2020 via email

@cupid666bg
Copy link
Author

cupid666bg commented Dec 23, 2020 via email

@paddywwoof
Copy link
Member

Hi, are the drives identical apart from size? ie is the formatting the same? I had to format my usb drive as FAT to get it to allow execution from it (along with other specific mount settings) Don't really know if that's relevant.

Also do you have --verbose=true so you get any error messages?

@cupid666bg
Copy link
Author

cupid666bg commented Dec 23, 2020 via email

@cupid666bg
Copy link
Author

cupid666bg commented Dec 23, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants