Go to advanced search

by elParaguayo
Tue Oct 03, 2017 5:49 pm
Forum: Python
Topic: ImportError: No module named sh
Replies: 3
Views: 4512

Re: ImportError: No module named sh

You've installed the module for python 3 but I suspect you're running your script with python 2. Have you tried running your script with python3 e.g. "python3 capture.py"?
by elParaguayo
Tue Oct 03, 2017 1:06 pm
Forum: General programming discussion
Topic: Sync Time from Internet
Replies: 20
Views: 56051

Re: Sync Time from Internet

I've never used timedatectl before (but like learning things) so what's below is just my observations/research and Dougie can correct me if I get it wrong: The command has done exactly what it's meant to do - you have set the time to the specified time and date (see the man page for an explanation)....
by elParaguayo
Sun Oct 01, 2017 6:46 pm
Forum: Python
Topic: Calling functions within threads
Replies: 4
Views: 762

Re: Calling functions within threads

Thanks. I couldn't be bothered to test it but I was surprised that that example didn't work.

Does super handle multiple inheritance? Also, it can be easier to use super e.g. no need to update if you change an inherited class.
by elParaguayo
Sat Sep 30, 2017 6:41 pm
Forum: Python
Topic: Calling functions within threads
Replies: 4
Views: 762

Re: Calling functions within threads

Been a while since I've done this. Could you just do: def do_stuff(): # do stuff here class Arm_Thread(threading.Thread): def __init__(self, threadID, name, counter, func): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = counter self.func = func def run(self)...
by elParaguayo
Sat Sep 30, 2017 10:08 am
Forum: Python
Topic: GPIOZero - 2 fonction for same GPIO ?
Replies: 17
Views: 2662

Re: GPIOZero - 2 fonction for same GPIO ?

I guess I'm missing something here. Wouldn't active_time return the amount of time the button has been held while it is being held and, once the button is released, the relevant time is now in hold_time (and active_time is None as the button is now inactive)? If that's the case then comparing them d...
by elParaguayo
Sat Sep 30, 2017 9:49 am
Forum: Python
Topic: Time Function
Replies: 33
Views: 10456

Re: Time Function

You're probably right. The GIL is one of those things that I'll never really understand and I'm ok with that!
by elParaguayo
Fri Sep 29, 2017 1:29 pm
Forum: Python
Topic: Time Function
Replies: 33
Views: 10456

Re: Time Function

Wasn't expecting this... Ran my sleep threads with niceness 19 and a "cpu_hog" code (10 threads using your example loops) with a niceness of -20 and got this: Thread: 0 Nice: 19 Duration: 1000.094957 Thread: 1 Nice: 19 Duration: 1009.848235 Thread: 2 Nice: 19 Duration: 1009.848586 Thread: 3 Nice: 19...
by elParaguayo
Fri Sep 29, 2017 10:41 am
Forum: Python
Topic: Dial a number from python
Replies: 11
Views: 1733

Re: Dial a number from python

In your first post you said you did "ATD(123456789)", I don't think you want the brackets in there so try "ATD123456789". There's also mention about ending with semicolon but I think that's only for voice calls so may not be relevant here.

Good luck and post your code if you need further help.
by elParaguayo
Fri Sep 29, 2017 10:24 am
Forum: Python
Topic: Dial a number from python
Replies: 11
Views: 1733

Re: Dial a number from python

The examples in paddy's link show you how to send GSM commands (using ser.write), so can't you just substitute your ATD command in its place?
by elParaguayo
Fri Sep 29, 2017 9:34 am
Forum: Python
Topic: Time Function
Replies: 33
Views: 10456

Re: Time Function

I wrote a short script to time 1000s sleeps at different niceness levels. Nothing really changed (see below) but I suspect that's because my pi was idle other than this script. I'm curious to see if the 500ms limit does apply - what's the best way to get the cpu busy on something else? Results: Thre...
by elParaguayo
Thu Sep 28, 2017 12:55 pm
Forum: Python
Topic: Time Function
Replies: 33
Views: 10456

Re: Time Function

....Meaning that in theory, if you would have it wait for 1000 seconds (a bit more than 16 minutes), it would actually wait 1001 seconds After some testing I can confirm this is NOT the case. I am getting results of 1000.10, 1000.09, 1000.04, 1000.08 and 1000.10. The added delay does not stack up f...
by elParaguayo
Thu Sep 28, 2017 9:40 am
Forum: Python
Topic: Can anyone change my Python 2.7 code to Python 3?
Replies: 12
Views: 1810

Re: Can anyone change my Python 2.7 code to Python 3?

Doesn't it seem like someone should write an automated converter program (if such has not already been done) ? I wonder what googling for "convert python 2 to python 3" would reveal... I tried to use the converting program that Python had. I asked on this forum because it didn't work. Sorry if I bo...
by elParaguayo
Thu Sep 28, 2017 9:16 am
Forum: Python
Topic: Time Function
Replies: 33
Views: 10456

