Python's tail -f implementation for remote files
Basically what i want to do is to read a file
that is being constantly appended to but which
is located on a remote server.
I found this for doing BASH's tail -f in python:
import os
tailoutputfile = os.popen('tail -f syslog')
while 1:
line = tailoutputfile.readline()
if len(line)==0: # change the termination condition
break
process_line(line)
and it works great. But not sure how to use this with
ssh command to connect to remote machine.
Any tips?
--
http://mail.python.org/mailman/listinfo/python-list
Dynamic HTML from Python Script
I have a python script whose output i want to dynamically display on a webpage which will be hosted using Apache. How do I do that? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic HTML from Python Script
> Well, there's a few ways you could approach it. > > You could create a cgi program from your script - this is probably the > solution you're looking for. > Output from the script does come up very often. There is a new output every 10 secs and it's possible that the script might be run indefinitely. Basically I want all that output displayed in a web browser > You could have the script run periodically and create a static html file > in the webroot... this would be acceptable, maybe preferable, if the > output from your script doesn't change frequently. > -- http://mail.python.org/mailman/listinfo/python-list
Re: Dynamic HTML from Python Script
On Wed, 11 Jun 2008 11:20:48 +1000, Aidan wrote: > asdf wrote: >>> Well, there's a few ways you could approach it. >>> >>> You could create a cgi program from your script - this is probably the >>> solution you're looking for. >>> >>> >> Output from the script does come up very often. There is a new output >> every 10 secs and it's possible that the script might be run >> indefinitely. Basically I want all that output displayed in a web >> browser > > Well, in that case you could simply append the new output to a static > file every 10 seconds, or whenever there is new output. That way, you > just need to refresh the static file in your browser to see updates... > Given what I understand of your situation, that's how I'd do it. > The problem with this is that browser would have to be refreshed manually every 10 seconds. Unless there is a way to set this in the script itself. > A constantly running CGI app is probably not the best idea, given > timeouts and other such constraints you might run into. > > >>> You could have the script run periodically and create a static html >>> file in the webroot... this would be acceptable, maybe preferable, if >>> the output from your script doesn't change frequently. >>> -- http://mail.python.org/mailman/listinfo/python-list
matplotlib question
basically I need to plot a graph of data vs time. However when i use matplotlib the hr:min tick marks come out very close together and appear jumbled. So 12:00 comes out very close to 12:30 for example. There are two things I would like to do. First, is to increase the horizontal dimension of the graph. So basically increase the horizontal number of pixels. The data will always be from midnight to midnight it's just that i want it stretched out more horizontally. Also, how do i specify that i only want hourly tickmarks. So under the x-axis i only want to see 12:00 1:00 etc. thanks -- http://mail.python.org/mailman/listinfo/python-list
2Q's: How to autocreate instance of class;How to check for membership in a class
So I'm writing a script which will create several instances of User() class. I want each instance to be named after the login name of a user. I don't know beforehand how many users the script will have to create or how they are named. Right now I've created a dictionary of usernames as keys and objects themselves as values. It works, but is very unwieldy, because every time I need to access a value from within an object I have to do something like dict-user[x].value. Is there a way of automatically naming objects from variable names. So for example if I know that var1=jsmith. Can I somehow do var1=User(). This obviously won't work because I tried this. It'll just create var1 of type User. My second question is how can I check if object is a member of a class. so let's say I create a=User(), b=User()... Can I do something similar to if x.Users()==TRUE: print "user already created" Right now I'm doing this using try-except which works but I'm looking for something cleaner. thanks for all the replies. -- http://mail.python.org/mailman/listinfo/python-list
Parse specific text in email body to CSV file
I have been searching all over for a solution to this. I am new to Python, so I'm a little lost. Any pointers would be a great help. I have a couple hundred emails that contain data I would like to incorporate into a database or CSV file. I want to search the email for specific text. The emails basically look like this: random text _important text:_15648 random text random text random text random text random text random text random text _important text:_15493 random text random text random text random text _important text:_11674 random text random text random text ===Date: Wednesday March 5, 2008 name1: 15name5: 14 name2: 18name6: 105 name3: 64name7: 2 name4: 24name8: 13 I want information like "name1: 15" to be placed into the CSV with the name "name1" and the value "15". The same goes for the date and "_important text:_15493". I would like to use this CSV or database to plot a graph with the data. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
