From 0c5d67ebb77b0be23aca6593581062a1ef7ce8ca Mon Sep 17 00:00:00 2001
From: Alain Takoudjou <talino@tiolive.com>
Date: Fri, 23 Jan 2015 12:42:18 +0000
Subject: [PATCH] monitor: fix folder exist with apachedex

---
 stack/monitor/buildout.cfg        |  2 +-
 stack/monitor/run-apachedex.py.in | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/stack/monitor/buildout.cfg b/stack/monitor/buildout.cfg
index 004bf10f3..a4b1d8794 100644
--- a/stack/monitor/buildout.cfg
+++ b/stack/monitor/buildout.cfg
@@ -147,7 +147,7 @@ mode = 0644
 recipe = hexagonit.recipe.download
 url = ${:_profile_base_location_}/${:filename}
 download-only = true
-md5sum = 00b230e1dee6e7f25d2050f6f0ae39e2
+md5sum = 54c8a93ab16918392784794dd86d221e
 filename = run-apachedex.py.in
 mode = 0644
 
diff --git a/stack/monitor/run-apachedex.py.in b/stack/monitor/run-apachedex.py.in
index 4f1f443b7..a1906aa2d 100644
--- a/stack/monitor/run-apachedex.py.in
+++ b/stack/monitor/run-apachedex.py.in
@@ -2,7 +2,7 @@
 # BEWARE: This file is operated by slapgrid
 # BEWARE: It will be overwritten automatically
 
-import os
+import os, errno
 import subprocess
 from datetime import date
 
@@ -26,8 +26,14 @@ if not os.path.exists(output_folder) or not os.path.isdir(output_folder):
   exit(1)
 today = date.today().strftime("%Y-%m-%d")
 folder_today = os.path.join(output_folder, 'ApacheDex-%s' % today)
-if not os.path.exists(folder_today):
+
+# XXX- don't raise if folder_today exist
+try:
   os.makedirs(folder_today)
+except OSError as exc:
+  if exc.errno == errno.EEXIST and os.path.isdir(folder_today):
+    pass
+  else: raise
 
 apachedex = "{{ apachedex_executable }}".strip()
 argument_list = [apachedex, '--js-embed', '--out',
-- 
2.30.9