Deploy Failure - Bad substitution
jackmcdougal opened this issue · 7 comments
Hi! First of all, thanks for the great project! Excited to try this out.
I am new to gcp but think I have managed to stumble through all the right setup. I can successfully deploy the dev app server (although I can't actually check the app using localhost since I setup the dev environment on a headless lxc container - I can see it listening on 8080 and 8000.
When I try to deploy to google-cloud ... using scripts/deploy 0-1, I get:
52: Bad substitution
Any thoughts? (I did see the same issue in the "installation problem" issues ... but it seems the goal there was to get the devapp server going and that error was never addressed...
Thanks!
It looks like this error can arise when running the scripts with something other than bash.
If so, I wonder if this is related to the shell configuration in your container, as implied by this SO question. Might be worth trying running the script explicitly with bash, and also changing the hash bang to !/bin/bash
to see if that helps.
Thanks! That was the issue. Changing the hash bang to !/bin/bash worked. (or running bash ./deploy.sh 0-1)
I then had to specify my python path at the top of the runtest.py (my container had nothing at /usr/bin/python)
I then ran into an error that was solved by changing line 41 in runtests.py from
print 'Error: 2+ arguments required.'
to
print ('Error: 2+ arguments required.')
I also had to modify run_tests.sh to properly specify my google-sdk path - which wasn't in my home folder.
Now I have another exception ... but before I keep hammering away at this: I noticed the devappserver won't run locally because one of the libraries doesn't support python2.7 any more.
I think I am running python3.8 for all of the above ... is it reasonable to assume this app will run on Ubuntu 20.04?
Thanks!
Thanks for that, I'm updating the bash script accordingly as well.
As for the new exception, it's true that we're still using the python2.7 runtime in gcloud. However, I'm able to run the dev app server locally (on a mac) without issue, as well as execute deploys to production. Which library are you seeing lack of support? It could be that there are support differences on Ubuntu.
In general, this codebase is in bad need of a refresh and upgrade to Python 3, and it's just not something I have time for at the moment, unfortunately.
so when running the devapp server, I get this:
ERROR 2022-07-15 16:50:36,129 wsgi.py:267]
Traceback (most recent call last):
File "/home/myusername/flowdashboard-macs/google-cloud-sdk/platform/google_appengine/python27/sdk/google/appengine/runtime/wsgi.py", line 238, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/myusername/flowdashboard-macs/google-cloud-sdk/platform/google_appengine/python27/sdk/google/appengine/runtime/wsgi.py", line 309, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/myusername/flowdashboard-macs/google-cloud-sdk/platform/google_appengine/python27/sdk/google/appengine/runtime/wsgi.py", line 83, in LoadObject
obj = __import__(path[0])
File "/home/myusername/flowdashboard-macs/flow-dashboard/flow.py", line 7, in <module>
import api
File "/home/myusername/flowdashboard-macs/flow-dashboard/api.py", line 8, in <module>
from oauth2client import client
File "/home/myusername/flowdashboard-macs/flow-dashboard/lib/oauth2client/client.py", line 38, in <module>
from oauth2client import transport
File "/home/myusername/flowdashboard-macs/flow-dashboard/lib/oauth2client/transport.py", line 17, in <module>
import httplib2
File "/home/myusername/flowdashboard-macs/flow-dashboard/lib/httplib2/__init__.py", line 396
print("%s:" % h, end=" ", file=self._fp)
^
SyntaxError: invalid syntax
INFO 2022-07-15 16:50:36,135 module.py:890] default: "GET /_ah/warmup HTTP/1.1" 500 -
Googling I found this thread:
Thanks again for the support! I have no coding experience/training so I not sure I could help. Is migrating to python3 a big job? Could something like this work? https://docs.python.org/3/library/2to3.html
The github issue linked from the SO question you linked (googleapis/google-api-python-client#704) does seem to imply there is still support for python 2 in older versions of httplib.
If you installed the python dependencies using pip install -t lib
, you should have httplib2 in the ./lib
directory. Can you check its version by looking at the __version__
declaration at the top of the __init__.py
?
In my install, I'm seeing 0.10.3
. This is the version that was installed by the google_api_python_client
version 1.5.1, I believe.
As for upgrading to python3, unfortunately it's not as easy as updating the code itself (which as you found, is quite manageable). It's the dependencies (with the google python api client as a good example) and use of various GCP libraries and APIs that would need to be updated as well, which makes it a bigger task. All doable, of course.
Thanks again.
Odd ... I have version = "0.20.4" in mine. I did install `from:
pip install -t lib -r requirements.txt pip install -r local.requirements.txt
my requirements.txt shows: google_api_python_client==1.5.1 too ...
Ok, I think it's worth a try then to downgrade httplib2. You should be able to do this by deleting the urllib2 folder from lib, adding httplib2==0.10.3 to requirements.txt at the top, and then re-running the pip install -t lib -r requirements.txt
command.