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版脚本的更多相关文章

  1. 跨过Nginx上基于uWSGI部署Django项目的坑

    先说说他们的关系,Nginx和uWSGI都是Web服务器,Nginx负责静态内容,uWSGI负责Python这样的动态内容,二者配合共同提供Web服务以实现提高效率和负载均衡等目的.uWSGI实现了多 ...

  2. Django项目的ORM操作之--数据模型类创建

    在django项目中,其自带了ORM(Object Relation Mapping)对象关系映射框架,我们在django项目下app的models模块下对类进行操作,通过ORM会将我们对类的操作转化 ...

  3. django项目的uwsgi方式启停脚本

    #!/bin/sh NAME="fushentang" if [ ! -n "$NAME" ];then echo "no arguments&quo ...

  4. docker笔记(3) ------Django项目的docker部署

    2019-01-12   14:23:18 django容器连接到mysql_server容器分析:原myblog项目使用sqlit3数据库,使用mysql容器前需要在django中加入pymysql ...

  5. Django项目的ORM操作之--模型类数据查询

    1.查询基本格式及理解: 类名.objects.[查询条件] 例如我们要查询数据库中一张表(bookinfo)的所有数据,sql语句为:select * from bookinfo, 对应模型类的操作 ...

  6. 决解nginx代理的django项目的admin站点无法访问,和没样式的问题。

    首先我们先解决无法访问admin站点的问题 首先我们先修改一下nginx的配置,添加红色框框的部分. 然后重新启动一下nginx 访问一下admin站点 发现没有样式了. 我们先修改/fast_foo ...

  7. CentOS7下Docker中构建可以自动发布到项目的Tomcat容器

    步骤 下载镜像 搜索相应的镜像文件:docker search 'tomcat' 如下 下载镜像:docker pull tomcat:7,如下图 PS:后面的数字代表tomcat的版本,可以自己选择 ...

  8. 当前,我们的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 ...

  9. 如何查看Ubuntu服务器上Django项目的MySQL服务有没有挂?

    如果你在项目内输入:MySQL -uroot -p 接着输入密码之后返回ERROR:1045……如下图 那么这就说明MySQL服务挂了. 需要重新启动一下 重启时在项目目录下输入:sudo servi ...

随机推荐

  1. 一个项目中哪些文件是要上传到 git上的,哪些是不必要的

  2. [IOS 同步GET和POST数据的模版]

    1.同步GET (联网检测) +(BOOL)checkConnect{ // 初始化请求 NSMutableURLRequest *request = [[NSMutableURLRequest al ...

  3. CF Gym 100685E Epic Fail of a Genie

    传送门 E. Epic Fail of a Genie time limit per test 0.5 seconds memory limit per test 64 megabytes input ...

  4. Activity的成员变量

    // set by the thread after the constructor and before onCreate(Bundle savedInstanceState) is called. ...

  5. PHP防止重复提交表单(helloweba网站经典实例)

    <?php session_start(); header("Content-Type:text/html;charset:utf8"); function set_toke ...

  6. iOS 刚刚,几分钟前,几小时前,几天前,几月前,几年前

    - (NSString *)compareCurrentTime:(NSDate*) compareDate { NSTimeInterval timeInterval = [compareDate ...

  7. Unity 游戏资源ktx转换png

    Unity 开发的模型贴图都是.ktx格式的,提取出来的资源,其中的ktx资源,用PVRTexToolGUI.exe可以打开查看,可以发现都是上下颠倒,且被拉伸 直接转为png格式的批处理脚本为: @ ...

  8. 新浪微博客户端(17)-集成MJExtension

    使用MJExtension框架将字典转换为模型 DJHomeViewController.m /** 载入新的微博数据 */ - (void)loadNewStatues { AFHTTPSessio ...

  9. sqlplus 配置方法及相关命令

    sqlplus 配置方法及相关命令 1.配置文件 1.1 全局模式什么叫全局模式呢:当我们配置完sqlplus工具加载配置文件后,无论在哪个目录下登陆数据库,您设置[sqlplus提示符样子,在任何目 ...

  10. absolute布局和css布局释疑

    jqueryui也不是万能的, 有时候, 也需要自己写一些, 由 css 和jquery结合的一些东西, 如: banner中, 依次播放的div等 ## 关于jquery设计的一些思想和理念?but ...