This article describes the Python batch submission sandbox problem, share for everyone reference. The specific methods are as follows:
The problems that arise are as follows:
1. The use of Popen, in the Linux parameter with the list, do not use string transmission may be "oserrorror: [Errno 2] No such file or directory" error
2. The list should be copied with Shutil module or it will be append continuously. After the first sample has been submitted, the subsequent submission parameters are wrong.
The code is as follows:
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, the 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 ()
I hope this article will help you with your Python programming.