I have a question, I coded just a basic python bot, one of the commands called "ascii" takes an input from the ctx and then with subproccess.py calls a C binary, that pretty much just writes the input with "#" and " ", everything works fine when I run it on my pc, but I just put the bot on heroku and this doesn't work (other commands work), I call it with

subprocess.check_output("ascii \"" + " ".join(text) + "\"", shell=True)

In logs I get Command 'ascii "input"' returned non-zero exit status 127. which from what I've found meand that command was not found, so I guess I will have to add a directiory to the path (like /apps/bot/ascii or something) but I can't figure out what exactly to put in there or if this even is the issue.

Any ideas how to make it work?

edit_1: I tried to change the calling of the function to /app/ascii which should be the directory I thought at least, but now it returns exit status 126, which is that the command is not a executable

edit_2: Just tried to run ascii with console on heroku, at first permission denied, but after I gave it permission, it worked. Do I need to somehow set global permission to ascii? Like in requirements.txt or something?

1 Answers

0
Community On Best Solutions

Sooo, for anyone that would like to do this kind of thing, I would say, don't.. I've had a lot of trouble with the setup of this, but now, it actually works well it seems, no problems so far, but looking back, it would be much faster if I just re-wrote the .c file into python, not that difficult, much faster in the end. That said, I will tell you how I got it working and by following it, you may get it working fairly fast.

To the "tutorial": Firstly, calling the binary as I have it in the post worked perfectly, no changes needed for that.

On the github from which it was deployed I needed to add as per usual with heroku apps a procfile (you can search on the internet, pretty much 1 line of code calling the worker, the .py bot file), requirements.txt (where the non-standart libraries that I used had to be added, discord and asyncio for me) and runtime.txt (forced it to run python 3.6.8, actually probably not needed). Also, a makefile that I had to create. Don't forget to upload all needed .c and .h files you want to be using. That should be it on github.

Now to heroku:

firstly create a new app, I have not yet connected it to the github. Then I have added a C buildpack(that is what the makefile is for), and added the python buildpack that is on heroku. Then I went back to deploy and connected the github, enabled automated deploys for good measure and deployed. Now just go back to overview, configure dynos and you 'should' only see one worker, the one you added in the Procfile. Activate it and if I haven't forgotten any steps then the .c file should compile with make and the makefile and should be able to run when called by python.

Now that I look at it, it looks like 20 minutes of work lol, I spent like 2,5 days on trying to get it work...

Well, at least now you don't have to go through what I did, if anyone ever needs to do this :)

If you have any more questions, I will try to help, shoot a message, here or discord (my name is exactly the same as here and will remain so)