Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

If an experiment works, something has gone wrong.


computers / comp.sys.raspberry-pi / Re: Help With Sense Hat Python Script

SubjectAuthor
* Help With Sense Hat Python ScriptDr Stephen Strange
`* Re: Help With Sense Hat Python ScriptThe Natural Philosopher
 `* Re: Help With Sense Hat Python ScriptDr Stephen Strange
  `* Re: Help With Sense Hat Python ScriptDr Stephen Strange
   `- Re: Help With Sense Hat Python ScriptThe Natural Philosopher

1
Help With Sense Hat Python Script

<JSidnaAITuhW1hj4nZ2dnZfqnPidnZ2d@brightview.co.uk>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=8475&group=comp.sys.raspberry-pi#8475

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 22 Dec 2023 08:41:47 +0000
Newsgroups: comp.sys.raspberry-pi
X-Mozilla-News-Host: news://usenet.plus.net:119
From: no.spam@me.com (Dr Stephen Strange)
Subject: Help With Sense Hat Python Script
Date: Fri, 22 Dec 2023 08:41:46 +0000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 14.2; rv:91.0)
Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.18
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <JSidnaAITuhW1hj4nZ2dnZfqnPidnZ2d@brightview.co.uk>
Lines: 28
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-MGZrsXHoEev8wKwubkfoU9G4k7D8M6pKofkAFtSbPhKOKIA/p4ddPbSiY2kcYc0BCknzuDSm+/1l8g4!EG/RSm7eEo3TQTENM5SZW9DOe3jUNtY/kiscxZ51TzDCF4hhB2D3DiCII/uHULVdfKjDBrkjqa2u!sgGRrAjNurUU6U6o/Mfn4C5BBA==
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Dr Stephen Strange - Fri, 22 Dec 2023 08:41 UTC

I have a Sense Hat and want to run this oython script at boot:

from sense_hat import SenseHat
from pydub import AudioSegment
from pydub.playback import play

song = AudioSegment.from_wav("/home/pi/redalert.wav")

sense = SenseHat()

x = 0.1
y = 204,0,0
z = 0,0,153
y1 = 25,0,0
z1 = 255,255,0

while True:
play(song)
play(song)
sense.show_message("!!! Intuder Alert ", x, y, z)

Now if I boot the Pi and then run the script it runs fine and the sound
plays.

However if I use

@reboot python3 /home/pi/intruder.py via a cron job, the message is
displayed but no sound.

Re: Help With Sense Hat Python Script

<um3m5g$1gu1j$6@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=8476&group=comp.sys.raspberry-pi#8476

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.sys.raspberry-pi
Subject: Re: Help With Sense Hat Python Script
Date: Fri, 22 Dec 2023 09:50:40 +0000
Organization: A little, after lunch
Lines: 50
Message-ID: <um3m5g$1gu1j$6@dont-email.me>
References: <JSidnaAITuhW1hj4nZ2dnZfqnPidnZ2d@brightview.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 22 Dec 2023 09:50:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="23e37881c39b9e3a9926c4e008af3ba4";
logging-data="1603635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192jL6mNjXgn3oMJkTEqZSvgm7/oru9KtI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:FCVK/ikCH0Cs7Hz75kPADl0UJoQ=
Content-Language: en-GB
In-Reply-To: <JSidnaAITuhW1hj4nZ2dnZfqnPidnZ2d@brightview.co.uk>
 by: The Natural Philosop - Fri, 22 Dec 2023 09:50 UTC

On 22/12/2023 08:41, Dr Stephen Strange wrote:
> I have a Sense Hat and want to run this oython script at boot:
>
> from sense_hat import SenseHat
> from pydub import AudioSegment
> from pydub.playback import play
>
> song = AudioSegment.from_wav("/home/pi/redalert.wav")
>
> sense = SenseHat()
>
> x = 0.1
> y = 204,0,0
> z = 0,0,153
> y1 = 25,0,0
> z1 = 255,255,0
>
> while True:
>  play(song)
>  play(song)
>  sense.show_message("!!! Intuder Alert ", x, y, z)
>
> Now if I boot the Pi and then run the script it runs fine and the sound
> plays.
>
> However if I use
>
> @reboot python3 /home/pi/intruder.py via a cron job, the message is
> displayed but no sound.

I think I had this issue. The permissions on sound channels are weird.
I wanted the web server (user www-data) to play sounds - it wouldn't
until I did something to it...

OK I just logged in to that machine

in /etc/group is this line:

audio:x:29:me,www-data,pulse,root

I suggest you add at least root and probably pulse to the audio group

--
The biggest threat to humanity comes from socialism, which has utterly
diverted our attention away from what really matters to our existential
survival, to indulging in navel gazing and faux moral investigations
into what the world ought to be, whilst we fail utterly to deal with
what it actually is.

Re: Help With Sense Hat Python Script

