pexpect does not work fabric-classic
gscorrea opened this issue · 4 comments
gscorrea commented
Migrating from fabric3 to fabric 1.18.0 breaks import of pexpect as fabric api put method requires mode value in octal and it is putting pexpect module with put with integer mode values.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/fabric/main.py", line 685, in main
docstring, callables, default = load_fabfile(fabfile)
File "/usr/local/lib/python3.8/dist-packages/fabric/main.py", line 177, in load_fabfile
imported = importer(os.path.splitext(fabfile)[0])
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/gscorrea/fabfilelab.py", line 23, in <module>
from ilogue.fexpect import expect, expecting, erun, esudo
File "/usr/local/lib/python3.8/dist-packages/ilogue/fexpect/__init__.py", line 1, in <module>
from ilogue.fexpect.api import expect, expecting, run, sudo, local
File "/usr/local/lib/python3.8/dist-packages/ilogue/fexpect/api.py", line 2, in <module>
from ilogue.fexpect.internals import wrapExpectations, wrapExpectationsLocal, ExpectationContext
File "/usr/local/lib/python3.8/dist-packages/ilogue/fexpect/internals.py", line 23
fabric.api.put(pexpect_module,'/tmp/', mode=0777)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
ploxiln commented
looks like ilogue/fexpect/internals.py
is not compatible with python3, this doesn't really have anything to do with the fabric library
ploxiln commented
(the problem is in https://github.com/ilogue/fexpect, not here)
gscorrea commented
I figured it out and modified internals.py.
I just have a question, why fabric-classic adopted put mode as octal and not integer like it was before?
ploxiln commented
The change is in python3, not in fabric. It is still integer in all cases, octal is just a way of writing integers "literal values".
$ python2
Python 2.7.17 (default, Jan 14 2020, 03:01:26)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def test(mode):
... print(mode)
...
>>> test(0o777)
511
>>> test(0777)
511
$ python3
Python 3.7.7 (default, Mar 12 2020, 20:55:24)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def test(mode):
... print(mode)
...
>>> test(0o777)
511
>>> test(0777)
File "<stdin>", line 1
test(0777)
^
SyntaxError: invalid token