Re: Time Function

Is that the same thing though? I thought the problem being highlighted was when the length of the sleep increased. In your example, the sleep is always 1 second and never increases. EDIT: a lot of this thread is above my head (but interesting nonetheless) so it's perfectly possible that I've misunde...
by elParaguayo
Wed Sep 27, 2017 8:17 am
Forum: Python
Topic: guizero - display loop progress %
Replies: 4
Views: 1242

Re: guizero - display loop progress %

I completely agree with RDS. I'm much more likely to provide more help if there's some show of gratitude.

So... welcome to the forum and I hope you enjoy learning how to program your pi!
by elParaguayo
Wed Sep 27, 2017 8:13 am
Forum: Python
Topic: GPIOZero - 2 fonction for same GPIO ?
Replies: 17
Views: 2662

Re: GPIOZero - 2 fonction for same GPIO ?

The error message is quite clear in explaining the problem. You are trying to see if but.active_time is less than but.hold_time. The problem is that but.active_time has a value of None. You can't compare None to a numerical value hence the error (actually, I think python 2 allows this but python 3 d...
by elParaguayo
Sat Sep 23, 2017 2:19 pm
Forum: Python
Topic: How to run GUI application at boot
Replies: 11
Views: 20796

Re: How to run GUI application at boot

Ha. Good piece of software to use as an example! :D
by elParaguayo
Sat Sep 23, 2017 6:02 am
Forum: Python
Topic: XBox 360 controller I want something to happen when button A is keydown.
Replies: 2
Views: 574

Re: XBox 360 controller I want something to happen when button A is keydown.

I agree with paddy. Your code confused me at the beginning as I just saw the "input(pygame.event.get())" line which made no sense if input was the built in function... Back to your problem: it's not immediately clear what your problem is. Are the print statements not displaying when you press the bu...
by elParaguayo
Fri Sep 22, 2017 3:44 pm
Forum: Python
Topic: Upload Temprature data online on Thinkspeak server
Replies: 1
Views: 389

Re: Upload Temprature data online on Thinkspeak server

Have you looked at the API documentation for details on sending updates?

I'm not sure you should be using that URL to post updates.

EDIT: Looks like there's also a python module for uploading data. See the docs for more.
by elParaguayo
Wed Sep 20, 2017 7:45 pm
Forum: Python
Topic: Control-C in Python
Replies: 9
Views: 3192

Re: Control-C in Python

Try changing cmd_two as follows: cmd_two = ['mv', '/home/pi/voice-recognizer-raspi/src/music/test_record.wav', '/home/pi/voice-recognizer-raspi/src/music/test_record_old.wav'] You also don't need to terminate cmd_two as it will complete instantly. However, it's worth noting that you can use the os m...
by elParaguayo
Wed Sep 20, 2017 11:44 am
Forum: Python
Topic: Python open()
Replies: 6
Views: 2115

Re: Python open()

When you say you "find this article helpful", did you actually write it? I only ask because there's a fair bit of similarity between your username here and the article's author and this also feels a bit like self-promotion because the last post before yours was a few months ago. Please don't misunde...
by elParaguayo
Mon Sep 18, 2017 8:04 am
Forum: Python
Topic: PiFace Digital 2 Button Press Event Listener in Python
Replies: 1
Views: 619

Re: PiFace Digital 2 Button Press Event Listener in Python

The problem is that you're using the "pfd" instance whereas InputEventListener is actually a separate class in pifacedigitalio. See the documentation here.

try this instead:

Code: Select all

listener = pifacedigitalio.InputEventListener(chip=pfd)
by elParaguayo
Wed Sep 06, 2017 5:43 pm
Forum: Python
Topic: insert python in kivy code
Replies: 2
Views: 977

Re: insert python in kivy code

I think you can also use threaded callbacks in kivy rather than using a clock to check the state.

It's been a while since I used kivy though...
by elParaguayo
Mon Sep 04, 2017 7:19 pm
Forum: Python
Topic: Alarm clock
Replies: 14
Views: 2167

Re: Alarm clock

We may agree to disagree on whether it's fair compensation (I prefer to share my code freely and you've said this is based on someone else's code) but I still have no idea what your question is. What is the problem with your code?
by elParaguayo
Mon Sep 04, 2017 6:38 pm
Forum: Python
Topic: Alarm clock
Replies: 14
Views: 2167

Re: Alarm clock

Porbos, Did you have a question? You also haven't posted any code so there's really nothing that anybody can do at the moment. However, if you're just asking someone to write code for you because you don't have time then I don't think you'll have much luck (unless someone is feeling very generous). ...
by elParaguayo
Fri Sep 01, 2017 5:38 pm
Forum: Python
Topic: Python Launch on Boot
Replies: 1
Views: 339

Re: Python Launch on Boot

This is a question that gets asked a lot so have a search and you'll see numerous options.

Personally, I use systemd to start and stop scripts. There's a good example of getting this going here.

Go to advanced search