summaryrefslogtreecommitdiff
path: root/bin/tools/misc.py
diff options
context:
space:
mode:
authorVir (Open ERP) <vir@tinyerp.com>2010-06-01 11:08:40 +0530
committerVir (Open ERP) <vir@tinyerp.com>2010-06-01 11:08:40 +0530
commitb2a6a5f79c0ae1cc13f207ca0135d1eb401f2c35 (patch)
tree7aeea0e54926957c1b3181a92f3681626ccd1939 /bin/tools/misc.py
parent9a7c0bfa75a8138b442160e96074bd7652f42c10 (diff)
parent2a1d7c24c0e06c5fc383cce4778ca525ecfa5eef (diff)
[Merge] Merge with Trunk Server
bzr revid: vir@tinyerp.com-20100601053840-z183q5is7js83sb9
Diffstat (limited to 'bin/tools/misc.py')
-rw-r--r--bin/tools/misc.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/bin/tools/misc.py b/bin/tools/misc.py
index 60c2750d413..8c8117c02c8 100644
--- a/bin/tools/misc.py
+++ b/bin/tools/misc.py
@@ -3,6 +3,7 @@
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
+# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -34,6 +35,7 @@ import socket
import re
from itertools import islice
import threading
+from which import which
if sys.version_info[:2] < (2, 4):
@@ -112,23 +114,19 @@ def init_db(cr):
cr.commit()
def find_in_path(name):
- if os.name == "nt":
- sep = ';'
- else:
- sep = ':'
- path = [dir for dir in os.environ['PATH'].split(sep)
- if os.path.isdir(dir)]
- for dir in path:
- val = os.path.join(dir, name)
- if os.path.isfile(val) or os.path.islink(val):
- return val
- return None
+ try:
+ return which(name)
+ except IOError:
+ return None
def find_pg_tool(name):
+ path = None
if config['pg_path'] and config['pg_path'] != 'None':
- return os.path.join(config['pg_path'], name)
- else:
- return find_in_path(name)
+ path = config['pg_path']
+ try:
+ return which(name, path=path)
+ except IOError:
+ return None
def exec_pg_command(name, *args):
prog = find_pg_tool(name)