Serverless Deploy Pip fails - Manual Pip succeeds - python

I wrote a python Serverless application.
I have a requirements.txt file that looks like:
git+https://github.com/Blah1/blah2#1.0#egg=blah3
oauth2==1.9.0.post1
When I run sls deploy or sudo sls deploy it fails saying:
Command "git clone -q https://github.com/Blah1/blah2.git /tmp/pip-install-jxs9quvp/blah2" failed with error code 128 in None
I've tried changing to ssh - same error.
I've tried to download it manually - works fine.
I've tried changing the command to use the local files I downloaded and
depending on the setup:
Fails with the same error code 128 in None error
Fails with a different error saying it can't find the file even though I verified path and

Related

Issue in creating a layer for AWS lambda for psycopg2

I am trying to create a layer for aws lambda for psycopg. I am following the answer to the question - psycopg2 folder zipped into python venv lambda function
Screenshot of the process from above link
However I am getting the below error while executing the docker step.
$ docker run "lambci/lambda:build-python3.8" /bin/sh -c "pip install -r requirements.txt -t /python/lib/python3.8/site-packages/; exit"
**docker: Error response from daemon: failed to create shim task: OCI
runtime create failed: runc create failed: unable to start container
process: exec: "C:/Users/aameen/AppData/Local/Programs/Git/usr/bin/sh":
stat C:/Users/aameen/AppData/Local/Programs/Git/usr/bin/sh: no such file
or directory: unknown.**
I am executing this on the git bash on windows. May be the problem lies there.

Lemur + PostgreSQL - can't render element of type

I'm trying to locally deploy a Netflix open project locally using the following documentation
https://media.readthedocs.org/pdf/lemur/latest/lemur.pdf (page 46)
and following these steps:
git clone git://github.com/netflix/lemur.git
# Create a python virtualenv
mkvirtualenv lemur
# Make the magic happen
make
When I call lemur init I get the following error:
sqlalchemy.exc.CompileError: (in table 'authorities', column 'options'): Compiler <sqlalchemy.dialects.sqlite.base.SQLiteTypeCompiler object at 0x10aaa3dd0> can't render element of type <class 'sqlalchemy.sql.sqltypes.JSON'>
I have a Postgres SQL server running locally (using docker) only address
postgresql://lemur:lemur#localhost:5432/lemur
But it's seems that the project fails to connect.
This is how I deployed to database docker:
docker run --name some-postgres -e POSTGRES_DB=lemur -e POSTGRES_USER=lemmr -e POSTGRES_PASSWORD=lemur -p 5432:5432 -d postgres
Working on Mac OS
Please advise
Issue was caused because a config file was not created, which by default caused Lemur to access SQlite.
Before calling 'lemur init' called 'lemur create_config', which resolved the issue.

Python Heroku allow pushed .exe to run - OSError: [Errno 13] Permission denied

