Heroku bash on windows - python

I am trying to connect to Heroku bash on windows and use python manage.py shell iPython shell to help me type commands faster.
While this works fine if I am on Mac, on my Windows machine - the colour coding of heroku bash iPython shell and the tab-autocomplete feature does not work.
Is there some other tool I can use or can configure somewhere? I tried installing bash on Windows, and it gives me the same result

You should NOT, NOT, NOT!!#!!!!! be using Heroku's bash shell for casual python coding. This is an awful idea for many reasons:
Heroku dynos don't have a persistent filesystem. Any files on your dyno can be deleted randomly.
The amount of time it will take you to build an ipython setup / configuration from scratch, and get it running on your dyno is not worth the effort.
Heroku dynos are meant to run web processes as they restart randomly -- your terminal session may blow up at any point.
If you really want an authentic 'shell' experience, I recommend using a real shell for development -- either get yourself a virtual machine and install ubuntu, or spin up a ubuntu server machine through a host like DigitalOcean or Amazon.

Related

How to run Django server constantly on windows

I wrote a code for a Django server, and it works perfectly inside the shell of Pycharm.
Now, I want to run this server on a local computer constantly without being inside Pycharm's shell.
Also, because it's for a client of mine I don't want any open CMD windows or any other weird GUI- I want him to just access the website like any other website.
I've seen all kinds of solutions- running runserver with &, creating a virtual machine and running the server on it and etc.
I am familiar with Vmware and all, so if the proper solution is this It's OK. But I wonder- are there any other ways to run a server on a PC without installing any additional programs?

How to deploy multiple Python-Telegram-Bot (s) in local macOS (As a bot server)?

