maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   python help plz (https://talk.maemo.org/showthread.php?t=52319)

bonkel 2010-05-10 14:49

NeutrinorRemote...python help plz
 
hi, I would like to make a python script to run http:// commands like
wget -q http://192.168.2.45/control/rcem?KEY_HOME

but i don't know , how can i make it, i'm not fit in python,
I would like to make buttons to click. like:

1 (command: wget -q http://192.168.2.45/control/rcem?KEY_1)
2 (command: wget -q http://192.168.2.45/control/rcem?KEY_2)
..
10 (command: wget -q http://192.168.2.45/control/rcem?KEY_10)
Red (command: wget -q http://192.168.2.45/control/rcem?KEY_RED)
Exit (command: wget -q http://192.168.2.45/control/rcem?KEY_HOME)

etc.

how can i make that??
a little help start , would be nice..

demiurgus 2010-05-10 14:53

Re: python help plz
 
Look into python standard library subprocess

noobmonkey 2010-05-10 15:05

Re: python help plz
 
Code:

import os
os.popen(command)


Slocan 2010-05-10 15:39

Re: python help plz
 
If you don't want to use a subprocess to start wget, you can use the urllib2 module ( http://docs.python.org/library/ ) :
Code:

import urllib2
f = urllib2.urlopen('http://192.168.2.45/control/rcem?KEY_HOME')
data = f.read()
f.close()


bonkel 2010-05-10 16:29

Re: python help plz
 
Quote:

Originally Posted by Slocan (Post 651974)
If you don't want to use a subprocess to start wget, you can use the urllib2 module ( http://docs.python.org/library/ ) :
Code:

import urllib2
f = urllib2.urlopen('http://192.168.2.45/control/rcem?KEY_HOME')
data = f.read()
f.close()


this works faster, how can i build it into a button?

Slocan 2010-05-10 17:10

Re: python help plz
 
Check this out:
http://www.pygtk.org/pygtk2tutorial/.../helloworld.py
Add the urrlib2 code into the the def hello(...) function.
Once you get the one button working, then you can copy/paste the button creation code to create the multiple buttons, and place them into a gtk.VBox (a container for your buttons).

mikec 2010-05-10 20:47

Re: python help plz
 
why dont you just use the desktop execution widget in the repos

http://talk.maemo.org/showthread.php...ktop+execution

bonkel 2010-05-12 23:15

Re: python help plz
 
after some reading, ive finish my python, not nice, but my first :D

http://i42.tinypic.com/63vwh3.jpg

clasificado 2010-05-12 23:17

Re: python help plz
 
Hey! congrats mate!

bonkel 2010-05-13 03:31

Re: python help plz
 
any idea to replate all ip's with only one?

like:

IP = 192.168.2.45

urllib2.urlopen('http://IP/control/rcem?KEY_HOME')

BrentDC 2010-05-13 04:12

Re: python help plz
 
Quote:

Originally Posted by bonkel (Post 656354)
any idea to replate all ip's with only one?

like:

IP = 192.168.2.45

urllib2.urlopen('http://IP/control/rcem?KEY_HOME')

Is this what you mean?



IP = '192.168.2.45'

urllib2.urlopen('http://' + IP + '/control/rcem?KEY_HOME')

GreatGonzo 2010-05-13 04:50

Re: python help plz
 
or

Code:

IP = '192.168.2.45'
url = "http://%s/control/rcmem?%s"
# redefine for each key
keycode = "KEY_HOME"
urlib2.urlopen(url % (IP, keycode))


helex 2010-05-13 08:15

Re: python help plz
 
Quote:

Originally Posted by bonkel (Post 656159)
after some reading, ive finish my python, not nice, but my first :D

http://i42.tinypic.com/63vwh3.jpg

Oh, nice. :) I've done something similar and finished just last sunday. Currently I'm waiting since 3 days for the maemo Extras approval to upload the first version to autobuilder. Today it is a official holiday day here in my country. So I have time for testing but still no answer from the garage guys... so, lets wait and see when I have again time for it. :(
When it is ready I'll post a link! :)

But mine is in contrast for the Dreambox Receivers. Is your software is for the tuxbox? German: GNU DBox2 Software Projekt

rohanhole 2010-05-13 08:39

Re: python help plz
 
First Learn python , i bet u wont ask such questions again !!
Basics of python is enugg .. and for GUI. use pygtk.

bonkel 2010-05-13 13:48

Re: python help plz
 
Quote:

Originally Posted by helex (Post 656501)

But mine is in contrast for the Dreambox Receivers. Is your software is for the tuxbox? German: GNU DBox2 Software Projekt

yeah its for dbox or coolstream, or the sh4 receivers with neutrino-hd.
i can change the links ,then it works with enigma2 too :D
sh4 duckbox git (e2,neutrino-HD and vdr)

bonkel 2010-05-13 16:25

Re: python help plz
 
now i play with images:

normal:
http://i40.tinypic.com/2hqa4nd.jpg

pressed arrow button:
http://i41.tinypic.com/9u6s7a.jpg

pressed ok button:
http://i39.tinypic.com/11qipoh.jpg


follow: volume up,down buttons .
play,stop,rec usw.

helex 2010-05-13 17:23

Re: python help plz
 
Quote:

Originally Posted by bonkel (Post 656832)
yeah its for dbox or coolstream, or the sh4 receivers with neutrino-hd.
i can change the links ,then it works with enigma2 too :D
sh4 duckbox git (e2,neutrino-HD and vdr)

Yes, thats true. Thanks for the offer. :)
I worked the last weeks on a remote (only) for the Dreambox (I don't know much about other linux based home entertainment systems), I answerd this morning in your app request thread. (Sorry, haven't seen it before this morning. Otherwise I had answered before. :o)

So it's not needed for me to change the links in your application. I finished mine already for my needs. :)
But if you wan't we can work together to get it for your neutrino-HD box working.

If you have more fun in learning and programming I wouldn't integrate the neutrino functionality in my application and let you enjoy what you're developing. :)

Get a working result out of hard work is very important. I know that! ;)

bonkel 2010-05-14 18:33

Re: python help plz
 
i think i'm done....looks cool for me.. ..
if someone wants to test


http://rapidshare.com/files/38733251...rinoRemote.zip

aspidites 2010-05-14 18:45

Re: python help plz
 
Quote:

Originally Posted by bonkel (Post 658727)
i think i'm done....looks cool for me.. ..
if someone wants to test


http://rapidshare.com/files/38733251...rinoRemote.zip

Rapidshare is annoying. Just attach it to the thread directly (manage attachments button)

bonkel 2010-05-14 19:02

Re: python help plz
 
Quote:

Originally Posted by aspidites (Post 658734)
Rapidshare is annoying. Just attach it to the thread directly (manage attachments button)

Your file of 769.5 KB bytes exceeds the forum's limit of 488.3 KB for this filetype.

aspidites 2010-05-14 19:39

Re: python help plz
 
Quote:

Originally Posted by bonkel (Post 658759)
Your file of 769.5 KB bytes exceeds the forum's limit of 488.3 KB for this filetype.

Python program that large? Wow. Oh wait, using custom images...got it. :(

Downloading via rapidshare...

bonkel 2010-05-14 20:04

Re: python help plz
 
Quote:

Originally Posted by aspidites (Post 658813)
Python program that large? Wow. Oh wait, using custom images...got it. :(

Downloading via rapidshare...

sry...........

aspidites 2010-05-14 20:18

Re: python help plz
 
@bonkel: Any reason you aren't using Designer? Nothing wrong with doing things by hand, but it may speed up development for you. Also, any reason you don't have an __init__() method for your class?

helex 2010-05-24 18:42

Re: python help plz
 
Are you still continuing this project to make a proper application out of it?

helex 2010-07-29 11:11

Re: python help plz
 
1 Attachment(s)
Quote:

Originally Posted by helex (Post 673732)
Are you still continuing this project to make a proper application out of it?

Okay, more than 2 Months no answer for my question and still not in extra-devel. :(
So I guess the development of your small project is totally abadoned?

I got several requests to integrate dbox2 support (Neutrino Image) into my DreamRemote. After a long time of waiting I integrated yesterday the support. I attached a screenshot and I will upload the new version next Weekend to extra devel. Only to inform all followers of this thread.


All times are GMT. The time now is 11:59.

vBulletin® Version 3.8.8