summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
authorJohnathan Corgan2011-03-14 20:00:21 -0700
committerJohnathan Corgan2011-03-14 20:00:21 -0700
commitf4e78c76520abc950bf34188cf61cd30f4d26188 (patch)
treed35715c145a143587fa83ae2d45a1ab9dfbff129 /grc
parent44f06ca629900ea1ac77ddfc80d6f4202db25e6c (diff)
parent21158d425ff8d8b1ba8bbc6a89609b33fb4252b4 (diff)
downloadgnuradio-f4e78c76520abc950bf34188cf61cd30f4d26188.tar.gz
gnuradio-f4e78c76520abc950bf34188cf61cd30f4d26188.tar.bz2
gnuradio-f4e78c76520abc950bf34188cf61cd30f4d26188.zip
Merge remote branch 'jblum/wip/grc/kill_process' into next
* jblum/wip/grc/kill_process: grc: swap store the subprocess object rather than the pid when executing
Diffstat (limited to 'grc')
-rw-r--r--grc/gui/ActionHandler.py20
-rw-r--r--grc/gui/MainWindow.py6
-rw-r--r--grc/gui/NotebookPage.py20
3 files changed, 23 insertions, 23 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index 108e23a23..350b297bb 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -1,5 +1,5 @@
"""
-Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
@@ -282,7 +282,7 @@ class ActionHandler:
# Gen/Exec/Stop
##################################################
elif action == Actions.FLOW_GRAPH_GEN:
- if not self.get_page().get_pid():
+ if not self.get_page().get_proc():
if not self.get_page().get_saved() or not self.get_page().get_file_path():
Actions.FLOW_GRAPH_SAVE() #only save if file path missing or not saved
if self.get_page().get_saved() and self.get_page().get_file_path():
@@ -293,14 +293,14 @@ class ActionHandler:
except Exception,e: Messages.send_fail_gen(e)
else: self.generator = None
elif action == Actions.FLOW_GRAPH_EXEC:
- if not self.get_page().get_pid():
+ if not self.get_page().get_proc():
Actions.FLOW_GRAPH_GEN()
if self.get_page().get_saved() and self.get_page().get_file_path():
ExecFlowGraphThread(self)
elif action == Actions.FLOW_GRAPH_KILL:
- if self.get_page().get_pid():
- try: os.kill(self.get_page().get_pid(), signal.SIGKILL)
- except: print "could not kill pid: %s"%self.get_page().get_pid()
+ if self.get_page().get_proc():
+ try: self.get_page().get_proc().kill()
+ except: print "could not kill process: %d"%self.get_page().get_proc().pid
elif action == Actions.PAGE_CHANGE: #pass and run the global actions
pass
else: print '!!! Action "%s" not handled !!!'%action
@@ -340,10 +340,10 @@ class ActionHandler:
Update the exec and stop buttons.
Lock and unlock the mutex for race conditions with exec flow graph threads.
"""
- sensitive = self.get_flow_graph().is_valid() and not self.get_page().get_pid()
+ sensitive = self.get_flow_graph().is_valid() and not self.get_page().get_proc()
Actions.FLOW_GRAPH_GEN.set_sensitive(sensitive)
Actions.FLOW_GRAPH_EXEC.set_sensitive(sensitive)
- Actions.FLOW_GRAPH_KILL.set_sensitive(self.get_page().get_pid() != None)
+ Actions.FLOW_GRAPH_KILL.set_sensitive(self.get_page().get_proc() != None)
class ExecFlowGraphThread(Thread):
"""Execute the flow graph as a new process and wait on it to finish."""
@@ -362,7 +362,7 @@ class ExecFlowGraphThread(Thread):
#get the popen
try:
self.p = self.page.get_generator().get_popen()
- self.page.set_pid(self.p.pid)
+ self.page.set_proc(self.p)
#update
self.update_exec_stop()
self.start()
@@ -385,5 +385,5 @@ class ExecFlowGraphThread(Thread):
def done(self):
"""Perform end of execution tasks."""
Messages.send_end_exec()
- self.page.set_pid(None)
+ self.page.set_proc(None)
self.update_exec_stop()
diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py
index 9fcbe2a6c..2f761df1f 100644
--- a/grc/gui/MainWindow.py
+++ b/grc/gui/MainWindow.py
@@ -1,5 +1,5 @@
"""
-Copyright 2008, 2009 Free Software Foundation, Inc.
+Copyright 2008, 2009, 2011 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
@@ -216,7 +216,7 @@ class MainWindow(gtk.Window):
"""
if not self.page_to_be_closed: self.page_to_be_closed = self.get_page()
#show the page if it has an executing flow graph or is unsaved
- if self.page_to_be_closed.get_pid() or not self.page_to_be_closed.get_saved():
+ if self.page_to_be_closed.get_proc() or not self.page_to_be_closed.get_saved():
self._set_page(self.page_to_be_closed)
#unsaved? ask the user
if not self.page_to_be_closed.get_saved() and self._save_changes():
@@ -225,7 +225,7 @@ class MainWindow(gtk.Window):
self.page_to_be_closed = None #set the page to be closed back to None
return
#stop the flow graph if executing
- if self.page_to_be_closed.get_pid(): Actions.FLOW_GRAPH_KILL()
+ if self.page_to_be_closed.get_proc(): Actions.FLOW_GRAPH_KILL()
#remove the page
self.notebook.remove_page(self.notebook.page_num(self.page_to_be_closed))
if ensure and self.notebook.get_n_pages() == 0: self.new_page() #no pages, make a new one
diff --git a/grc/gui/NotebookPage.py b/grc/gui/NotebookPage.py
index fddfeaf5f..86b6f1513 100644
--- a/grc/gui/NotebookPage.py
+++ b/grc/gui/NotebookPage.py
@@ -1,5 +1,5 @@
"""
-Copyright 2008, 2009 Free Software Foundation, Inc.
+Copyright 2008, 2009, 2011 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
@@ -40,7 +40,7 @@ class NotebookPage(gtk.HBox):
@param file_path path to a flow graph file
"""
self._flow_graph = flow_graph
- self.set_pid(None)
+ self.set_proc(None)
#import the file
self.main_window = main_window
self.set_file_path(file_path)
@@ -119,19 +119,19 @@ class NotebookPage(gtk.HBox):
"""
return self.tab
- def get_pid(self):
+ def get_proc(self):
"""
- Get the pid for the flow graph.
- @return the pid number
+ Get the subprocess for the flow graph.
+ @return the subprocess object
"""
- return self.pid
+ return self.process
- def set_pid(self, pid):
+ def set_proc(self, process):
"""
- Set the pid number.
- @param pid the new pid number
+ Set the subprocess object.
+ @param process the new subprocess
"""
- self.pid = pid
+ self.process = process
def get_flow_graph(self):
"""