Index: TOOLS/ConsoGENCI/trunk/bin/init_alloc_tbl.py
===================================================================
--- TOOLS/ConsoGENCI/trunk/bin/init_alloc_tbl.py	(revision 2776)
+++ TOOLS/ConsoGENCI/trunk/bin/init_alloc_tbl.py	(revision 2783)
@@ -45,5 +45,5 @@
       "machine": "curie",
       "node": "thin/standard",
-      "alloc": 15000000,
+      "alloc": 10000000,
       "start": "2015-07-01 00:00:00",
       "end": "2015-12-31 23:59:59",
@@ -117,5 +117,6 @@
     db_data.db_host,
     db_data.db_name,
-    db_data.db_user
+    db_data.db_user,
+    db_data.db_pwd,
   )
 
@@ -160,2 +161,4 @@
 
   cdb.close_db(conn)
+
+  exit(0)
Index: TOOLS/ConsoGENCI/trunk/bin/init_conso_tbl.py
===================================================================
--- TOOLS/ConsoGENCI/trunk/bin/init_conso_tbl.py	(revision 2776)
+++ TOOLS/ConsoGENCI/trunk/bin/init_conso_tbl.py	(revision 2783)
@@ -77,5 +77,6 @@
     db_data.db_host,
     db_data.db_name,
-    db_data.db_user
+    db_data.db_user,
+    db_data.db_pwd,
   )
 
@@ -175,2 +176,4 @@
     print("Close connection")
   cdb.close_db(conn)
+
+  exit(0)
Index: TOOLS/ConsoGENCI/trunk/bin/insert_conso_tbl.py
===================================================================
--- TOOLS/ConsoGENCI/trunk/bin/insert_conso_tbl.py	(revision 2776)
+++ TOOLS/ConsoGENCI/trunk/bin/insert_conso_tbl.py	(revision 2783)
@@ -69,5 +69,5 @@
   if not filelist:
     print("No files found, exit")
-    exit(0)
+    exit(1)
 
   if args.verbose:
@@ -83,5 +83,6 @@
     db_data.db_host,
     db_data.db_name,
-    db_data.db_user
+    db_data.db_user,
+    db_data.db_pwd,
   )
 
@@ -211,2 +212,4 @@
     print("Close connection")
   cdb.close_db(conn)
