Skip to content

Commit

Permalink
perf(py): 🚸 Code Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
ys1231 committed Mar 14, 2024
1 parent ee2b939 commit a19359d
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/sosearch.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ options:
参数 保存到文件
```
# 编译命令
- `~/.bin` 为PATH路径 可自行修改
```shell
rm -rf out build *.log searchso.spec
pyinstaller -F -w ./main.py --distpath=out -n sosearch
cp ./sosearch ~/.bin
sudo chmod a+x ~/.bin/sosearch
sudo chmod a+x ~/.bin/sosearch
```
5 changes: 3 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rm -rf out build *.log searchso.spec
pyinstaller -F -w ./main.py --distpath=out -n sosearch
mkdir build || cd build
rm -rf out searchso.spec
pyinstaller -F -w ./../main.py --distpath=out -n sosearch
cp ./out/sosearch ~/.bin
sudo chmod a+x ~/.bin/sosearch
14 changes: 9 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def searchso(sopath, s):
arrayStr = []
result = None
if out is not None:
print("> {}:开始分析!".format(os.path.split(sopath)[1]))
print("> commad: strings -a {} | grep {}".format(sopath, s))
# print("> {}:开始分析!".format(os.path.split(sopath)[1]))
# print("> commad: strings -a {} | grep {}".format(sopath, s))
result = out.decode('utf-8')
if args.saveall is not None and result is not None:
with open(args.saveall, 'a') as f:
Expand All @@ -30,19 +30,23 @@ def searchso(sopath, s):
f.close()
try:
if args.ignorecase == 1:
print("> -i 1 默认忽略大小写")
# print("> -i 1 默认忽略大小写")
items = re.finditer(s, result, re.IGNORECASE)
else:
items = re.finditer(s, result)
print("> -i 0 区分大小写")
# print("> -i 0 区分大小写")
isfind = False
for i in items:
isfind = True
arg = result[i.start():-1]
print(arg[:arg.find('\n')])
if args.output:
arrayStr.append(arg[:arg.find('\n')])
if isfind == True:
print('search {} found'.format(os.path.split(sopath)[1]))
except Exception as e:
print(e)
print("> {}:分析完成!".format(os.path.split(sopath)[1]))
# print("> {}:分析完成!".format(os.path.split(sopath)[1]))
if args.output is not None and len(arrayStr):
with open(args.output, 'a') as f:
f.write('<====' + os.path.split(sopath)[1] + "====\n")
Expand Down

0 comments on commit a19359d

Please sign in to comment.