From 59c6e03ea7c62406057de397a06086018075835b Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 6 Aug 2008 07:39:28 +0530 Subject: Just spent the better part of an hour tracing a regression that turned out to be a missing '/' Tell me. What did I do to deserve this? --- slave/autotua/chroot/__init__.py | 9 +++++---- slave/cleanup_on_death.py | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/slave/autotua/chroot/__init__.py b/slave/autotua/chroot/__init__.py index 3197176..cdc02c2 100644 --- a/slave/autotua/chroot/__init__.py +++ b/slave/autotua/chroot/__init__.py @@ -93,9 +93,10 @@ class WorkChroot(object): def _clean_mounts(self): # /proc/mounts is more reliable than mtab (which is what `mount` uses) mounts = open('/proc/mounts', 'r').read() - regex = re.compile(r'%s/[^ ]+' % self.chrootdir.replace(' ', r'\040')) + regex = re.compile(r'%s/[^ ]+' % self.chrootdir.replace(' ', r'\\040')) for mount in regex.findall(mounts): - subprocess.check_call('umount "%s"' % mount.replace(r'\040', ' '), shell=True) + mount = mount.replace(r'\040(deleted)', '').replace(r'\040', ' ') + subprocess.check_call('umount "%s"' % mount, shell=True) def _bind(self, src, dest, ro=True): """ @@ -148,7 +149,7 @@ class WorkChroot(object): """ self._clean_mounts() if osp.isdir('%s/tmp/autotua' % self.chrootdir): - if not os.isdir('%s/tmp/aututoa-old' % self.chrootdir): - os.makedirs('%s/tmp/aututoa-old' % self.chrootdir) + if not osp.isdir('%s/tmp/autotua-old' % self.chrootdir): + os.makedirs('%s/tmp/autotua-old' % self.chrootdir) shutil.move('%s/tmp/autotua' % (self.chrootdir), '%s/tmp/autotua-old/autotua-%s' % (self.chrootdir, strftime('%Y%m%d%H%M%S'))) diff --git a/slave/cleanup_on_death.py b/slave/cleanup_on_death.py index e8f6e42..00c37ea 100755 --- a/slave/cleanup_on_death.py +++ b/slave/cleanup_on_death.py @@ -13,9 +13,10 @@ from autotua import const def clean_mounts(): # /proc/mounts is more reliable than mtab (which is what `mount` uses) mounts = open('/proc/mounts', 'r').read() - regex = re.compile(r'%s/[^ ]+' % const.TMPDIR.replace(' ', r'\040')) + regex = re.compile(r'%s/[^ ]+' % const.TMPDIR.replace(' ', r'\\040')) for mount in regex.findall(mounts): - subprocess.check_call('umount "%s"' % mount.replace(r'\040', ' '), shell=True) + mount = mount.replace(r'\040(deleted)', '').replace(r'\040', ' ') + subprocess.check_call('umount "%s"' % mount, shell=True) print "ZOMG!@~: WE DIED. Cleaning up stuff..." clean_mounts() -- cgit v1.2.3-65-gdbad