preilly has submitted this change and it was merged.

Change subject: fix. removal of deploy folder once sync completes.
......................................................................


fix. removal of deploy folder once sync completes.

Change-Id: I0b481935d5d47002f442cde15158a50be3606842
---
M sartoris/sartoris.py
1 file changed, 19 insertions(+), 1 deletion(-)

Approvals:
  Rfaulk: Verified; Looks good to me, approved
  preilly: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/sartoris/sartoris.py b/sartoris/sartoris.py
index 110cc09..2676700 100755
--- a/sartoris/sartoris.py
+++ b/sartoris/sartoris.py
@@ -23,6 +23,8 @@
 import logging
 import argparse
 import os
+import stat
+import shutil
 import sys
 from re import search
 import subprocess
@@ -75,6 +77,19 @@
     class NullHandler(logging.Handler):
         def emit(self, record):
             pass
+
+
+def remove_readonly(fn, path, excinfo):
+    """
+    Modifies path to writable for recursive path removal.
+        e.g. shutil.rmtree(path, onerror=remove_readonly)
+    """
+    if fn is os.rmdir:
+        os.chmod(path, stat.S_IWRITE)
+        os.rmdir(path)
+    elif fn is os.remove:
+        os.chmod(path, stat.S_IWRITE)
+        os.remove(path)
 
 # Add a do-nothing NullHandler to the module logger to prevent "No handlers
 # could be found" errors. The calling code can still add other, more useful
@@ -390,7 +405,10 @@
                 exit_code = 40
                 log.error("{0}::{1}".format(__name__, exit_codes[exit_code]))
                 return exit_code
-        os.unlink('.git/deploy')
+
+        os.remove(self.DEPLOY_DIR + self.LOCK_FILE_HANDLE)
+        shutil.rmtree(self.DEPLOY_DIR, onerror=remove_readonly)
+
         return 0
 
     def resync(self, args):

-- 
To view, visit https://gerrit.wikimedia.org/r/64034
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0b481935d5d47002f442cde15158a50be3606842
Gerrit-PatchSet: 1
Gerrit-Project: sartoris
Gerrit-Branch: master
Gerrit-Owner: Rfaulk <[email protected]>
Gerrit-Reviewer: Rfaulk <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-Reviewer: preilly <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to