[Merge] Merge with Trunk Server
authorVir (Open ERP) <vir@tinyerp.com>
Tue, 1 Jun 2010 05:38:40 +0000 (11:08 +0530)
committerVir (Open ERP) <vir@tinyerp.com>
Tue, 1 Jun 2010 05:38:40 +0000 (11:08 +0530)
bzr revid: vir@tinyerp.com-20100601053840-z183q5is7js83sb9

1  2 
bin/tools/misc.py

diff --combined bin/tools/misc.py
@@@ -3,6 -3,7 +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 +35,7 @@@ import socke
  import re
  from itertools import islice
  import threading
+ from which import which
  
  
  if sys.version_info[:2] < (2, 4):
@@@ -112,23 -114,19 +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)
@@@ -1130,15 -1128,6 +1128,15 @@@ icons = map(lambda x: (x,x), ['STOCK_AB
  'terp-account', 'terp-crm', 'terp-mrp', 'terp-product', 'terp-purchase',
  'terp-sale', 'terp-tools', 'terp-administration', 'terp-hr', 'terp-partner',
  'terp-project', 'terp-report', 'terp-stock', 'terp-calendar', 'terp-graph',
 +'terp-check','terp-go-month','terp-go-year','terp-go-today','terp-document-new','terp-camera_test',
 +'terp-emblem-important','terp-gtk-media-pause','terp-gtk-stop','terp-gnome-cpu-frequency-applet+',
 +'terp-dialog-close','terp-gtk-jump-to-rtl','terp-gtk-jump-to-ltr','terp-accessories-archiver',
 +'terp-stock_align_left_24','terp-stock_effects-object-colorize','terp-go-home','terp-gtk-go-back-rtl',
 +'terp-gtk-go-back-ltr','terp-personal','terp-personal-','terp-personal+','terp-accessories-archiver-minus',
 +'terp-accessories-archiver+','terp-stock_symbol-selection','terp-call-start','terp-dolar',
 +'terp-face-plain','terp-folder-blue','terp-folder-green','terp-folder-orange','terp-folder-yellow',
 +'terp-gdu-smart-failing','terp-go-week','terp-gtk-select-all','terp-locked','terp-mail-forward',
 +'terp-mail-message-new','terp-mail-replied','terp-rating-rated','terp-stage','terp-stock_format-scientific'
  ])
  
  def extract_zip_file(zip_file, outdirectory):