python批量提交沙箱问题实例
作者:shichen2014 时间:2023-12-14 07:40:09
本文实例讲述了python批量提交沙箱问题,分享给大家供大家参考。具体方法如下:
出现的问题如下:
1. Popen的使用,在linux下参数用列表传,不要用字符串传 否则可能会有“OSErrorror: [Errno 2] No such file or directory”错误
2. 列表要拷贝用 shutil模块中 不然会连续append..提交完第一个样本后,后面的提交参数就错了。
代码如下:
import os
from subprocess import Popen
class SubmitCuckoo:
""""""
def __init__(self, dirctory):
"""Constructor"""
self._dirctory = dirctory
self._pargs = ["/usr/bin/python", "/home/xxx/xxx/submit.py"]
def _file_callback(self, file_path):
args = ["/usr/bin/python", "/home/xx/xxx/submit.py"]
args.append(file_path)
print "args:",args
Popen(args)
def submit_cuckoo(self, file_callback=_file_callback):
"""
"""
dir = self._dirctory
for root, dirs, files in os.walk(dir):
for f in files:
file_path = os.path.join(root, f)
if file_callback:
file_callback(self, file_path)
if __name__ == "__main__":
submit_cuckoo = SubmitCuckoo(r"/home/xxx/xxx/samples")
submit_cuckoo.submit_cuckoo()
希望本文所述对大家的Python程序设计有所帮助。
标签:python,沙箱
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python range与enumerate函数区别解析
2022-03-05 21:40:20
Python使用PyAV提取视频关键帧的实践
2023-04-29 23:45:04
![](https://img.aspxhome.com/file/2023/2/124212_0s.png)
PyTorch学习笔记之回归实战
2023-09-17 10:26:19
![](https://img.aspxhome.com/file/2023/2/78752_0s.png)
Python神经网络TensorFlow基于CNN卷积识别手写数字
2022-06-18 20:23:00
![](https://img.aspxhome.com/file/2023/3/99433_0s.png)
Python greenlet实现原理和使用示例
2023-10-02 08:22:25
mysql数据库mysql: [ERROR] unknown option '--skip-grant-tables'
2024-01-18 08:41:27
oracle11g卸载完整图文教程
2024-01-26 18:23:42
![](https://img.aspxhome.com/file/2023/4/65254_0s.png)
18个超棒的Web和移动应用开发框架
2011-03-31 17:04:00
python异常中else的实例用法
2021-02-05 06:18:56
python学习基础之循环import及import过程
2022-04-02 13:23:25
MYSQL--自身字段约束级联删除
2010-11-02 11:42:00
python 使用socket传输图片视频等文件的实现方式
2022-11-12 11:55:37
Python将py文件编译为exe文件
2023-07-29 10:05:36
![](https://img.aspxhome.com/file/2023/3/82723_0s.png)
sqlserver 触发器实例代码
2012-01-29 18:30:45
如何利用Vue3管理系统实现动态路由和动态侧边菜单栏
2024-05-05 09:25:34
![](https://img.aspxhome.com/file/2023/9/128889_0s.png)
python 类相关概念理解
2023-02-17 21:16:47
python数据结构之列表和元组的详解
2021-01-23 17:34:27
Vue结合Video.js播放m3u8视频流的方法示例
2023-07-02 16:55:40
利用Python破解生日悖论问题
2022-11-08 02:37:55
![](https://img.aspxhome.com/file/2023/5/67365_0s.jpg)
CSS设计之如何让数字字母自动换行
2007-10-19 15:12:00