# HG changeset patch # User paulb # Date 1153344971 0 # Node ID d22ed89c07b7bc8a59e8d3656e5e1bee6bad7ab3 # Parent 9792b158cecaa0d2735b810931d6e34ac216faf3 [project @ 2006-07-19 21:36:11 by paulb] Added Python 2.3 support using popen2, choosing a specific _run function according to module availability. Updated release information. diff -r 9792b158ceca -r d22ed89c07b7 PKG-INFO --- a/PKG-INFO Wed Oct 15 23:18:02 2008 +0200 +++ b/PKG-INFO Wed Jul 19 21:36:11 2006 +0000 @@ -1,12 +1,12 @@ Metadata-Version: 1.1 Name: desktop -Version: 0.2.2 +Version: 0.2.3 Author: Paul Boddie Author-email: paul at boddie org uk Maintainer: Paul Boddie Maintainer-email: paul at boddie org uk Home-page: http://www.python.org/sf?id=1301512 -Download-url: http://www.boddie.org.uk/python/downloads/desktop-0.2.2.tar.gz +Download-url: http://www.boddie.org.uk/python/downloads/desktop-0.2.3.tar.gz Summary: Simple desktop integration for Python License: LGPL Description: This module provides desktop environment detection and resource diff -r 9792b158ceca -r d22ed89c07b7 README.txt --- a/README.txt Wed Oct 15 23:18:02 2008 +0200 +++ b/README.txt Wed Jul 19 21:36:11 2006 +0000 @@ -36,6 +36,11 @@ ROX-Filer Supports file opening using "rox " but not URL opening. +New in desktop 0.2.3 (Changes since desktop 0.2.2) +-------------------------------------------------- + + * Added Python 2.3 support (using popen2 instead of subprocess). + New in desktop 0.2.2 (Changes since desktop 0.2.1) -------------------------------------------------- diff -r 9792b158ceca -r d22ed89c07b7 desktop.py --- a/desktop.py Wed Oct 15 23:18:02 2008 +0200 +++ b/desktop.py Wed Jul 19 21:36:11 2006 +0000 @@ -5,7 +5,7 @@ detection and resource opening support for a selection of common and standardised desktop environments. -Copyright (C) 2005 Paul Boddie +Copyright (C) 2005, 2006 Paul Boddie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -68,11 +68,25 @@ http://lists.freedesktop.org/archives/xdg/2004-August/004489.html """ -__version__ = "0.2.2" +__version__ = "0.2.3" import os import sys -import subprocess + +try: + import subprocess + def _run(cmd, shell, wait): + opener = subprocess.Popen(cmd, shell=shell) + if wait: opener.wait() + return opener.pid + +except ImportError: + import popen2 + def _run(cmd, shell, wait): + opener = popen2.Popen3(cmd) + if wait: opener.wait() + return opener.pid + import commands def get_desktop(): @@ -104,17 +118,6 @@ return os.environ.has_key("DESKTOP_LAUNCH") -def _wait(pid, block): - - """ - Perform a blocking Wait for the given process identifier, 'pid', if the - 'block' flag is set to a true value. Return the process identifier. - """ - - if block: - os.waitpid(pid, os.P_WAIT) - return pid - def open(url, desktop=None, wait=0): """ @@ -146,7 +149,7 @@ if (desktop is None or desktop == "standard") and is_standard(): arg = "".join([os.environ["DESKTOP_LAUNCH"], commands.mkarg(url)]) - return _wait(subprocess.Popen(arg, shell=1).pid, wait) + return _run(arg, 1, wait) elif (desktop is None or desktop == "Windows") and detected == "Windows": # NOTE: This returns None in current implementations. @@ -168,6 +171,6 @@ else: raise OSError, "Desktop not supported (neither DESKTOP_LAUNCH nor os.startfile could be used)" - return _wait(subprocess.Popen(cmd).pid, wait) + return _run(cmd, 0, wait) # vim: tabstop=4 expandtab shiftwidth=4