错误:PermissionError:[WinError 5]访问被拒绝:

时间:2019-04-23 10:34:28

标签: python node.js

我正在使用this(trufflehog.py) python module to scan any github repo

通过在Windows命令行中使用CLI来获得准确的结果。

但是现在我正在尝试使用nodeJs。所以我正在使用PythonShell,通过它我将执行与cli相同的操作。

NodeJs代码:-

var pythonShell= require("python-shell")

var options = {
 args: ['--regex','put your repo address here.']
};

pythonShell.PythonShell.run('truffleHog.py',options,function (err,results) {
  if (err) throw err;
console.log('finished'+err);
   console.log('results: %j', results);
});

但是从上面的代码中出现了错误:-

Error: PermissionError: [WinError 5] Access is denied: 'C:\\Users\\sagar\\AppData\\Local\\Temp\\tmp6ji867wv'
    at PythonShell.parseError (E:\node_server\node_modules\python-shell\index.js:246:21)
    at terminateIfNeeded (E:\node_server\node_modules\python-shell\index.js:129:32)
    at ChildProcess.<anonymous> (E:\node_server\node_modules\python-shell\index.js:121:13)
    at ChildProcess.emit (events.js:189:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
    ----- Python Traceback -----
    File "C:\Users\sagar\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 567, in _rmtree_unsafe
      os.rmdir(path)
  PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\sagar\\AppData\\Local\\Temp\\tmp6ji867wv'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "truffleHog.py", line 312, in <module>
      main()
    File "truffleHog.py", line 57, in main
      output = find_strings(args.git_url, args.since_commit, args.max_depth, args.output_json, args.do_regex, do_entropy, surpress_output=False, branch=args.branch, repo_path=args.repo_path)
    File "truffleHog.py", line 303, in find_strings
      shutil.rmtree(project_path, onerror=del_rw)
    File "C:\Users\sagar\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 681, in rmtree
      return _rmtree_unsafe(path, onerror)
    File "C:\Users\sagar\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 569, in _rmtree_unsafe
      onerror(os.rmdir, path, sys.exc_info())
    File "truffleHog.py", line 83, in del_rw
      os.remove(name)

很高兴找出这个问题。

0 个答案:

没有答案