if you ever need to create a new python 2 virtual environment: conda create --name thenameyouwant python=2 anaconda
In [1]:
from fabric.api import *
env.host_string="ec2-35-166-108-198.us-west-2.compute.amazonaws.com"
env.user = "ubuntu"
env.key_filename = ['/home/cognizac/Downloads/Stevens-key2.pem']
In [2]:
# run a command on the server to make sure you're connected
run('uname -a')
Out[2]:
In [4]:
# stop the service for your project so you can edit the code
sudo('service myproject stop')
Out[4]:
In [5]:
# stop nginx so you can use port 41593 for testing
sudo('service nginx stop')
Out[5]:
In [6]:
# download the current code for your project
get('myproject.py')
Out[6]:
In [7]:
# see what directory your currently in on the local machine
pwd
Out[7]:
In [10]:
# cd into the directory created when you downloaded the project.py file
import os
os.chdir('ec2-35-166-108-198.us-west-2.compute.amazonaws.com/')
In [11]:
# checking to make sure we're in the right working directory
pwd
Out[11]:
In [12]:
# list the files to see what's there
ls
In [26]:
# edit the code in a separate window, feel free to use my code
put('myproject.py')
Out[26]:
In [ ]:
# if you are using my code with TextBlob make sure to install TextBlob to the chatbot env
with prefix('source activate chatbot'):
run('pip install textblob')
In [27]:
# we need to use our chatbot virtual environment to run the server code
with prefix('source activate chatbot'):
run('python myproject.py')
#if you need to stop the server script, just select this cell and click the stop button at the top
In [28]:
# after you've stopped the server, make sure it's not still running remotely
sudo('killall python')
Out[28]:
In [29]:
sudo('service myproject start')
sudo('service nginx start')
Out[29]:
In [ ]: