nccgroup / opinel

Python code shared by Scout2 and AWS-Recipes
GNU General Public License v2.0
24 stars 18 forks source link

Opinel not looking for the requirements file "next to the script." #17

Closed grettir closed 7 years ago

grettir commented 7 years ago

Many of the scripts that rely on opinel are currently failing unless they are run from the directory where the scripts reside. Otherwise, you get something along the lines of…

Traceback (most recent call last):
  File "/Users/xxxxxxx/Code/AWS-recipes/Python/awsrecipes_init_sts_session.py", line 40, in <module>
    sys.exit(main())
  File "/Users/xxxxxxx/Code/AWS-recipes/Python/awsrecipes_init_sts_session.py", line 31, in main
    if not check_requirements(os.path.realpath(__file__)):
  File "/usr/local/lib/python2.7/site-packages/opinel/utils/globals.py", line 35, in check_requirements
    with open(requirements_file, 'rt') as f:
IOError: [Errno 2] No such file or directory: 'requirements.txt'

I think the reason is that opinel purports to look for the requirements file in two places:

Instead, opinel appears to be looking in:

My Python skills are rudimentary (at best), but I believe that line #34 in opinel/utils/globals.py, which currently ends with:

...else 'requirements.txt'

...should end with:

...else os.path.join(script_dir, 'requirements.txt')
l01cd3v commented 7 years ago

Thanks ! I'll look into the other issue you opened (AWS-recipes) before pushing a new release of opinel.