<1GmdnXHq5eDVCRj4nZ2dnZfqn_SdnZ2d@brightview.co.uk>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=8478&group=comp.sys.raspberry-pi#8478

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!69.80.99.22.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 22 Dec 2023 13:51:04 +0000
Subject: Re: Help With Sense Hat Python Script
Newsgroups: comp.sys.raspberry-pi
References: <JSidnaAITuhW1hj4nZ2dnZfqnPidnZ2d@brightview.co.uk> <um3m5g$1gu1j$6@dont-email.me>
From: no.spam@me.com (Dr Stephen Strange)
Date: Fri, 22 Dec 2023 13:51:04 +0000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 14.2; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.18
MIME-Version: 1.0
In-Reply-To: <um3m5g$1gu1j$6@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Message-ID: <1GmdnXHq5eDVCRj4nZ2dnZfqn_SdnZ2d@brightview.co.uk>
Lines: 46
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-Y7ik/V0/Je09XqFm2dj8WKkk4bTSfe6Hg0IIpjyM1N6fSGfiJD2zdK6UuuPWmBXj7+ASlBlN6OD1+ht!VUkkyoK5eSTfC1bbGkSsym26zf69ElRMdLlrFxmdcp+97RZ+UOzmNC0Ojc2Y+TAQqLxP1a+768vF!A3+xC1A3QlQrAwf/D0VPWRZEgA==
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Dr Stephen Strange - Fri, 22 Dec 2023 13:51 UTC

The Natural Philosopher wrote:
> On 22/12/2023 08:41, Dr Stephen Strange wrote:
>> I have a Sense Hat and want to run this oython script at boot:
>>
>> from sense_hat import SenseHat
>> from pydub import AudioSegment
>> from pydub.playback import play
>>
>> song = AudioSegment.from_wav("/home/pi/redalert.wav")
>>
>> sense = SenseHat()
>>
>> x = 0.1
>> y = 204,0,0
>> z = 0,0,153
>> y1 = 25,0,0
>> z1 = 255,255,0
>>
>> while True:
>>   play(song)
>>   play(song)
>>   sense.show_message("!!! Intuder Alert ", x, y, z)
>>
>> Now if I boot the Pi and then run the script it runs fine and the
>> sound plays.
>>
>> However if I use
>>
>> @reboot python3 /home/pi/intruder.py via a cron job, the message is
>> displayed but no sound.
>
> I think I had this issue.  The permissions on sound channels are weird.
> I wanted the web server (user www-data) to play sounds - it wouldn't
> until I did something to it...
>
> OK I  just logged in to that machine
>
> in /etc/group is this line:
>
> audio:x:29:me,www-data,pulse,root
>
> I suggest you add at least root and probably pulse to the audio group
>

Hi - thanks for your help - tired that but still no sound

Re: Help With Sense Hat Python Script

<8JSdnTuBy-nyCBj4nZ2dnZfqn_udnZ2d@brightview.co.uk>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=8479&group=comp.sys.raspberry-pi#8479

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!i2pn.org!news.furie.org.uk!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 22 Dec 2023 13:55:59 +0000
Subject: Re: Help With Sense Hat Python Script
Newsgroups: comp.sys.raspberry-pi
References: <JSidnaAITuhW1hj4nZ2dnZfqnPidnZ2d@brightview.co.uk>
<um3m5g$1gu1j$6@dont-email.me>
<1GmdnXHq5eDVCRj4nZ2dnZfqn_SdnZ2d@brightview.co.uk>
From: no.spam@me.com (Dr Stephen Strange)
Date: Fri, 22 Dec 2023 13:55:59 +0000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 14.2; rv:91.0)
Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.18
MIME-Version: 1.0
In-Reply-To: <1GmdnXHq5eDVCRj4nZ2dnZfqn_SdnZ2d@brightview.co.uk>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Message-ID: <8JSdnTuBy-nyCBj4nZ2dnZfqn_udnZ2d@brightview.co.uk>
Lines: 49
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-lH861ThQncj5La7tLGJSPxCMbO9ntGDun112nMd+svDX4G4WgrzzYQnt6CwdHLkfLPulm8VO8hLn8ND!xXCyOZ6JrwvqGslnFjT3xzAzz5IJeWgcFI+uCjsm+rGDIbdJQ9OQztwd//j5cKdHKTdJwfqBBZ/9!jJdAKQea1kIjo1Krbo+UAiisOA==
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 2633
 by: Dr Stephen Strange - Fri, 22 Dec 2023 13:55 UTC

