简体   繁体   中英

Execute file in specific path bash

i'm using Stacoan for vulnerability analysis ( https://github.com/vincentcox/StaCoAn ), i want to use it in a pipeline, but when i run stacoan binary or python script in other path, i obtain errors (using stacoan.py):

Traceback (most recent call last):
  File "/home/jenkins/StaCoAn/src/stacoan.py", line 18, in <module>
    from helpers.project import Project
  File "/home/jenkins/StaCoAn/src/helpers/project.py", line 11, in <module>
    from helpers.file import File
  File "/home/jenkins/StaCoAn/src/helpers/file.py", line 12, in <module>
    class File:
  File "/home/jenkins/StaCoAn/src/helpers/file.py", line 15, in File
    non_regex_indicator = config.get("ProgramConfig", 'non_regex_indicator')
  File "/usr/lib/python3.8/configparser.py", line 781, in get
    d = self._unify_values(section, vars)
  File "/usr/lib/python3.8/configparser.py", line 1149, in _unify_values
    raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'ProgramConfig'

Using stacoan executable:

Traceback (most recent call last):
  File "/opt/python/3.6.2/lib/python3.6/configparser.py", line 1138, in _unify_values
KeyError: 'ProgramConfig'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/travis/build/vincentcox/StaCoAn/src/stacoan.py", line 17, in <module>
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "/home/travis/virtualenv/python3.6.2/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
  File "/home/travis/build/vincentcox/StaCoAn/src/logger.py", line 19, in <module>
  File "/home/travis/build/vincentcox/StaCoAn/src/logger.py", line 25, in Logger
  File "/home/travis/build/vincentcox/StaCoAn/src/logger.py", line 41, in __Logger
  File "/opt/python/3.6.2/lib/python3.6/configparser.py", line 781, in get
  File "/opt/python/3.6.2/lib/python3.6/configparser.py", line 1141, in _unify_values
configparser.NoSectionError: No section: 'ProgramConfig'
[81859] Failed to execute script stacoan

This doesn't occurs if i run it in its own path, i tried a simbolic link, executing using absolute path and build an executable but i still obtains errors.

Thanks!

NOTE: I know is a deprecated repository, but my team want to use it

You could use:

os.chdir(path)

More details here: https://www.geeksforgeeks.org/python-os-chdir-method/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM