Advanced search FAQ Register Login

It is currently Tue Jan 23, 2018 10:35 am


Postby LinuxHippy » Mon Aug 21, 2017 7:32 pm

Well, I now have 3 buttons programmed on the PaPiRus zero using python scripts. I added a clock button using this python script:

import RPi.GPIO as GPIO
import time
import subprocess

# set pin 16 to input
GPIO.setup(16, GPIO.IN)

oldButtonState1 = True
while True:
buttonState1 = GPIO.input(16)

if buttonState1 != oldButtonState1 and buttonState1 == False :
print "Button 2 pressed-what time is it?""papirus-clock", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

oldButtonState1 = buttonState1


It works fine, but now the screen is busy and the papirus-clock process needs to be killed with sudo killall papirus-clock from the command line in an ssh session to do anything else. How can I put the sudo killall command into a python script? I'm using psutil (sudo apt-get install python-psutil) but I'm not sure it can work to terminate a root process in a python script.



Posts: 4

Joined: Sat Aug 19, 2017 4:38 pm

Postby Dave » Tue Aug 22, 2017 8:17 am

Maybe look into copying the code out of the papirus-clock script into your script. That way you don't have to call an external script and you'll be able to start/stop the clock script from within yours.


User avatar

Posts: 2084

Joined: Wed Jul 22, 2015 11:36 am

Forum Administrator & Technical Support

Who is online

Users browsing this forum: No registered users and 1 guest

Board index

The teamDelete all board cookies • All times are UTC [ DST ]