我试图为mac终端创建一条捷径,这样当我编写“jj”时,终端中使用的以下代码行将运行:
python 5_7_16.py
我的搭档可以为Linux写程序,但他不能为Mac写。他设法把代码的路径写成如下
FPTH="/Users/kylefoley/PycharmProjects/inference_engine2/inference2/Proofs/5_7_16.py"
当我使用pycharm软件时,这是我在使用python5\u7\u16.py之前使用的前两行代码
cd inference2
cd Proofs
我们已经在正确的位置保存了python文件jj,我们几乎可以让它工作,但还不够
另外,软件有三种模式:输出到excel,输出到django,输出到mysql。由于我不明白的原因,我的搭档认为我们需要在文件中写下什么类型的模式是活动的。我不明白为什么会这样,因为所有这些信息都已经存储在5u7u16文件中了。为了以防万一,这里是python代码的第一行
excel = True
mysql = False
if not excel and not mysql:
from inference2.models import Define3, Archives, Input
from inference2 import views
if mysql:
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
print BASE_DIR
sys.path.append(BASE_DIR)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "inference_engine2.settings")
import django
django.setup()
from inference2 import views
from inference2.models import Define3, Archives, Input
这就是他迄今为止写的东西,我想,我不明白为什么所有这些都是必要的。我想你只需要告诉mac终端你想运行什么代码:
FPTH="/Users/kylefoley/PycharmProjects/inference_engine2/inference2/Proofs/5_7_16.py"
vmysql=$(sed -i ‘’ -E ’s/^mysql = \(.*\)/\1/g’ $FPTH)
vexcel=$(sed —i ‘’ E ’s/^excel = \(.*\)/\1/g’ $FPTH)
echo $vexcel
echo $vmysql
if [ "$vexcel" == "True" ] ; then
echo "Excel"
elif [ "$vmysql" = "True" ]
then
echo "Mysql"
else
echo "Django"
fi
if [ "$vexcel" = "True" ] ; then
echo "Excel is set”
python $FPTH
elif [ "$vmysql" = "True" ]
then
echo "Mysql is set”
python $FPTH
else
echo “Django is set”
cd /dUsers/kylefoley/PycharmProjects/inference_engine2
python manage.py runserver
fi
您需要在
.bash_profile
文件中添加别名。 有关详细信息,请选中:About .bash_profile, .bashrc, and where should alias be written in?以下是要遵循的步骤:
你现在可以做了
从bash手册页:
相关问题 更多 >
编程相关推荐