Python发布Django项目的pyc版脚本
import os
import sys
from py_compile import compile #print "argvs:",sys.argv if len(sys.argv) == 3:
comd = sys.argv[1]
path = sys.argv[2]
if os.path.exists(path) and os.path.isdir(path):
for parent,dirname,filename in os.walk(path):
for cfile in filename:
fullname = os.path.join(parent,cfile)
if comd == 'clean' and cfile[-4:] == '.pyc':
try:
os.remove(fullname)
print "Success remove file:%s" % fullname
except:
print "Can't remove file:%s" % fullname
if comd == 'compile' and cfile[-3:] == '.py':
try:
compile(fullname)
print "Success compile file:%s" % fullname
except:
print "Can't compile file:%s" % fullname
if comd == 'remove' and cfile[-3:] == '.py' and cfile != 'settings.py' and cfile != 'wsgi.py':
try:
os.remove(fullname)
print "Success remove file:%s" % fullname
except:
print "Can't remove file:%s" % fullname
else:
print "Not an directory or Direcotry doesn't exist!"
else:
print "Usage:"
print "\tpython compile_pyc.py clean PATH\t\t#To clean all pyc files"
print "\tpython compile_pyc.py compile PATH\t\t#To generate pyc files"
print "\tpython compile_pyc.py remove PATH\t\t#To remove py files"
Python发布Django项目的pyc版脚本的更多相关文章
- 跨过Nginx上基于uWSGI部署Django项目的坑
先说说他们的关系,Nginx和uWSGI都是Web服务器,Nginx负责静态内容,uWSGI负责Python这样的动态内容,二者配合共同提供Web服务以实现提高效率和负载均衡等目的.uWSGI实现了多 ...
- Django项目的ORM操作之--数据模型类创建
在django项目中,其自带了ORM(Object Relation Mapping)对象关系映射框架,我们在django项目下app的models模块下对类进行操作,通过ORM会将我们对类的操作转化 ...
- django项目的uwsgi方式启停脚本
#!/bin/sh NAME="fushentang" if [ ! -n "$NAME" ];then echo "no arguments&quo ...
- docker笔记(3) ------Django项目的docker部署
2019-01-12 14:23:18 django容器连接到mysql_server容器分析:原myblog项目使用sqlit3数据库,使用mysql容器前需要在django中加入pymysql ...
- Django项目的ORM操作之--模型类数据查询
1.查询基本格式及理解: 类名.objects.[查询条件] 例如我们要查询数据库中一张表(bookinfo)的所有数据,sql语句为:select * from bookinfo, 对应模型类的操作 ...
- 决解nginx代理的django项目的admin站点无法访问,和没样式的问题。
首先我们先解决无法访问admin站点的问题 首先我们先修改一下nginx的配置,添加红色框框的部分. 然后重新启动一下nginx 访问一下admin站点 发现没有样式了. 我们先修改/fast_foo ...
- CentOS7下Docker中构建可以自动发布到项目的Tomcat容器
步骤 下载镜像 搜索相应的镜像文件:docker search 'tomcat' 如下 下载镜像:docker pull tomcat:7,如下图 PS:后面的数字代表tomcat的版本,可以自己选择 ...
- 当前,我们的DJANGO项目的requirements.txt文件
晒一晒,看用得多不多..:) amqp==1.4.7 anyjson==0.3.3 billiard==3.3.0.21 celery==3.1.19 celery-with-redis==3.0 c ...
- 如何查看Ubuntu服务器上Django项目的MySQL服务有没有挂?
如果你在项目内输入:MySQL -uroot -p 接着输入密码之后返回ERROR:1045……如下图 那么这就说明MySQL服务挂了. 需要重新启动一下 重启时在项目目录下输入:sudo servi ...
随机推荐
- nginx root && alias 文件路径配置
文章摘自:http://www.ttlsa.com/nginx/nginx-root_alias-file-path-configuration/ nginx指定文件路径有两种方式root和alias ...
- POJ-1273 Drainage Ditches 最大流Dinic
Drainage Ditches Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 65146 Accepted: 25112 De ...
- Robot Framework测试框架学习笔记
一.Robot Framework框架简介 Robot Framework是一种基于Python的可扩展关键字驱动自动化测试框架,通常用于端到端的可接收测试和可接收测试驱动的开发.可以 ...
- iOS动画中的枚举UIViewAnimationOptions
若本帖转出“博客园”请注明出处(博客园·小八究):http://www.cnblogs.com/xiaobajiu/p/4084747.html 笔记 首先这个枚举属于UIViewAnimation. ...
- Yii查看执行的SQL
开户debug 修改配置文件 :protected/config/main.php, 'log' => array( 'class' => 'CLogRouter', ...
- 浏览器的中的 XMLHttpRequest 对象的使用
使用XMLHttpRequest浏览器对象(IE5.IE6中是ActiveXObject对象)可以实现异步请求,Ajax就是以此为基础进行的封装. 1.同步与异步: <script type=& ...
- hdu 1284 钱币兑换问题(动态规划)
Ac code : 完全背包: #include<stdio.h> #include<string.h> int dp[4][40000]; int main(void) { ...
- hdu 1202 The calculation of GPA
感觉本题没有什么好解释的,已知公式,直接编程即可. 1.统计所有 科目的学分 得到总学分 2.统计所有 成绩对应的绩点*对应的学分即可(如果成绩==-1直接continue,不进行统计),得到总绩点. ...
- linux下安装phpredis扩展--update20141127
***今天又装了phpredis,更新一下phpredis的下在地址**** 1.下载php所需的模块owlient-phpredis-90ecd17.tar.gz(tar.gz文件下载:owlien ...
- <span>和<a>的margin上下和padding上下不起作用的原因和解决
使用到了<span>和<a>标签,发现在样式里面直接写margin-top.margin-bottom和padding-top.padding-bottom都不起作用,页面样式 ...