I had to push an .exe file to heroku to be able to create invoice pdfs. It works localy without any problems but on heroku I get an error:
OSError: [Errno 13] Permission denied
Probably because I am not allowed to execute .exe files. So I need somehow to create a rule that this file is allowed to execute.
I pushed wkhtmltopdf.exe to heroku and I access this file in my method to create a pdf:
MYDIR = os.path.dirname(__file__)
path_wkthmltopdf = os.path.join(MYDIR + "/static/executables/", "wkhtmltopdf.exe")
config = pdfkit.configuration(wkhtmltopdf=path_wkthmltopdf)
Was not able to find a solution yet.
EDIT:
Tryed giving permission with chmod through heroku bash and also adding a linux executable but still the same error:
~/static/executables $ chmod a+x wkhtmltopdf-linux.exe
~ $ chmod a+x static/executables/wkhtmltopdf-linux.exe
Using sudo gave me:
bash: sudo: command not found
I'm not very familiar with heroku, but if you can somehow get access to terminal of environment of your application (for example ssh to your server), you need to change permissions of that file so it can be executed. To do that, you need to run in that terminal:
sudo chmod a+x /path/to/file/FILENAME
Also,i'm pretty sure your app on Heroku runs on Linux, specifically on Ubuntu, since it's the default (link)
It means there might be difficulties with running Windows executables.
Okay I managed to fix this with a buildpack. In addition wkhtmltopdf-pack must be installed and added to the requirements.txt.
Then you have to set a config var in heroku for the wkhtmltopdf executable which will be generated from the files provided in the buildpack. Do not search for an .exe file.
heroku config:set WKHTMLTOPDF_BINARY=wkhtmltopdf-pack
You can see all your config vars also in the heroku dashboard under settings, you can also create it there and not use the CLI.
Then you have to tell the pdfkit configuration where to find the WKHTMLTOPDF_BINARY:
In my config.py:
import subprocess
WKHTMLTOPDF_CMD = subprocess.Popen(
['which', os.environ.get('WKHTMLTOPDF_BINARY', 'wkhtmltopdf')], # Note we default to 'wkhtmltopdf' as the binary name
stdout=subprocess.PIPE).communicate()[0].strip()
For the pdfkit configuration:
config = pdfkit.configuration(wkhtmltopdf=app.config['WKHTMLTOPDF_CMD'])
Now you should be able to create the pdf, example:
the_pdf = pdfkit.from_string("something", False, configuration=config)
Credit to this tutorial:
https://artandlogic.com/2016/12/generating-pdfs-wkhtmltopdf-heroku/

Running Django locally with heroku fails due to missing Procfile

I have a Django 1.11/Python 3.5 app that I built and want to run on Heroku locally. It's a simple SPA using the Heroku Django template provided on GitHub (https://github.com/heroku/heroku-django-template). I followed a Heroku tutorial (https://devcenter.heroku.com/articles/deploying-python#how-to-keep-build-artifacts-out-of-git), but I cannot seem to run the app locally using the following command:
heroku local web
Running this produces the following error:
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open '.env'
at Object.fs.openSync (fs.js:584:18)
at Object.fs.readFileSync (fs.js:491:33)
at loadEnvsFile (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/foreman/lib/envs.js:133:15)
at Array.map (native)
at loadEnvs (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/foreman/lib/envs.js:148:30)
at Command.<anonymous> (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/foreman/nf.js:72:16)
at Command.listener (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/commander/index.js:301:8)
at emitTwo (events.js:106:13)
at Command.emit (events.js:194:7)
at Command.parseArgs (/snap/heroku/414/lib/node_modules/heroku-cli/node_modules/commander/index.js:615:12)
My .env file looks like this:
WEB_CONCURRENCY=3
SECRET_APP_KEY="xxxxxxxxxxxxxxxxxxxx"
I ran chmod 777 on .env but I get the same error.
When I run the following command:
heroku local
I get the following error:
[WARN] EACCES: permission denied, open 'Procfile'
[FAIL] No Procfile and no package.json file found in Current Directory - See run.js --help
▸ Cannot convert undefined or null to object
My Procfile looks like this:
web: gunicorn personal_website.wsgi
Now I cannot understand why when running "heroku local web" I get the previously mentioned error, especially after giving it the necessary permissions.
Also, others have had the same error when running "heroku local", but the answer is to "make sure the formatting of your Procfile is correct." Well mine is correct and have tried many variations to it.
I have seen others with this issue on SO and some have been resolved, unfortunately for me none of them worked.
What could I possibly be doing wrong here?

Python Fabric error when executing git archive command

I'm running Fabric on a windows 7 machine, when I type:
fab production setup
I get the following error:
[localhost] run: git archive --format=tar master > 20110221142115.tar
Warning: local() encountered an error (return code 1) while executing 'git archi
ve --format=tar master > 20110221142115.tar'
the fabric file works fine on my Windows XP machine, but I can't seem to get past this error. I also tried running the "git archive" command from the prompt, it works fine no issues. Any idea why Fabric is puking?
If the same script/command works on Windows XP, then did you check if Windows 7 firewall or any sort-of-protection is not allowing your connection to go through? Try if the following works on interactive prompt:
from fabric.api import local
local('git archive')

Categories