So far I am just simply open 2 sessions(I've got 2 bots so far) in macOS 'Terminal' and run the bots.
May I know if there is better way to make those bots alive? Is that the normal way that most of the people will do in this way?
Like this, once the bot is started, then I will just leave the session here for listening the requests.
Thanks all.
Way 1: Run inside docker container
You need to install docker Desktop at your Mac and run each python script in separate container
Pros:
Modern and correct way to run background processes
Running environment independent from local environment
Cons:
You need to install docker
You need to know/learn docker
Way 2: Run as daemon process inside Linux Virtual Machine [VM]
You need to install hypervisor (VirtualBox for example) and install Linux on it. After that use it like server for python scripts.
Pros:
Same as 1
Cons:
You need to install hypervisor
You need to know Linux and how to daemonize script (using systemd for example)
VM need more resources than docker
Way 3: Run process in background detached from terminal
Just run nohup pyton3 /Users/ws_fingear/Documents/workspace/Telegram_Bot/Telegram_Bot_WSFG1.0.py > output.log &. Mark & means that process will be run in background and continue to run even if you close terminal. Output will be printed out inside output.log file
Pros:
Super simple
Cons:
Bad way for production environment
Can't control or stop running process properly
I guess, you looking for way 3.
Also you can use syncthing on Mac OS to run script as daemon locally

Run Ansible-Playbook on localhost on Windows

I know Ansible supports Windows clients/nodes. What I really enjoy about Ansible is that I can create a Linux VM, pull a git repo that contains Ansible playbooks for and without any configuration or setup of a control server, I am able to run the playbook on the local machine.
Since you can execute Python on Windows, would it be possible to run roles/playbooks on localhost on Windows?
This would be the first step for running Ansible in a datacenter with only Windows where it is not possible to even run Linux in VirtualBox.
Ansible won't run on a windows control machine, as stated in the documentation:
Reminder: You Must Have a Linux Control Machine
Note running Ansible from a Windows control machine is NOT a goal of the project. Refrain from asking for this feature, as it limits what technologies, features, and code we can use in the main project in the future. A Linux control machine will be required to manage Windows hosts.
Cygwin is not supported, so please do not ask questions about Ansible running from Cygwin.

How to install django applications on a Memory Stick

I am currently developing an open source software based on python/django. The software should later be easy installable by a standard windows/linux users without any programming experiance. It should also be portable to different computers. The only installation that should be required on these computers should be python itself.
Is there a way to get this to work?
I already found this "dbuilder" Django Projects as Desktop applications : how to?
desktop-applications-how-to
It seems to be a bit outdated and not a very smooth solution.
Are there better solutions?
Just use a portable version of python on your memory stick. Make a batch file that runs
projname.bat file:
python.exe /django-app-path/manage.py runserver
now open a browser and browse for it
the default address will be:
http://127.0.0.1:8000
If you need to browse your app on other device that you're app is running:
get your server ip with
windows shell>ipconfig
linux shell# ifconfig
then run your development server on that address (in the batch file):
python.exe /django-app-path/manage.py runserver your-ip-address:port-if-not-80

How do I run Django as a service?

I am having difficulty running Django on my Ubuntu server. I am able to run Django but I don't know how to run it as a service.
Distributor ID: Ubuntu
Description: Ubuntu 10.10
Release: 10.10
Codename: maverick
Here is what I am doing:
I log onto my Ubuntu server
Start my Django process: sudo ./manage.py runserver 0.0.0.0:80 &
Test: Traffic passes and the app displays the right page.
Now I close my terminal window and it all stops. I think I need to run it as a service somehow, but I can't figure out how to do that.
How do I keep my Django process running on port 80 even when I'm not logged in?
Also, I get that I should be linking it through Apache, but I'm not ready for that yet.
Don't use manage.py runserver to run your server on port 80. Not even for development. If you need that for your development environment, it's still better to redirect traffic from 8000 to 80 through iptables than running your django application as root.
In django documentation (or in other answers to this post) you can find out how to run it with a real webserver.
If, for any other reason you need a process to keep running in background after you close your terminal, you can't just run the process with & because it will be run in background but keep your session's session id, and will be closed when the session leader (your terminal) is terminated.
You can circunvent this behaviour by running the process through the setsid utility. See your manpage for setsid for more details.
Anyway, if after reading other comments, you still want to use the process with manage.py, just add "nohup" before your command line:
sudo nohup /home/ubuntu/django_projects/myproject/manage.py runserver 0.0.0.0:80 &
For this kind of job, since you're on Ubuntu, you should use the awesome Ubuntu upstart.
Just specify a file, e.g. django-fcgi, in case you're going to deploy Django with FastCGI:
/etc/init/django-fcgi.conf
and put the required upstart syntax instructions.
Then you can you would be able to start and stop your runserver command simply with:
start runserver
and
stop runserver
Examples of managing the deployment of Django processes with Upstart: here and here. I found those two links helpful when setting up this deployment structure myself.
The problem is that & runs a program in the background but does not separate it from the spawning process. However, an additional issue is that you are running the development server, which is only for testing purposes and should not be used for a production environment.
Use gunicorn or apache with mod_wsgi. Documentation for django and these projects should make it explicit how to serve it properly.
If you just want a really quick-and-dirty way to run your django dev server on port 80 and leave it there -- which is not something I recommend -- you could potentially run it in a screen. screen will create a terminal that will not close even if you close your connection. You can even run it in the foreground of a screen terminal and disconnect, leaving it to run until reboot.
If you are using virtualenv,the sudo command will execute the manage.py runserver command outside of the virtual enviorment context, and you'll get all kind of errors.
To fix that, I did the following:
while working on the virtual env type:
which python
outputs: /home/oleg/.virtualenvs/openmuni/bin/python
then type:
sudo !!
outputs: /usr/bin/python
Then all what's left to do is create a symbolic link between the global python and the python at the virtualenv that you currently use, and would like to run on 0.0.0.0:80
first move the global python folder to a backup location:
mv /usr/bin/python /usr/bin/python.old
/usr/bin/python
that should do it:
ln -s /usr/bin/python /home/oleg/.virtualenvs/openmuni/bin/python
that's it! now you can run sudo python manage.py runserver 0.0.0.0:80 in virtaulenv context!
Keep in mind that if you are using postgres DB on your developement local setup, you'll probably need a root role.
Credit to #ydaniv

Categories

Resources