client: make log helpful if PermissionError happens

Bug: 1239809
Change-Id: I6a0063a48fb9b20063b7f54b728fb0aa28347873
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-py/+/3103565
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Junji Watanabe <jwata@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
NOKEYCHECK=True
GitOrigin-RevId: 6c68395603cec7f05cea56b8ae60d6fa7bf51d9b
diff --git a/local_caching.py b/local_caching.py
index 27d15b5..a2a3e70 100644
--- a/local_caching.py
+++ b/local_caching.py
@@ -4,6 +4,8 @@
 
 """Define local cache policies."""
 
+from __future__ import print_function
+
 import errno
 import io
 import logging
@@ -913,6 +915,13 @@
         file_path.ensure_tree(dst)
         return 0
       except (IOError, OSError, PermissionError) as ex:
+        if sys.platform == 'win32':
+          print("There may be running process in cache"
+                " e.g. https://crbug.com/1239809#c14",
+                file=sys.stderr)
+          subprocess.check_call(
+              ["powershell", "get-process | select path,starttime"])
+
         # Raise using the original traceback.
         exc = NamedCacheError(
             'cannot install cache named %r at %r: %s' % (name, dst, ex))