# 使用提醒:
# 1. xbot包提供软件自动化、数据表格、Excel、日志、AI等功能
# 2. package包提供访问当前应用数据的功能,如获取元素、访问全局变量、获取资源文件等功能
# 3. 当此模块作为流程独立运行时执行main函数
# 4. 可视化流程中可以通过"调用模块"的指令使用此模块
import os
import stat
import shutil
import xbot
from xbot import print, sleep
from .import package
from .package import variables as glv
def _addWritePermForFile(filePath):
os.chmod(filePath, stat.S_IWUSR)
if not os.access(filePath, os.W_OK):
os.chmod(filePath, stat.S_IWUSR)
def _addWritePermForFiles(rootPath):
if not os.path.exists(rootPath): return
if os.path.isdir(rootPath):
_addWritePermForFile(rootPath)
listItems = os.listdir(rootPath)
for item in listItems:
nextPath = os.path.join(rootPath, item)
if (os.path.isfile(nextPath)):
_addWritePermForFile(nextPath)
else:
_addWritePermForFiles(nextPath)
elif os.path.isfile(rootPath):
# called only if rootPath is a file
_addWritePermForFile(rootPath)
def remove(rootPath):
_addWritePermForFiles(rootPath)
if (os.path.isdir(rootPath)):
shutil.rmtree(rootPath)
else:
os.remove(rootPath)
def main(args):
#if args is None:
# rootPath = "";
#else:
# rootPath = args.get("rootPath", "")
remove(args)