Active Topics

 


Reply
Thread Tools
Posts: 102 | Thanked: 17 times | Joined on Mar 2010 @ Herne,Germany
#1
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..

Last edited by bonkel; 2010-05-14 at 18:34.
 
demiurgus's Avatar
Posts: 40 | Thanked: 86 times | Joined on Dec 2009 @ Sweden
#2
Look into python standard library subprocess
 

The Following 2 Users Say Thank You to demiurgus For This Useful Post:
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#3
Code:
import os
os.popen(command)
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 

The Following User Says Thank You to noobmonkey For This Useful Post:
Posts: 324 | Thanked: 371 times | Joined on Dec 2009 @ Vancouver, BC
#4
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()
 

The Following User Says Thank You to Slocan For This Useful Post:
Posts: 102 | Thanked: 17 times | Joined on Mar 2010 @ Herne,Germany
#5
Originally Posted by Slocan View Post
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?
 
Posts: 324 | Thanked: 371 times | Joined on Dec 2009 @ Vancouver, BC
#6
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's Avatar
Posts: 1,366 | Thanked: 1,185 times | Joined on Jan 2006
#7
why dont you just use the desktop execution widget in the repos

http://talk.maemo.org/showthread.php...ktop+execution
__________________
N900_Email_Options Wiki Page
 
Posts: 102 | Thanked: 17 times | Joined on Mar 2010 @ Herne,Germany
#8
after some reading, ive finish my python, not nice, but my first

 

The Following 4 Users Say Thank You to bonkel For This Useful Post:
clasificado's Avatar
Posts: 466 | Thanked: 180 times | Joined on Feb 2010
#9
Hey! congrats mate!
 
Posts: 102 | Thanked: 17 times | Joined on Mar 2010 @ Herne,Germany
#10
any idea to replate all ip's with only one?

like:

IP = 192.168.2.45

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


 
Forum Jump


All times are GMT. The time now is 18:03.