# Buggy code
def get_base_args(self):
    # get ansible-inventory absolute path for running in bubblewrap/proot, in Popen
    abs_ansible_inventory = shutil.which("ansible-inventory")
    bargs = [abs_ansible_inventory, "-i", self.source]
    logger.debug("Using base command: {}".format(" ".join(bargs)))
    return bargs


# Traceback (RuntimeError)
1.570 INFO     Updating inventory 3: roman cluster
1.584 INFO     Reading Ansible inventory source: /var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/plugins/inventory/ec2.py
1.586 INFO     Using VIRTUAL_ENV: /var/lib/awx/venv/my-custom-venv/
1.586 INFO     Using PATH: /var/lib/awx/venv/my-custom-venv/bin:/var/lib/awx/venv/awx/bin:/var/lib/awx/venv/awx/bin:/var/lib/awx/venv/awx/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
1.586 INFO     Using PYTHONPATH: /var/lib/awx/venv/my-custom-venv/lib/python3.6/site-packages:
Traceback (most recent call last):
File "/var/lib/awx/venv/awx/bin/awx-manage", line 11, in <module>
load_entry_point('awx==3.0.0.0', 'console_scripts', 'awx-manage')()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/__init__.py", line 150, in manage
execute_from_command_line(sys.argv)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/management/commands/inventory_import.py", line 1030, in handle
raise exc
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/management/commands/inventory_import.py", line 930, in handle
data = AnsibleInventoryLoader(source=source, is_custom=self.is_custom, venv_path=venv_path).load()
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/management/commands/inventory_import.py", line 176, in load
return self.command_to_json(base_args + ['--list'])
File "/var/lib/awx/venv/awx/lib64/python3.6/site-packages/awx/main/management/commands/inventory_import.py", line 159, in command_to_json
self.method, proc.returncode, stdout, stderr))
RuntimeError: ansible-inventory failed (rc=1) with stdout:
stderr:
Traceback (most recent call last):
File "/usr/bin/ansible-inventory", line 67, in <module>
import ansible.constants as C
File "/var/lib/awx/venv/my-custom-venv/lib/python3.6/site-packages/ansible/constants.py", line 17, in <module>
from ansible.config.manager import ConfigManager, ensure_type, get_ini_config_value
File "/var/lib/awx/venv/my-custom-venv/lib/python3.6/site-packages/ansible/config/manager.py", line 16, in <module>
from yaml import load as yaml_load
File "/var/lib/awx/venv/my-custom-venv/lib/python3.6/site-packages/yaml/__init__.py", line 284
class YAMLObject(metaclass=YAMLObjectMetaclass):
^
SyntaxError: invalid syntax

# Fixed code
def get_base_args(self):
    # get ansible-inventory absolute path for running in bubblewrap/proot, in Popen
    bargs = [self.get_path_to_ansible_inventory(), "-i", self.source]
    logger.debug("Using base command: {}".format(" ".join(bargs)))
    return bargs