简体   繁体   中英

How do you use python to open a PowerPoint on a Raspberry Pi?

The current project I am working on has me programming a pi to auto-run PowerPoint file through libre office.

I am using the subprocess.Popen to attempt to be able to open and close a show-only PowerPoint file.

All of the code other than the following line works fine:

    p = subprocess.Popen(['/usr/share/applications/libreoffice-impress.desktop', '/home/pi/Desktop/test.ppsx])

This line returns the "Permission denied" error. However, the executable and the .ppsx file both have all permissions set to anyone. This includes all folders in the path leading to them.

Am I forgetting to give permissions to a specific file? Or does another file need to have the correct permissions? Or is there a better command I should be using to open and close PowerPoints altogether?

Just use the command directly, libreoffice --impress which is what is exec'd inside /usr/share/applications/libreoffice-impress.desktop , it will work fine and you won't have any worry about permissions:

subprocess.check_call(['libreoffice', '--impress', '/home/pi/Desktop/test.ppsx'])

check_call would be preferable when you want to call a process, if the process returns a non-zero exit status you will know as it will raise a CalledProcessError .

If you prefer using a .desktop I would recommend creating one in your home directory, you could also go down the sudo route but considering you can simply run the command directly that would not make much sense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM