# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from popen2 import Popen3
+from subprocess import Popen, PIPE
import os
import config
+import errno
client = config.get_val("arch_client")
if client is None:
client = "tla"
config.set_val("arch_client", client)
def invoke(args):
- q=Popen3(args, True)
- output = q.fromchild.read()
- error = q.childerr.read()
+ q = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+ output = q.stdout.read()
+ error = q.stderr.read()
status = q.wait()
- if os.WIFEXITED(status):
- return os.WEXITSTATUS(status), output, error
+ if status >= 0:
+ return status, output, error
raise Exception("Command failed: %s" % error)
def invoke_client(*args, **kwargs):
def detect(path):
"""Detect whether a directory is revision-controlled using Arch"""
path = os.path.realpath(path)
+ old_path = None
while True:
if os.path.exists(os.path.join(path, "{arch}")):
return True
- if path == "/":
+ if path == old_path:
return False
- path = os.path.dirname(path)
+ old_path = path
+ path = os.path.join('..', path)
name = "Arch"
msg = "The directory \"%s\" has no bug directory." % path
Exception.__init__(self, msg)
self.path = path
-
+
+
+def iter_parent_dirs(cur_dir):
+ cur_dir = os.path.realpath(cur_dir)
+ old_dir = None
+ while True:
+ yield cur_dir
+ old_dir = cur_dir
+ cur_dir = os.path.normpath(os.path.join(cur_dir, '..'))
+ if old_dir == cur_dir:
+ break;
+
def tree_root(dir, old_version=False):
- rootdir = os.path.realpath(dir)
- while (True):
- versionfile=os.path.join(rootdir, ".be/version")
+ for rootdir in iter_parent_dirs(dir):
+ versionfile=os.path.join(rootdir, ".be", "version")
if os.path.exists(versionfile):
if not old_version:
test_version(versionfile)
- break;
- elif rootdir == "/":
- raise NoBugDir(dir)
+ return BugDir(os.path.join(rootdir, ".be"))
elif not os.path.exists(rootdir):
raise NoRootEntry(rootdir)
- rootdir=os.path.dirname(rootdir)
- return BugDir(os.path.join(rootdir, ".be"))
+ old_rootdir = rootdir
+ rootdir=os.path.join('..', rootdir)
+
+ raise NoBugDir(dir)
class BadTreeVersion(Exception):
def __init__(self, version):
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from popen2 import Popen3
+from subprocess import Popen
import os
import config
def invoke(args):
- q=Popen3(args, True)
- output = q.fromchild.read()
- error = q.childerr.read()
+ q=Popen(args)
+ output = q.stdout.read()
+ error = q.stderr.read()
status = q.wait()
- if os.WIFEXITED(status):
- return os.WEXITSTATUS(status), output, error
+ if status >= 0:
+ return status, output, error
raise Exception("Command failed: %s" % error)
+
def invoke_client(*args, **kwargs):
cl_args = ["bzr"]
cl_args.extend(args)
def detect(path):
"""Detect whether a directory is revision-controlled using bzr"""
path = os.path.realpath(path)
+ old_path = None
while True:
if os.path.exists(os.path.join(path, ".bzr")):
return True
- if path == "/":
+ if path == old_path:
return False
+ old_path = path
path = os.path.dirname(path)
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from popen2 import Popen4
import os
import config
from os import unlink
>>> q.startswith("<module 'becommands.list' from ")
True
"""
- dirprefix = '/'.join(prefix.split('.'))
+ dirprefix = os.path.join(*prefix.split('.'))
command_path = os.path.join(plugin_path, dirprefix, name+".py")
if os.path.isfile(command_path):
return my_import(prefix + "." + name)
"""Invokes the editor, and returns the user_produced text as a string
- >>> del os.environ["EDITOR"]
+ >>> if "EDITOR" in os.environ:
+ ... del os.environ["EDITOR"]
>>> editor_string()
Traceback (most recent call last):
CantFindEditor: Can't find editor to get string from