]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: Use __file__ instead of sys.argv[0]
authorEd Bartosh <ed.bartosh@linux.intel.com>
Thu, 9 Apr 2015 12:54:35 +0000 (15:54 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 13 Apr 2015 21:28:33 +0000 (22:28 +0100)
Using __file__ makes the code work independently of the way
it's loaded. In some cases wic can be imported by another
program without executing it. sys.argv[0] would not contain
path to the wic in such a cases.

This is an enabler for unit testing with nose framework.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/wic

index dcf1a5520e3eff61cbd638710174bc4a6cf0d3d7..fd4a67892bf2e2539f8748e9fedaad341497725f 100755 (executable)
@@ -38,7 +38,7 @@ import optparse
 import logging
 
 # External modules
-scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
+scripts_path = os.path.abspath(os.path.dirname(__file__))
 lib_path = scripts_path + '/lib'
 bitbake_path = os.path.join(scripts_path, '../bitbake/lib')
 sys.path = sys.path + [lib_path, bitbake_path]