ianmiell / shutit

Automation framework for programmers
http://ianmiell.github.io/shutit/
MIT License
2.15k stars 110 forks source link

"local variable 'input' referenced before assignment" error in shutit_util.py #312

Closed rydnr closed 6 years ago

rydnr commented 6 years ago

When running shutit-openshift-origin, I get this error in my ubuntu:

2018-03-12 08:17:28,661 INFO: Retrieving output from command: command cat /proc/meminfo  | grep MemAvailable | awk '{print $2}'
2018-03-12 08:17:28,662 INFO: Sending: command cat /proc/meminfo  | grep MemAvailable | awk '{print $2}'
2018-03-12 08:17:28,967 INFO: Output (squashed): command cat /proc/meminfo  | grep MemAvailable | awk '{print $2}'1366244javi-HP-630-Notebook-PC:shutit.openshift_vagrant.openshift_vag
rant.openshift_vagrant:2Cz [...]
2018-03-12 08:17:28,967 WARNING: Exception at 2665: a bytes-like object is required, not 'str'
Traceback (most recent call last):
  File "/usr/local/bin/shutit", line 11, in <module>
    load_entry_point('shutit==1.0.62', 'console_scripts', 'shutit')()
  File "/usr/local/lib/python3.5/dist-packages/shutit.py", line 67, in main
    shutit.setup_shutit_obj()
  File "/usr/local/lib/python3.5/dist-packages/shutit_class.py", line 3960, in setup_shutit_obj
    self.do_build()
  File "/usr/local/lib/python3.5/dist-packages/shutit_class.py", line 4199, in do_build
    self.build_module(module)
  File "/usr/local/lib/python3.5/dist-packages/shutit_class.py", line 4141, in build_module
    if not module.build(self):
  File "/usr/local/lib/python3.5/dist-packages/shutit_module.py", line 59, in wrapper
    ret = func(self, shutit)
  File "/home/papa/review/work/shutit-openshift-origin/openshift_vagrant.py", line 79, in build
    if not shutit.get_input('Memory available appears to be: ' + str(memavail) + 'kB, need ' + str(mem_needed * 1000) + 'kB available to run.\nIf you want to continue, input "y", else
 "n"',boolean=True):
  File "/usr/local/lib/python3.5/dist-packages/shutit_class.py", line 4403, in get_input
    colour=colour)
  File "/usr/local/lib/python3.5/dist-packages/shutit_util.py", line 271, in get_input
    answer = util_raw_input(prompt=colourise(colour,msg),ispass=ispass)
  File "/usr/local/lib/python3.5/dist-packages/shutit_util.py", line 247, in util_raw_input
    return input(prompt).strip() or default
UnboundLocalError: local variable 'input' referenced before assignment
ianmiell commented 6 years ago

Thanks again for raising this, this is gold.

ianmiell commented 6 years ago

In python3, input should be available, I think:

https://docs.python.org/3/library/functions.html#input

ianmiell commented 6 years ago

Can you let me know the output of:

python --version

python3 --version

echo input | python

echo input | python

on your host?

Thanks.

rydnr commented 6 years ago

python --version -> Python 2.7.12 python3 --version -> Python 3.5.2 echo input | python returns nothing (result code 0) echo input | python3 returns nothing (result code 0)

ianmiell commented 6 years ago

That's odd. The interpreter doesn't complain on the CL, but does in ShutIt. I'm going to add some debug.

ianmiell commented 6 years ago

I've added some debug - can you pip install --upgrade shutit and re-run? Thanks

ianmiell commented 6 years ago

I believe this is fixed...