Automate webpage refresh

D

DarkBlue

I am trying to write a script (python2.3) which will be used
with linux konqueror to retrive 2 webpages alternatively every 2 minutes.

My question is how can I send alternative args (the url)
to the same invocation of konqueror which I started with

def pipedreams(program, *args):
pid = os.fork()
if not pid:
os.execvp(program, (program,) + args)
return os.wait()[0]

pipedreams("konqueror",url1)

Obviously every time I call pipedreams I would open a new instance
which is exactly what I do not want.

My pseudocode :

if timecounter == 60 :
send url1 to konqueror to fetch & display
elif timecounter == 120:
send url2 to konqueror to fetch % display
timecounter = 0



Thanks for any hints
D.B.
 
C

Carl Friedrich Bolz

Hi!
I am trying to write a script (python2.3) which will be used
with linux konqueror to retrive 2 webpages alternatively every 2 minutes.

My question is how can I send alternative args (the url)
to the same invocation of konqueror which I started with

This can be done using dcop, the KDE interprocess communication system.
dcop can be used as a simple command line utility that sends messages
to running applications. The easiest way to use it is to just play
around with it on the commandline. For the konqueror usecase you would
do something like:

dcop konqueror-<pid> konqueror-mainwindow#1 openURL "http://google.net"

this command can easily be executed with os.system.

Hope this gave some hints,

Carl Friedrich Bolz
 
M

Mike Meyer

DarkBlue said:
I am trying to write a script (python2.3) which will be used
with linux konqueror to retrive 2 webpages alternatively every 2 minutes.

My question is how can I send alternative args (the url)
to the same invocation of konqueror which I started with

def pipedreams(program, *args):
pid = os.fork()
if not pid:
os.execvp(program, (program,) + args)
return os.wait()[0]

pipedreams("konqueror",url1)

Obviously every time I call pipedreams I would open a new instance
which is exactly what I do not want.

No, that's not at all obvious. Some browsers will notice the
previously running instance, and tell it to load the page - basically
doing exactly what you want. Some take special flags to do that.

The webbrowser module abstracts all these differences out for
you. Since it has support for Konquerer, your code should look like this:

# Untested - I don't have Konquer installed.

import webbrowser
webbrowser.open(url1)

You may have to set the BROWSER environment variable to get it to find
Konquerer.

<mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top