jython2.7 删除文件夹

删除文件夹

 1 import os
 2 import shutil
 3 def rmdir(path):
 4     folder = os.path.exists(path)
 5     if folder:
 6         os.rmdir(path)
 7 def shutildir(path):
 8     folder = os.path.exists(path)
 9     if folder:
10         shutil.rmtree(path)
11 try:
12     flowFile = session.get()
13     f1 = flowFile.getAttribute('filePath')
14     f2 = flowFile.getAttribute('fileRange')
15     dir = '/shared/winshare/'+f1
16     if f1 !="":
17         if f2 == "all":
18             shutildir(dir)
19         elif f2 == "only":
20             rmdir(dir)
21     session.transfer(flowFile, REL_SUCCESS)
22 except:
23     session.transfer(flowFile, REL_FAILURE)

 

posted @ 2021-07-22 14:23  木章  阅读(60)  评论(0编辑  收藏  举报