summaryrefslogtreecommitdiffstats
path: root/FusionIcon/execute.py
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-13 03:34:10 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-13 03:34:10 +0000
commit6a8e496233a6f6d632bdc7551a5fbda3543c27bb (patch)
tree28479fd17cf5a19838108ab4a17b6f3fb1e5cd88 /FusionIcon/execute.py
downloadfusion-icon-6a8e496233a6f6d632bdc7551a5fbda3543c27bb.tar.gz
fusion-icon-6a8e496233a6f6d632bdc7551a5fbda3543c27bb.zip
Added KDE3 version of fusion-icon for Compiz
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/fusion-icon@1102634 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'FusionIcon/execute.py')
-rw-r--r--FusionIcon/execute.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/FusionIcon/execute.py b/FusionIcon/execute.py
new file mode 100644
index 0000000..5615cd1
--- /dev/null
+++ b/FusionIcon/execute.py
@@ -0,0 +1,58 @@
+# This file is part of Fusion-icon.
+
+# Fusion-icon is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Fusion-icon is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author(s): crdlb, nesl247
+#
+# Copyright 2007 Christopher Williams <[email protected]>
+
+import subprocess, signal, os
+
+# avoid zombies
+signal.signal(signal.SIGCHLD, signal.SIG_IGN)
+
+def run(command, mode='spawn', quiet=False, env=None):
+ 'Simple wrapper for the subprocess module. Supported modes: spawn, call, and output'
+
+ if mode == 'spawn':
+ if not quiet:
+ popen_object = subprocess.Popen(command)
+ else:
+ popen_object = subprocess.Popen(command, stdout=open(os.devnull, 'w'))
+
+ return popen_object
+
+ elif mode == 'call':
+ # restore normal child handling
+ signal.signal(signal.SIGCHLD, signal.SIG_DFL)
+ if not quiet:
+ exitcode = subprocess.call(command, stderr=subprocess.PIPE)
+ else:
+ exitcode = subprocess.call(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ # turn zombie protection back on
+ signal.signal(signal.SIGCHLD, signal.SIG_IGN)
+
+ return exitcode
+
+ elif mode == 'output':
+ signal.signal(signal.SIGCHLD, signal.SIG_DFL)
+ if not env:
+ output = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=open(os.devnull, 'w')).communicate()[0]
+ else:
+ output = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=open(os.devnull, 'w'), env=env).communicate()[0]
+
+ signal.signal(signal.SIGCHLD, signal.SIG_IGN)
+
+ return output