In connection to a little project I'm making based on the RuneAudio distro (runs on a stripped version of Arch). I want to have a LED turn on when Media Player Daemon is running.
I'm a total beginner with programming in general so any help here will be aprciated.
I started poking around the net for solutions and I found this script made for a wardriving set-up https://docs.google.com/file/d/0B1i26Iu ... JJSjg/edit and I thought I could use this as a basis for my own project.
I made some changes that I thought was the correct way of doing it.
Code: Select all
import RPi.GPIO as GPIO
import os
import subprocess
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)#Sets the GPIO pin to be an output pin
GPIO.output(17, False) #Makes sure all LED's are at the same state (off)
while 1 < 2:
mpd = subprocess.Popen(['ps -ef | grep /usr/bin/mpd | grep -v grep '], stdout=subprocess.PIPE, shell=True) #Assigns the output from the grep to the kismet variable
(output, error) = mpd.communicate()
if '/usr/bin/mpd' in output:
GPIO.output(17, True) #Turn on LED
else:
GPIO.output(17, False) #Turn off LEDCode: Select all
Traceback (most recent call last):
File "led-test.py", line 12, in <module>
if '/usr/bin/mpd' in output:
TypeError: Type str doesn't support the buffer API