From bfrisch at edam.speech.cs.cmu.edu Mon Jul 2 19:10:21 2007 From: bfrisch at edam.speech.cs.cmu.edu (bfrisch@edam.speech.cs.cmu.edu) Date: Mon, 2 Jul 2007 19:10:21 -0400 Subject: [RavenclawDev 285] [927] Tools/MakeLM/makelm.pl: Updating MakeLM to work with Active State Perl Message-ID: <200707022310.l62NAL3g018702@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/ravenclaw-developers/attachments/20070702/c81c48e4/attachment.html -------------- next part -------------- Modified: Tools/MakeLM/makelm.pl =================================================================== --- Tools/MakeLM/makelm.pl 2007-06-16 15:51:30 UTC (rev 926) +++ Tools/MakeLM/makelm.pl 2007-07-02 23:10:19 UTC (rev 927) @@ -4,7 +4,6 @@ use HTTP::Request::Common; use File::Spec; use File::Copy; -use File::stat; use IO::Handle; use IPC::Open2; use Getopt::Long; @@ -22,7 +21,7 @@ open(LOG, ">$LOGFILE") if $LOGFILE; #need access to cygwin dir so that cygwin1.dll can be found -$ENV{'Path'} .= ($ENV{'CYGWIN_DIR'} || 'C:\cygwin').'\bin;'; +$ENV{'Path'} .= ';'.($ENV{'CYGWIN_DIR'} || 'C:\cygwin').'\bin'; #setup default vaiables #needs to run from makelm directory @@ -202,10 +201,10 @@ my @diclines = grep !(/CONTENT-TYPE/ || /TEXT\/PLAIN/), &getdic('outfile.tmp'); unlink 'outfile.tmp'; - my @longlines = stat('longfile.tmp')->size? - grep !(/CONTENT-TYPE/ || /TEXT\/PLAIN/), &getdic('longfile.tmp'): - (); - unlink 'longfile.tmp'; + my @longlines = (stat('longfile.tmp'))[7]? + grep !(/CONTENT-TYPE/ || /TEXT\/PLAIN/), &getdic('longfile.tmp'): + (); + unlink 'longfile.tmp'; my $not_used = 1; From tk at edam.speech.cs.cmu.edu Tue Jul 3 23:00:26 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Tue, 3 Jul 2007 23:00:26 -0400 Subject: [RavenclawDev 287] [928] Pythia: 1) Extended Pythia to support remote dynamic configuration. Message-ID: <200707040300.l6430Qp7025648@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/ravenclaw-developers/attachments/20070703/00da9b6e/attachment-0001.html -------------- next part -------------- Property changes on: Pythia/PythiaDynamicClient ___________________________________________________________________ Name: svn:ignore + *.ncb *.suo *.user Added: Pythia/PythiaDynamicClient/Debug/PythiaDynamicClient.lib =================================================================== (Binary files differ) Property changes on: Pythia/PythiaDynamicClient/Debug/PythiaDynamicClient.lib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: Pythia/PythiaDynamicClient/PythiaDynamicClient.cpp =================================================================== --- Pythia/PythiaDynamicClient/PythiaDynamicClient.cpp (rev 0) +++ Pythia/PythiaDynamicClient/PythiaDynamicClient.cpp 2007-07-04 03:00:24 UTC (rev 928) @@ -0,0 +1,70 @@ +#ifdef WIN32 +#include +#else +#error fixme +#endif + +#include +#include + +#include "PythiaDynamicClient.h" + +using namespace std; + +namespace Pythia { + + const short Message::_port = 11044; + + Message::Message(const string& cmd, const string title, const string dir) : _cmd(cmd), _title(title), _dir(dir) { +#ifdef WIN32 + WSADATA wsaData; + if(WSAStartup(MAKEWORD(2,0),&wsaData)!=0) { + cerr << "Socket initialization error" << endl; + } +#endif + } + + void Message::send(const string& host) const { + SOCKET sockfd; + if((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { + cerr << "Invalid socket " << GetLastError() << endl; + return; + } + + SOCKADDR_IN servaddr; + { + memset(&servaddr, 0, sizeof(servaddr)); + servaddr.sin_family = AF_INET; + servaddr.sin_port = htons(_port); + struct hostent* hp; + if((hp = gethostbyname(host.c_str())) == NULL) { + cerr << "Unable to get hostent for " << host << endl; + return; + } + memcpy(&servaddr.sin_addr, (hp->h_addr_list)[0], sizeof(struct in_addr)); + } + + int lConnect; + if((lConnect = connect(sockfd,(SOCKADDR *)&servaddr,sizeof(SOCKADDR_IN))) != 0) { + cerr << "Connect Error" << endl; + return; + } + + string msg = formMessage(); + if(::send(sockfd, msg.c_str(), (int)msg.length() ,0) < (int)msg.length()) { + cerr << "Send Error" << endl; + } + + closesocket(sockfd); + } + + string Message::formMessage() const { + ostringstream ret; + ret << "PROCESS: " << _cmd << endl; + ret << "PROCESS_MONITOR_ARGS: --start" << endl; + if(!_dir.empty()) ret << "PROCESS_WORKDIR: " << _dir << endl; + if(!_title.empty()) ret << "PROCESS_TITLE: " << _title << endl; + return ret.str(); + } + +} \ No newline at end of file Added: Pythia/PythiaDynamicClient/PythiaDynamicClient.h =================================================================== --- Pythia/PythiaDynamicClient/PythiaDynamicClient.h (rev 0) +++ Pythia/PythiaDynamicClient/PythiaDynamicClient.h 2007-07-04 03:00:24 UTC (rev 928) @@ -0,0 +1,22 @@ +#ifndef PYTHIA_DYNAMIC_CLIENT_H +#define PYTHIA_DYNAMIC_CLIENT_H + +#include +using namespace std; + +namespace Pythia { + + class Message { + private: + string _title, _dir, _cmd; + static const short _port; + public: + Message(const string& cmd, const string title=string(), const string dir=string()); + void send(const string& host) const; + protected: + string formMessage() const; + }; + +} + +#endif \ No newline at end of file Added: Pythia/PythiaDynamicClient/PythiaDynamicClient.sln =================================================================== --- Pythia/PythiaDynamicClient/PythiaDynamicClient.sln (rev 0) +++ Pythia/PythiaDynamicClient/PythiaDynamicClient.sln 2007-07-04 03:00:24 UTC (rev 928) @@ -0,0 +1,20 @@ +? +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PythiaDynamicClient", "PythiaDynamicClient.vcproj", "{BC3C2AF0-EF36-4587-B384-E154B6EDCC33}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BC3C2AF0-EF36-4587-B384-E154B6EDCC33}.Debug|Win32.ActiveCfg = Debug|Win32 + {BC3C2AF0-EF36-4587-B384-E154B6EDCC33}.Debug|Win32.Build.0 = Debug|Win32 + {BC3C2AF0-EF36-4587-B384-E154B6EDCC33}.Release|Win32.ActiveCfg = Release|Win32 + {BC3C2AF0-EF36-4587-B384-E154B6EDCC33}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: Pythia/PythiaDynamicClient/PythiaDynamicClient.vcproj =================================================================== --- Pythia/PythiaDynamicClient/PythiaDynamicClient.vcproj (rev 0) +++ Pythia/PythiaDynamicClient/PythiaDynamicClient.vcproj 2007-07-04 03:00:24 UTC (rev 928) @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: Pythia/PythiaDynamicClient/Release/PythiaDynamicClient.lib =================================================================== (Binary files differ) Property changes on: Pythia/PythiaDynamicClient/Release/PythiaDynamicClient.lib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: Pythia/dist/library.zip =================================================================== (Binary files differ) Modified: Pythia/dist/process_monitor.exe =================================================================== (Binary files differ) Modified: Pythia/src/basic_process_monitor.py =================================================================== --- Pythia/src/basic_process_monitor.py 2007-07-02 23:10:19 UTC (rev 927) +++ Pythia/src/basic_process_monitor.py 2007-07-04 03:00:24 UTC (rev 928) @@ -680,12 +680,32 @@ return (config_entry[-1] == self.container_set_class) and \ (config_entry[-2] == 1) + def DynamicCallback(self, directives): + cur_set = self.cur_set + cur_container = self.cur_container + for key, val in directives: + cur_set, cur_container = self._ConfigureOption(cur_set, cur_container, key, val, 0, self._AssembleConfiguration()) + cur_container.ConfigDone() + for p in cur_set.processes: + if (not (p == None)) and p.title == cur_container.title and p != cur_container: + cur_set.processes[-1:] = [] + cur_container = p + break + if not cur_set.UnmetRequirements(): + cur_set.meets_requirements = 1 + else: + cur_set.meets_requirements = 0 + print "unmet requirements" + return cur_container + def _Configure(self, optlist, from_cmdline, config_dict): # So now we work our way through the optlist. cur_set = None cur_container = None for key, val in optlist: cur_set, cur_container = self._ConfigureOption(cur_set, cur_container, key, val, from_cmdline, config_dict) + self.cur_set = cur_set + self.cur_container = cur_container def _ConfigureOption(self, cur_set, cur_container, key, val, from_cmdline, config_dict): @@ -741,7 +761,7 @@ else: kmethod() return cur_set, cur_container - + def ChooseConfig(self): p_set = None if self.num_conforming_process_sets == 0: Modified: Pythia/src/process_monitor.py =================================================================== --- Pythia/src/process_monitor.py 2007-07-02 23:10:19 UTC (rev 927) +++ Pythia/src/process_monitor.py 2007-07-04 03:00:24 UTC (rev 928) @@ -29,7 +29,7 @@ -c "bin/hub -pgm_file addmultiply.pgm" """ -import os, sys, socket, string, signal, select, math, time +import os, sys, socket, string, signal, select, math, time, Queue import Tkinter from Tkinter import * @@ -319,7 +319,7 @@ Frame.__init__(self, master) self['borderwidth'] = 2 # Default title. - self.master.title("Process monitor") + self.master.title("Pythia process monitor") self.pack(fill = 'both', expand = 1) self.top = Frame(self) self.top.pack(side = 'top', fill = 'x', anchor = 'w') @@ -387,12 +387,26 @@ self.process_env = process_env # For temporary files. self.process_env.Initialize() - self.master.iconbitmap(default=process_env.icon) + try: self.master.iconbitmap(default=process_env.icon) + except: pass self.process_set = None self.UseProcessSet(process_set) + self.calls = Queue.Queue(10) + def QDynamicCallback(self, directives): + self.calls.put(directives) + + def handle_calls(self): + while not self.calls.empty(): + directives = self.calls.get() + self.DynamicCallback(directives) + + def DynamicCallback(self, directives): + proc = self.process_env.DynamicCallback(directives) + if not proc == None: + self.DynamicProcess(proc) + def UseProcessSet(self, new_set): - # First, shut down and delete all windows, if # appropriate. if self.process_set: @@ -454,6 +468,54 @@ else: self.UseColumnConfig(self.process_env.ncols) + def DynamicProcess(self, proc): + # If this process is already attached then we may just want to start it + try: + if not proc.tk == None: + if proc.start and proc.Dead(): + proc.window_host.Restart() + return + except: + pass + + # Build a frame which has the lower pane as a hidden + # component. + # Set up the reference line. + proc.AddTk(self.tk) + self.AttachProcess(proc) + if proc.open: + proc.reference_entry.Enlarge() + if proc.start: + proc.window_host.Restart() + if proc.keepalive: + proc.window_host.KeepAlive() + # Now, build the button. + b = Button(self.button_row, + text = proc.title, + relief = 'raised', + font = HEADERFONT) + proc.compressed_button = b + b.configure(command = lambda p = proc, s = self: + s.MakeButtonActive(p)) + + # Now, we need to regenerate things. + if self.compressed: + # Regenerate the compressed list. + self.UnuseCompressedConfig() + self.separator_list.append(Frame(self.pane_frame, + relief = 'sunken', + height = 2, + borderwidth = 1)) + self.UseCompressedConfig(self.numcols, force = 1) + else: + # Regenerate the uncompressed structure. + self.UnuseColumnConfig() + self.separator_list.append(Frame(self.pane_frame, + relief = 'sunken', + height = 2, + borderwidth = 1)) + self.UseColumnConfig(self.numcols, force = 1) + def AttachProcess(self, p): ref = ReferenceEntry(self.pane_frame, self, p) p.SetReferenceEntry(ref) @@ -677,8 +739,13 @@ p.Poll() self.timer = self.tk.createtimerhandler(500, self.Poll) + def handle_calls_callback(self): + self.handle_calls() + self.after(1000, self.handle_calls_callback) + def Run(self): # self.timer = self.tk.createtimerhandler(500, self.Poll) + self.handle_calls_callback() self.mainloop() # We adopt a more complex model, where all the info about @@ -755,6 +822,8 @@ from basic_process_monitor import ProcessContainer, \ ProcessContainerSet, ProcessEnvironment, ConfigurationError +from spawn_listener import SpawnListener + class TkProcessContainer(ProcessContainer): config_table = ProcessContainer.config_table + \ [(None, "--input_line", 0, "LineInputMode", 0), @@ -1178,11 +1247,14 @@ if hasattr(signal, "SIGQUIT"): # Doesn't exist on Windows. signal.signal(signal.SIGQUIT, lambda n, stack, s = f: s.force_quit()) + listener = SpawnListener(f.QDynamicCallback) try: + listener.start() f.Run() except "foo": print "Encountered an unrecoverable error of type %s with argument %s. Exiting." % (`sys.exc_type`, `sys.exc_value`) sys.stdout.flush() f.quit() + main() Added: Pythia/src/spawn_listener.py =================================================================== --- Pythia/src/spawn_listener.py (rev 0) +++ Pythia/src/spawn_listener.py 2007-07-04 03:00:24 UTC (rev 928) @@ -0,0 +1,43 @@ +# Thomas Harris +# December 2006 +# +# This process listens for spawn requests on a known tcp port + +import socket, threading, string + +_port = 11044 + +class SpawnListener(threading.Thread): + def __init__(self, dynamic_callback): + threading.Thread.__init__(self) + self.setDaemon(1) + self.serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.serversocket.bind(('', _port)) + self.serversocket.listen(5) + self.dynamic_callback = dynamic_callback + + def run(self): + while 1: + (clientsocket, address) = self.serversocket.accept() + msg = '' + while 1: + chunk = clientsocket.recv(1024) + if chunk == '': + break + msg = msg + chunk + self._processMsg(msg) + + def _processMsg(self, msg): + lines = msg.splitlines() + directives = [] + for line in lines: + l = string.strip(line) + if l and l[0] != '#': + d = string.split(l, None, 1) + if len(d) == 1: + directives.append((d[0], "")) + else: + directives.append((d[0], d[1])) + self.dynamic_callback(directives) + + From tk at edam.speech.cs.cmu.edu Wed Jul 4 16:23:28 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Wed, 4 Jul 2007 16:23:28 -0400 Subject: [RavenclawDev 288] [929] Pythia: 1) Added configuration memory Message-ID: <200707042023.l64KNSFx028795@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/ravenclaw-developers/attachments/20070704/72b4e2a4/attachment.html -------------- next part -------------- Modified: Pythia/dist/library.zip =================================================================== (Binary files differ) Modified: Pythia/dist/process_monitor.exe =================================================================== (Binary files differ) Modified: Pythia/src/basic_process_monitor.py =================================================================== --- Pythia/src/basic_process_monitor.py 2007-07-04 03:00:24 UTC (rev 928) +++ Pythia/src/basic_process_monitor.py 2007-07-04 20:23:27 UTC (rev 929) @@ -15,7 +15,7 @@ from win_pm_core import _MAYBE_ALIVE, _DEFINITELY_ALIVE, _DEFINITELY_DEAD pm_core = win_pm_core else: - raise "Can't run process monitor on", os.name + raise Exception, "Can't run process monitor on", os.name # This class controls the subprocess. @@ -39,7 +39,8 @@ # For run_test_suite.py, ProcessContainer needs to be able to # stand alone. -ProcessContainerError = "ProcessContainerError" +class ProcessContainerError(Exception): + pass class ProcessContainer(pm_core.ProcessContainer): config_table = [("PROCESS_TITLE:", "-T", 1, "AddTitle", 0), @@ -401,7 +402,8 @@ import getopt -ConfigurationError = "ConfigurationError" +class ConfigurationError(Exception): + pass # INCLUDE: is also an option. @@ -629,7 +631,12 @@ if len(args) == 2: self.config_choice = args[1] self.file = args[0] - return self._DigestConfigurationFile(self.file), 0 + self.userfile = self.file + ".user" + try: + user_directives = self._DigestConfigurationFile(self.userfile) + except ConfigurationError: + user_directives = [] + return user_directives + self._DigestConfigurationFile(self.file), 0 else: raise ConfigurationError, "neither args nor configuration file" @@ -638,6 +645,7 @@ fp = open(test_file, "r") except: raise ConfigurationError, "couldn't find configuration file "+ test_file + lines = fp.readlines() fp.close() directives = [] Modified: Pythia/src/process_monitor.py =================================================================== --- Pythia/src/process_monitor.py 2007-07-04 03:00:24 UTC (rev 928) +++ Pythia/src/process_monitor.py 2007-07-04 20:23:27 UTC (rev 929) @@ -393,6 +393,13 @@ self.UseProcessSet(process_set) self.calls = Queue.Queue(10) + def RecordConfiguration(self, userfile, config): + if userfile == None: + return + f = open(userfile, "w") + for k, v in config.iteritems(): + f.write("%s: %s\n" % (k, v)) + def QDynamicCallback(self, directives): self.calls.put(directives) @@ -531,6 +538,9 @@ def UseCompressedConfig(self, ncols, force = 0): if self.compressed and (ncols == self.numcols) and (not force): return + + self.RecordConfiguration(self.process_env.userfile, {'NUM_DIVISIONS': ncols, 'COMPRESSED': ''}) + if (not self.compressed): if not force: self.UnuseColumnConfig() self.compressed = 1 @@ -672,6 +682,9 @@ def UseColumnConfig(self, ncols, force = 0): if self.compressed == 0 and ncols == self.numcols and (not force): return + + self.RecordConfiguration(self.process_env.userfile, {'NUM_DIVISIONS': ncols}) + # Make it uncompressed if self.compressed: if not force: self.UnuseCompressedConfig() Modified: Pythia/src/win_pm_core.py =================================================================== --- Pythia/src/win_pm_core.py 2007-07-04 03:00:24 UTC (rev 928) +++ Pythia/src/win_pm_core.py 2007-07-04 20:23:27 UTC (rev 929) @@ -29,7 +29,7 @@ PROCESS_RUNNER = 'cmd.exe /c' else: PROCESS_RUNNER = '' - raise "Unsupported before Windows NT" + raise Exception, "Unsupported before Windows NT" ########################################################### # From tk at edam.speech.cs.cmu.edu Thu Jul 5 17:32:09 2007 From: tk at edam.speech.cs.cmu.edu (tk@edam.speech.cs.cmu.edu) Date: Thu, 5 Jul 2007 17:32:09 -0400 Subject: [RavenclawDev 289] [930] Pythia: Closing process monitor window now closes spawned processes. Message-ID: <200707052132.l65LW9FA001636@edam.speech.cs.cmu.edu> An HTML attachment was scrubbed... URL: http://mailman.srv.cs.cmu.edu/pipermail/ravenclaw-developers/attachments/20070705/447eb436/attachment.html -------------- next part -------------- Modified: Pythia/dist/library.zip =================================================================== (Binary files differ) Modified: Pythia/dist/process_monitor.exe =================================================================== (Binary files differ) Modified: Pythia/src/process_monitor.py =================================================================== --- Pythia/src/process_monitor.py 2007-07-04 20:23:27 UTC (rev 929) +++ Pythia/src/process_monitor.py 2007-07-05 21:32:08 UTC (rev 930) @@ -1254,7 +1254,9 @@ except ConfigurationError, text: print text Usage() - f = ProcessFrame(env, config) + root = Tk() + f = ProcessFrame(env, config, root) + root.protocol("WM_DELETE_WINDOW", lambda s = f: s.force_quit()) signal.signal(signal.SIGINT, lambda n, stack, s = f: s.force_quit()) signal.signal(signal.SIGTERM, lambda n, stack, s = f: s.force_quit()) if hasattr(signal, "SIGQUIT"): @@ -1269,5 +1271,4 @@ sys.stdout.flush() f.quit() - main()