新代码的引擎有问题,引擎有若干版本源代码,不知道哪个版本是正确的。写个python程序,从git版本管理上每个版本取一次,自动比较,直到找到最相近的为止。
练习雏形
在/etc/profile 尾部添加我的shell脚本路径。所有又用的脚本都放到该路径下,以后调用这些脚本的时候就像调用系统命令一下,不用再输入路径了。比如我的脚本路径是/home/wulong/program/myshell。在/etc/profile尾部添加路径
#todo: wulong add my shell
myshell_path=/home/wulong/program/myshell
export PATH=$PATH:$myshell_path
export myshell_path
#endif
compare_folder.sh和compare_folder.py文件都放在myshell路径下
比如要击比较 ./src 与 ./old_src 。初版只比较文件数目。后面再添加 “比较文件名"--->比较文件内容0---->合并文件内容
调用方法如下
$compare_folder.sh ./src ./old_src
compare_folder.sh内容如下
#!/bin/bash
if [ $# -eq 2 ]
then
parent_path=`pwd`
one_path=`cd $parent_path ; cd $1 ; pwd`
two_path=`cd $parent_path ; cd $2 ; pwd`
sh_whole_path=`which compare_folder.sh`
sh_path=`dirname $sh_whole_path`
cd $sh_path #sh 与py在同一个文件夹下,文件路径要加到系统path中
python compare_folder.py $one_path $two_path
cd $parent_path
else
echo "need two params"
fi
compare_folder.py内容如下
#!/usr/bin/python
import sys
import os
def get_file_list(path):
f_l = []
if os.path.isdir(path):
for tmp in os.listdir(path):
tmp = path + "/" + tmp
if os.path.isdir(tmp):
ret_list = get_file_list(tmp)
f_l.extend(ret_list)
# for tmp in ret_list:
# f_l.append(tmp)
else:
f_l.append(tmp)
else:
f_1.append(path)
return f_l
def filter_path_name_list(path_list, parent_path):
new_list = []
if len(path_list):
for tmp in path_list:
tmp = tmp.replace(parent_path,"")
new_list.append(tmp)
return new_list
andengine_path=""
baofen_path=""
if len(sys.argv) == 3:
andengine_path = sys.argv[1]
baofen_path = sys.argv[2]
print len(sys.argv),", ",sys.argv[1],", ",sys.argv[2]
print andengine_path
print baofen_path
if os.path.isdir(andengine_path) and os.path.isdir(baofen_path):
andengine_file_list = get_file_list(andengine_path)
baofen_file_list = get_file_list(baofen_path)
andeng