+
+  exit(0)
Index: TOOLS/ConsoGENCI/trunk/bin/libconso.py
===================================================================
--- TOOLS/ConsoGENCI/trunk/bin/libconso.py	(revision 2776)
+++ TOOLS/ConsoGENCI/trunk/bin/libconso.py	(revision 2783)
@@ -38,5 +38,4 @@
   command = [
     "scp",
-    "-v",
     img_out,
     "{}@{}:{}".format(
@@ -67,5 +66,4 @@
   command = [
     "scp",
-    "-v",
     img_png,
     "{}@{}:{}".format(
@@ -104,6 +102,8 @@
   for section in ("projet", "directories"):
     if not config.has_section(section):
-      print("Missing section {} in {}, we stop".format(section, filename))
-      exit(1)
+      print(
+        "Missing section {} in {}, we stop".format(section, filename)
+      )
+      exit(9)
 
   # ...Â Project name ...
@@ -183,11 +183,4 @@
   """
   return dt.datetime.strptime(string, fmt)
-
-
-# ########################################################################
-# def date_to_string(dtdate, fmt="%Y-%m-%d"):
-#   """
-#   """
-#   return dt.datetime.strftime(dtdate, fmt)
 
 
@@ -235,5 +228,5 @@
     for f_in, f_out in zip(file_list, res):
       print("=> {}: {}".format(f_in, f_out))
-    exit(1)
+    exit(9)
 
   return res
@@ -264,6 +257,9 @@
     d["Title"]   = title
     d["Author"]  = os.path.basename(__file__)
-    # d["Subject"] = "Time spent over specific commands during create_ts \
-    #                 jobs at IDRIS and four configurations at TGCC"
+
+    # d["Subject"] = (
+    #   "Time spent over specific commands during create_ts "
+    #   "jobs at IDRIS and four configurations at TGCC"
+    # )
     # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat"
     # d["CreationDate"] = dt.datetime(2009, 11, 13)
Index: TOOLS/ConsoGENCI/trunk/bin/libconso_cpt.py
===================================================================
--- TOOLS/ConsoGENCI/trunk/bin/libconso_cpt.py	(revision 2776)
+++ TOOLS/ConsoGENCI/trunk/bin/libconso_cpt.py	(revision 2783)
@@ -146,5 +146,5 @@
   else:
     print("Unknown center {}".format(center))
-    exit()
+    exit(9)
 
 
Index: TOOLS/ConsoGENCI/trunk/bin/libconso_db.py
===================================================================
--- TOOLS/ConsoGENCI/trunk/bin/libconso_db.py	(revision 2776)
+++ TOOLS/ConsoGENCI/trunk/bin/libconso_db.py	(revision 2783)
@@ -29,8 +29,8 @@
 
 #######################################################################
-def connect_db(db_host, db_name, db_user):
+def connect_db(db_host, db_name, db_user, db_pwd):
 
-  conn_string = "host={} dbname={} user={}".format(
-    db_host, db_name, db_user
+  conn_string = "host={} dbname={} user={} password={}".format(
+    db_host, db_name, db_user, db_pwd
   )
 
@@ -44,5 +44,5 @@
   except Exception as rc:
     print("Problem with DB connect:\n{}".format(rc))
-    exit(1)
+    exit(9)
 
   # conn.cursor will return a cursor object, you can use this cursor
@@ -63,5 +63,5 @@
   except Exception as rc:
     print("Problem with select:\n{}".format(rc))
-    exit(1)
+    exit(9)
 
   # # retrieve the records from the database
@@ -85,5 +85,5 @@
   except Exception as rc:
     print("Problem with insert:\n{}".format(rc))
-    exit(1)
+    exit(9)
 
 
@@ -98,5 +98,5 @@
   except Exception as rc:
     print("Problem with commit:\n{}".format(rc))
-    exit(1)
+    exit(9)
 
 
@@ -110,5 +110,5 @@
   except Exception as rc:
     print("Problem with close:\n{}".format(rc))
-    exit(1)
+    exit(9)
 
 
Index: TOOLS/ConsoGENCI/trunk/bin/plot_bilan.py
===================================================================
--- TOOLS/ConsoGENCI/trunk/bin/plot_bilan.py	(revision 2776)
+++ TOOLS/ConsoGENCI/trunk/bin/plot_bilan.py	(revision 2783)
@@ -116,6 +116,6 @@
     """
     items = (item for item in self.itervalues()
-                   if item.date.date() >= date_beg and
-                      item.date.date() <= date_end)
+                   if item.date >= date_beg and
+                      item.date <= date_end)
     items = sorted(items, key=lambda item: item.date)
 
@@ -228,9 +228,9 @@
   fig, ax_conso, ax_theo,
   xcoord, dates, max_real_use,
-  title, faitle, projet
+  title, faitle, projet, bilan_plot
 ):
   """
   """
-  # from matplotlib.ticker import AutoMinorLocator
+  from matplotlib.ticker import AutoMinorLocator
 
   # ... Config axes ...
@@ -279,5 +279,7 @@
   ax_conso.plot(
     x_list, y_list,
-    color="blue", alpha=line_alpha,
+    linewidth=0.5,
+    color="blue",
+    alpha=line_alpha,
     label=line_label,
   )
@@ -312,9 +314,10 @@
   )
 
-  # minor_locator = AutoMinorLocator()
-  # ax.yaxis.set_minor_locator(minor_locator)
+  minor_locator = AutoMinorLocator()
+  ax_conso.yaxis.set_minor_locator(minor_locator)
+  minor_locator = AutoMinorLocator()
+  ax_theo.yaxis.set_minor_locator(minor_locator)
 
   ax_conso.set_yticks(conso_yticks)
-
   ax_theo.set_yticks(theo_yticks)
 
@@ -324,5 +327,4 @@
 
   for x, d in zip(xcoord, dates):
-    # if d.weekday() == 0 and d.hour == 0:
     if d.weekday() == 0:
       ax_conso.axvline(
@@ -359,5 +361,5 @@
     "Allocation(s):\n" +
     "\n".join([
-      "{:%d/%m/%Y}-{:%d/%m/%Y} : {:8,.0f}h".format(
+      "{:%d/%m/%Y}-{:%d/%m/%Y} : {:10,.0f}h".format(
         item.start_date, item.end_date, item.alloc
       ) for item in projet.alloc_items
@@ -370,7 +372,17 @@
   )
 
+  range_label = "{:%d/%m/%Y} - {:%d/%m/%Y}".format(
+    bilan_plot.date_min,
+    bilan_plot.date_max,
+  )
   plt.figtext(
-    x=0.5, y=0.93, s=faitle,
+    x=0.5, y=0.93, s=range_label,
     ha="center", va="bottom", fontsize="large"
+  )
+
+  faitle_label = "fait le {:%d/%m/%Y}".format(bilan_plot.faitle)
+  plt.figtext(
+    x=0.02, y=0.98, s=faitle_label,
+    ha="left", va="top", fontsize="x-small"
   )
 
@@ -441,5 +453,5 @@
   if not os.path.isfile(config_file):
     print("File {} missing ".format(config_file))
-    exit(1)
+    exit(9)
 
   (DIR, DODS) = parse_config(config_file)
@@ -457,15 +469,11 @@
   )
 
-  # if args.verbose:
-  #   print("Save plot as >{}<".format(img_name))
-
   conn, cursor = cdb.connect_db(
     db_data.db_host,
     db_data.db_name,
-    db_data.db_user
-  )
-
-  # today = os.path.basename(file_param).strip(OUT["PARAM"])
-  # today = dt.date.strftime(dt.date.today(), "%Y%m%d")
+    db_data.db_user,
+    db_data.db_pwd,
+  )
+
   today = dt.date.today()
 
@@ -474,7 +482,4 @@
     print(fmt_str.format("args", args))
     print(fmt_str.format("today", today))
-  #   print(fmt_str.format("file_param", file_param))
-  #   print(fmt_str.format("file_utheo", file_utheo))
-  #   print(fmt_str.format("file_data", file_data))
     print(fmt_str.format("img_name", img_name))
     print("")
@@ -495,14 +500,8 @@
     )
   bilan_plot = PlotData(date_min, date_max)
-
-  # print(bilan_plot.__dict__)
-  # exit()
+  bilan_plot.faitle = today
 
   # .. Get project info ..
   # ======================
-  # projet = Project(project_name)
-  # projet.fill_data(file_param)
-  # projet.get_date_init(file_utheo)
-
   table_name = "conso.tbl_allocation"
   request = (
@@ -517,9 +516,8 @@
   # print(cursor.rowcount)
   # print(cursor.fetchall())
+  # print(cursor.description)
 
   projet = Project(args.project, args.center)
-  # print(cursor.description)
   for row in cursor:
-    # if row["start_date"].year == today.year:
     if (bilan_plot.date_min >= row["start_date"].date() and
         bilan_plot.date_min <= row["end_date"].date()) or \
@@ -587,11 +585,14 @@
 
   theo_uses = []
-  for date in dates:
+  real_uses2 = []
+  for idx, date in enumerate(dates):
     for item in projet.alloc_items:
       if date >= item.start_date.date() and \
          date <= item.end_date.date():
         poly_theo  = item.theo_eq
+        alloc_val = item.alloc
         break
     theo_uses.append(100. * poly_theo(dates.index(date)))
+    real_uses2.append((100 * cumul[idx]) / alloc_val)
   delay_uses = delay * [0., ] + theo_uses[:-delay]
   theo_uses = np.array(theo_uses, dtype=float)
@@ -631,13 +632,4 @@
   # ... Tweak figure ...
   # --------------------
-  # title = "Consommation {}\n({:%d/%m/%Y} - {:%d/%m/%Y})".format(
-  #   projet.project.upper(),
-  #   projet.start_date,
-  #   projet.end_date
-  # )
-  # title = "Consommation {}\n(le {:%d/%m/%Y})".format(
-  #   projet.project.upper(),
-  #   today,
-  # )
   title = "Consommation {})".format(
     projet.project.upper(),
@@ -650,13 +642,19 @@
     fig, ax_conso, ax_theo,
     xcoord, dates, real_uses[dates.index(last_filled_date)],
-    title, faitle, projet
+    title, faitle, projet, bilan_plot
   )
 
   # ... Save figure ...
   # -------------------
-  img_out = os.path.join(
-    DIR["PLOT"], args.center, args.project,
-    "{}_{:%Y%m%d}.pdf".format(img_name, today)
-  )
+  if args.range:
+    img_out = os.path.join(
+      DIR["PLOT"], args.center, args.project,
+      "{}_{:%Y%m%d}_{:%Y%m%d}.pdf".format(img_name, *args.range)
+    )
+  else:
+    img_out = os.path.join(
+      DIR["PLOT"], args.center, args.project,
+      "{}_{:%Y%m%d}.pdf".format(img_name, today)
+    )
   if args.verbose:
     print("Save image as {}".format(img_out))
@@ -674,3 +672,3 @@
   #   plt.show()
 
-  # exit(0)
+  exit(0)
Index: TOOLS/ConsoGENCI/trunk/launch_conso.sh
===================================================================
--- TOOLS/ConsoGENCI/trunk/launch_conso.sh	(revision 2783)
+++ TOOLS/ConsoGENCI/trunk/launch_conso.sh	(revision 2783)
@@ -0,0 +1,87 @@
+#!/bin/bash
+#
+# ==================================================================== #
+# Author: Sonia Labetoulle                                             #
+# Contact: sonia.labetoulle _at_ ipsl.jussieu.fr                       #
+# Created: March 21 2016                                               #
+# History:                                                             #
+# Modification:                                                        #
+# ==================================================================== #
+# Launch everything needed to track the consumption                    #
+# for GENCI projects.                                                  #
+# To be executed by a cron                                             #
+# ======================================================================
+
+# set -vx
+
+whereami=$( hostname -s )
+
+# .. System dependant steps ..
+# ============================
+
+python_exe="python"
+case ${whereami} in
+  pc-236) 
+    echo "maison"
+    python_exe="/opt/epd7/bin/python"
+    ;;
+  curie*)
+    echo "curie"
+    # ... Initialize module command ...
+    # ---------------------------------
+    if [ -f /etc/bashrc ] ; then
+      . /etc/bashrc
+    fi
+    # ... Load python ...
+    # -------------------
+    #Â python/2.7.3 is the default, but it comes with matplotlib 1.2, 
+    # which is too old (no context manager for PdfPages)
+    module load python/2.7.8
+    ;;
+  *)
+    echo "Unknown host ${whereami}, exit"
+    exit 1
+    ;;
+esac
+
+# Go to root directory
+# ====================
+ROOT_DIR=$( dirname $0 )
+cd ${ROOT_DIR}
+BIN_DIR=${ROOT_DIR}/bin
+
+declare -A proj_center=(["gencimp6"]="tgcc" ["rgzi"]="idris")
+
+for projet in "${!proj_center[@]}"
+do
+  centre=${proj_center[${projet}]}
+
+  echo -e "\n* ${projet}/${centre}"
+  echo -e "================================================="
+
+  # .. Insert cpt data into database ..
+  # ===================================
+  echo -e "1) Insert cpt data into table"
+  echo -e "-------------------------------------------------"
+  ${python_exe} ${BIN_DIR}/insert_conso_tbl.py -v ${projet} ${centre}
+  RC=$?
+  if [ ${RC} -gt 1 ] ; then
+    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+    echo "!                                    ! "
+    echo "!   ERROR: script ended abnormally   !"
+    echo "!                                    ! "
+    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+  elif [ ${RC} -ne 0 ] ; then
+    echo -e "\n   => nothing to do for ${projet}/${centre}"
+    continue
+  fi
+
+  echo "test"
+
+  # .. Plot daily consumption ..
+  # ============================
+  echo -e "\n2) Plot daily consumption"
+  echo -e "-------------------------------------------------"
+  ${python_exe} ${BIN_DIR}/plot_bilan.py -vdf ${projet} ${centre}
+done
+
