[python-advocacy] py is fun
Carl Karsten
carl at personnelware.com
Sun Apr 1 16:35:40 CEST 2007
Just saw this on a mail list. seemed worth passing on.
Carl K
-------- Original Message --------
From: Matthew Turner <thshdwknws at hotmail.com>
To: vnc2swf-users at lists.sourceforge.net
For fun, - I don't know any python either :-) - I did some searching on the
net to see if I could come up with a way to stop the recording from the
command line I tried this:
------------------------------------------------------------------------
def SomeMethod(procname_ori):
import win32api
import win32pdh
import win32con
import win32pdhutil
import sys
print "killing " + procname_ori
try:
win32pdhutil.GetPerformanceAttributes('Process','ID
Process',procname_ori)
except:
pass
pids = win32pdhutil.FindPerformanceAttributesByName(procname_ori)
try:
pids.remove(win32api.GetCurrentProcessId())
except ValueError:
pass
if len(pids)==0:
result = "Can't find %s" % procname_ori
elif len(pids)>1:
result = "Found too many %s's - pids=`%s`" % (procname,pids)
else:
handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0,pids[0])
win32api.TerminateProcess(handle,0)
win32api.CloseHandle(handle)
result = ""
return result
SomeMethod = staticmethod(SomeMethod)
elif k == "-q":
Subprocess.SomeMethod("python")
-----------------------------------------------------------------------------
I started vnc2swf.py -n -o test.swf -t video
after the recording started I ran the new switch vnc2swf.py -n -q kill
it stopped the original vnc2swf.py thread but it terminated it before the
swf could be saved and it cuased corruption in the swf.
I also tried this code
--------------------------------------------------------------------------
def Test(port_name):
import socket
Host = "localhost"
Port = port_name
# reference time (in seconds since 1900-01-01 00:00:00)
# connect to server
s = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.connect((Host, port_name))
s.send("somthing")
data = s.recv(1024)
s.close ()
print 'Received', repr(data)
myFunc = staticmethod(Test)
elif k == "-q":
Subprocess.Test(5900)
-------------------------------------------------------------
in the above code I'm not sure what to tell RFB, or if its even
communicating too RFB, to stop the communications on localhost :5900.
Even though I failed it was fun playing with python. I think I'm missing a
lot of things namely taking to the same thread that the recording is on.
Anyway maybe all this better explains what I'm trying to accomplish.
Thanks
Matt
>From: "Matthew Turner" <thshdwknws at hotmail.com>
>Reply-To: General discussion about vnc2swf
><vnc2swf-users at lists.sourceforge.net>
>To: vnc2swf-users at lists.sourceforge.net
>Subject: [Vnc2swf-users] -Request- Quit command line option
>Date: Fri, 23 Mar 2007 00:08:48 -0700
>
>Hello
>Is there a command line parameter for vnc2swf.py to end a connection? If
>not
>would be a difficult feature to add?
>
>I have automated some steps to connect remotely. Currently to end the
>connection and save the swf I remotely run an ultravnc command:
>
>winvnc -kill
>
>This works fine, however it also stops my vnc remote session. What I would
>like to do is pass a parameter to vnc2swf to safely stop the recording and
>save the file maybe something like
>
>vnc2swf.py -q
>
>I could then remotely start another recording without losing my vnc
>connection.
>
>Thanks for your work on this project,
>
>Matt
>
>
>
>-------------------------------------------------------------------------
>Take Surveys. Earn Cash. Influence the Future of IT
>Join SourceForge.net's Techsay panel and you'll get the chance to share
>your
>opinions on IT & business topics through brief surveys-and earn cash
>http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>_______________________________________________
>Vnc2swf-users mailing list
>Vnc2swf-users at lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/vnc2swf-users
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Vnc2swf-users mailing list
Vnc2swf-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vnc2swf-users
More information about the Advocacy
mailing list