db.py should look in its directory, not the directory of the executable
that imported it, when it's looking for its .database, .unpriv_login,
and .priv_login configuration files.
Signed-off-by: Jeremy Orlow <jorlow@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@1195 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/db.py b/tko/db.py
index 605587a..2cf13ad 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -6,7 +6,7 @@
self.debug = debug
self.autocommit = autocommit
- path = os.path.dirname(os.path.abspath(sys.argv[0]))
+ path = os.path.dirname(__file__)
try:
file = os.path.join(path, '.database')
db_prefs = open(file, 'r')
@@ -52,7 +52,7 @@
self.status_idx[s[1]] = s[0]
self.status_word[s[0]] = s[1]
- dir = os.path.abspath(os.path.dirname(sys.argv[0]))
+ dir = os.path.dirname(__file__)
machine_map = os.path.join(dir, 'machines')
if os.path.exists(machine_map):
self.machine_map = machine_map
@@ -340,7 +340,7 @@
# Use a class method as a class factory, generating a relevant database object.
def db(*args, **dargs):
- path = os.path.dirname(os.path.abspath(sys.argv[0]))
+ path = os.path.dirname(__file__)
db_type = None
try:
db_file = os.path.join(path, '.database')