提交 d39f9a0a 编写于 作者: C Cleber Rosa

Removal of "import magic" for avocado and avocado-rest-client

These scripts rely on some Python library path manipulation to be
able to load from the source tree.  But, in fact that are a few
reasons for not having those, including:

 * All functionality in `avocado` relies on plugins, which will not be
   available from the source tree unless a `$ setup.py develop` is
   executed, which automatically makes the "import magic" unnecessary.

 * Most users will end up using a setuptools generated "entry point"
   instead.

For the sake of less code, I propose this (and all other?) magic to be
removed.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 8eb65529
...@@ -56,14 +56,6 @@ def handle_exception(*exc_info): ...@@ -56,14 +56,6 @@ def handle_exception(*exc_info):
sys.exit(-1) sys.exit(-1)
# simple magic for using scripts within a source tree
basedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if os.path.isdir(os.path.join(basedir, 'avocado')):
os.environ['PATH'] += ":" + os.path.join(basedir, 'scripts')
os.environ['PATH'] += ":" + os.path.join(basedir, 'libexec')
sys.path.append(basedir)
if __name__ == '__main__': if __name__ == '__main__':
sys.excepthook = handle_exception sys.excepthook = handle_exception
from avocado.core.app import AvocadoApp from avocado.core.app import AvocadoApp
......
...@@ -14,14 +14,8 @@ ...@@ -14,14 +14,8 @@
# Author: Cleber Rosa <cleber@redhat.com> # Author: Cleber Rosa <cleber@redhat.com>
import os
import sys import sys
# simple magic for using scripts within a source tree
basedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if os.path.isdir(os.path.join(basedir, 'avocado')):
sys.path.append(basedir)
from avocado.core.restclient.cli.app import App from avocado.core.restclient.cli.app import App
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -763,6 +763,11 @@ class RunnerSimpleTest(unittest.TestCase): ...@@ -763,6 +763,11 @@ class RunnerSimpleTest(unittest.TestCase):
simplewarning.sh uses the avocado-bash-utils simplewarning.sh uses the avocado-bash-utils
""" """
os.chdir(basedir) os.chdir(basedir)
# simplewarning.sh calls "avocado" without specifying a path
os.environ['PATH'] += ":" + os.path.join(basedir, 'scripts')
# simplewarning.sh calls "avocado exec-path" which hasn't
# access to an installed location for the libexec scripts
os.environ['PATH'] += ":" + os.path.join(basedir, 'libexec')
cmd_line = ('%s run --job-results-dir %s --sysinfo=off ' cmd_line = ('%s run --job-results-dir %s --sysinfo=off '
'examples/tests/simplewarning.sh --show-job-log' 'examples/tests/simplewarning.sh --show-job-log'
% (AVOCADO, self.tmpdir)) % (AVOCADO, self.tmpdir))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册