Dr Stephen Strange wrote:
> The Natural Philosopher wrote:
>> On 22/12/2023 08:41, Dr Stephen Strange wrote:
>>> I have a Sense Hat and want to run this oython script at boot:
>>>
>>> from sense_hat import SenseHat
>>> from pydub import AudioSegment
>>> from pydub.playback import play
>>>
>>> song = AudioSegment.from_wav("/home/pi/redalert.wav")
>>>
>>> sense = SenseHat()
>>>
>>> x = 0.1
>>> y = 204,0,0
>>> z = 0,0,153
>>> y1 = 25,0,0
>>> z1 = 255,255,0
>>>
>>> while True:
>>>   play(song)
>>>   play(song)
>>>   sense.show_message("!!! Intuder Alert ", x, y, z)
>>>
>>> Now if I boot the Pi and then run the script it runs fine and the
>>> sound plays.
>>>
>>> However if I use
>>>
>>> @reboot python3 /home/pi/intruder.py via a cron job, the message is
>>> displayed but no sound.
>>
>> I think I had this issue.  The permissions on sound channels are
>> weird. I wanted the web server (user www-data) to play sounds - it
>> wouldn't until I did something to it...
>>
>> OK I  just logged in to that machine
>>
>> in /etc/group is this line:
>>
>> audio:x:29:me,www-data,pulse,root
>>
>> I suggest you add at least root and probably pulse to the audio group
>>
>
>
> Hi - thanks for your help - tired that but still no sound

That is *TRIED* but still no sound!!!

Re: Help With Sense Hat Python Script

<um4cn9$1kl6c$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=8481&group=comp.sys.raspberry-pi#8481

  copy link   Newsgroups: comp.sys.raspberry-pi
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tnp@invalid.invalid (The Natural Philosopher)
Newsgroups: comp.sys.raspberry-pi
Subject: Re: Help With Sense Hat Python Script
Date: Fri, 22 Dec 2023 16:15:36 +0000
Organization: A little, after lunch
Lines: 89
Message-ID: <um4cn9$1kl6c$1@dont-email.me>
References: <JSidnaAITuhW1hj4nZ2dnZfqnPidnZ2d@brightview.co.uk>
<um3m5g$1gu1j$6@dont-email.me>
<1GmdnXHq5eDVCRj4nZ2dnZfqn_SdnZ2d@brightview.co.uk>
<8JSdnTuBy-nyCBj4nZ2dnZfqn_udnZ2d@brightview.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 22 Dec 2023 16:15:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="23e37881c39b9e3a9926c4e008af3ba4";
logging-data="1725644"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sVDsnyU2/V/uQ3W96Ihtz8BvnbJ3Q6mw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:YOILkQ2xKIf1gUlSSb45geMCXEg=
In-Reply-To: <8JSdnTuBy-nyCBj4nZ2dnZfqn_udnZ2d@brightview.co.uk>
Content-Language: en-GB
 by: The Natural Philosop - Fri, 22 Dec 2023 16:15 UTC

On 22/12/2023 13:55, Dr Stephen Strange wrote:
> Dr Stephen Strange wrote:
>> The Natural Philosopher wrote:
>>> On 22/12/2023 08:41, Dr Stephen Strange wrote:
>>>> I have a Sense Hat and want to run this oython script at boot:
>>>>
>>>> from sense_hat import SenseHat
>>>> from pydub import AudioSegment
>>>> from pydub.playback import play
>>>>
>>>> song = AudioSegment.from_wav("/home/pi/redalert.wav")
>>>>
>>>> sense = SenseHat()
>>>>
>>>> x = 0.1
>>>> y = 204,0,0
>>>> z = 0,0,153
>>>> y1 = 25,0,0
>>>> z1 = 255,255,0
>>>>
>>>> while True:
>>>>   play(song)
>>>>   play(song)
>>>>   sense.show_message("!!! Intuder Alert ", x, y, z)
>>>>
>>>> Now if I boot the Pi and then run the script it runs fine and the
>>>> sound plays.
>>>>
>>>> However if I use
>>>>
>>>> @reboot python3 /home/pi/intruder.py via a cron job, the message is
>>>> displayed but no sound.
>>>
>>> I think I had this issue.  The permissions on sound channels are
>>> weird. I wanted the web server (user www-data) to play sounds - it
>>> wouldn't until I did something to it...
>>>
>>> OK I  just logged in to that machine
>>>
>>> in /etc/group is this line:
>>>
>>> audio:x:29:me,www-data,pulse,root
>>>
>>> I suggest you add at least root and probably pulse to the audio group
>>>
>>
>>
>> Hi - thanks for your help - tired that but still no sound
>
> That is *TRIED* but still no sound!!!

Strange. You did reboot etc afterwards?

Try making the script do a 'who am i' so you can see who is in fact the
owning process.

And look in the log files.

Looking in stack overflow it seems that a 60 second sleep before
executing the script may allow stuff to settle down, but you probably
ought to be using systemd to start the script..e.g

/usr/lib/systemd/system/intruder.service

[Unit]
Description=Intruder Server

[Install]
WantedBy=multi-user.target

[Service]
ExecStart=/bin/bash /home/you/yourscript.py
Type=simple
User=root
Group=root
WorkingDirectory=/home/you
Restart=on-failure

Put this in a file /usr/lib/systemd/system/intruder.service. Then run
systemctl daemon-reload (once, and whenever you change intruder.service
to tell systemd to re-read the configuration) and systemctl start
intruder.service to start the e server.

If that works as expected, you can use systemctl enable intruder.service
to make sure it starts at boot.

--
The New Left are the people they warned you about.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor