- Timestamp:
- 03/21/16 15:55:15 (8 years ago)
- Location:
- TOOLS/ConsoGENCI/trunk
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/ConsoGENCI/trunk/bin/init_alloc_tbl.py
r2776 r2783 45 45 "machine": "curie", 46 46 "node": "thin/standard", 47 "alloc": 1 5000000,47 "alloc": 10000000, 48 48 "start": "2015-07-01 00:00:00", 49 49 "end": "2015-12-31 23:59:59", … … 117 117 db_data.db_host, 118 118 db_data.db_name, 119 db_data.db_user 119 db_data.db_user, 120 db_data.db_pwd, 120 121 ) 121 122 … … 160 161 161 162 cdb.close_db(conn) 163 164 exit(0) -
TOOLS/ConsoGENCI/trunk/bin/init_conso_tbl.py
r2776 r2783 77 77 db_data.db_host, 78 78 db_data.db_name, 79 db_data.db_user 79 db_data.db_user, 80 db_data.db_pwd, 80 81 ) 81 82 … … 175 176 print("Close connection") 176 177 cdb.close_db(conn) 178 179 exit(0) -
TOOLS/ConsoGENCI/trunk/bin/insert_conso_tbl.py
r2776 r2783 69 69 if not filelist: 70 70 print("No files found, exit") 71 exit( 0)71 exit(1) 72 72 73 73 if args.verbose: … … 83 83 db_data.db_host, 84 84 db_data.db_name, 85 db_data.db_user 85 db_data.db_user, 86 db_data.db_pwd, 86 87 ) 87 88 … … 211 212 print("Close connection") 212 213 cdb.close_db(conn) 214 215 exit(0) -
TOOLS/ConsoGENCI/trunk/bin/libconso.py
r2776 r2783 38 38 command = [ 39 39 "scp", 40 "-v",41 40 img_out, 42 41 "{}@{}:{}".format( … … 67 66 command = [ 68 67 "scp", 69 "-v",70 68 img_png, 71 69 "{}@{}:{}".format( … … 104 102 for section in ("projet", "directories"): 105 103 if not config.has_section(section): 106 print("Missing section {} in {}, we stop".format(section, filename)) 107 exit(1) 104 print( 105 "Missing section {} in {}, we stop".format(section, filename) 106 ) 107 exit(9) 108 108 109 109 # ... Project name ... … … 183 183 """ 184 184 return dt.datetime.strptime(string, fmt) 185 186 187 # ########################################################################188 # def date_to_string(dtdate, fmt="%Y-%m-%d"):189 # """190 # """191 # return dt.datetime.strftime(dtdate, fmt)192 185 193 186 … … 235 228 for f_in, f_out in zip(file_list, res): 236 229 print("=> {}: {}".format(f_in, f_out)) 237 exit( 1)230 exit(9) 238 231 239 232 return res … … 264 257 d["Title"] = title 265 258 d["Author"] = os.path.basename(__file__) 266 # d["Subject"] = "Time spent over specific commands during create_ts \ 267 # jobs at IDRIS and four configurations at TGCC" 259 260 # d["Subject"] = ( 261 # "Time spent over specific commands during create_ts " 262 # "jobs at IDRIS and four configurations at TGCC" 263 # ) 268 264 # d["Keywords"] = "bench create_ts TGCC IDRIS ncrcat" 269 265 # d["CreationDate"] = dt.datetime(2009, 11, 13) -
TOOLS/ConsoGENCI/trunk/bin/libconso_cpt.py
r2776 r2783 146 146 else: 147 147 print("Unknown center {}".format(center)) 148 exit( )148 exit(9) 149 149 150 150 -
TOOLS/ConsoGENCI/trunk/bin/libconso_db.py
r2775 r2783 29 29 30 30 ####################################################################### 31 def connect_db(db_host, db_name, db_user ):31 def connect_db(db_host, db_name, db_user, db_pwd): 32 32 33 conn_string = "host={} dbname={} user={} ".format(34 db_host, db_name, db_user 33 conn_string = "host={} dbname={} user={} password={}".format( 34 db_host, db_name, db_user, db_pwd 35 35 ) 36 36 … … 44 44 except Exception as rc: 45 45 print("Problem with DB connect:\n{}".format(rc)) 46 exit( 1)46 exit(9) 47 47 48 48 # conn.cursor will return a cursor object, you can use this cursor … … 63 63 except Exception as rc: 64 64 print("Problem with select:\n{}".format(rc)) 65 exit( 1)65 exit(9) 66 66 67 67 # # retrieve the records from the database … … 85 85 except Exception as rc: 86 86 print("Problem with insert:\n{}".format(rc)) 87 exit( 1)87 exit(9) 88 88 89 89 … … 98 98 except Exception as rc: 99 99 print("Problem with commit:\n{}".format(rc)) 100 exit( 1)100 exit(9) 101 101 102 102 … … 110 110 except Exception as rc: 111 111 print("Problem with close:\n{}".format(rc)) 112 exit( 1)112 exit(9) 113 113 114 114 -
TOOLS/ConsoGENCI/trunk/bin/plot_bilan.py
r2776 r2783 116 116 """ 117 117 items = (item for item in self.itervalues() 118 if item.date .date()>= date_beg and119 item.date .date()<= date_end)118 if item.date >= date_beg and 119 item.date <= date_end) 120 120 items = sorted(items, key=lambda item: item.date) 121 121 … … 228 228 fig, ax_conso, ax_theo, 229 229 xcoord, dates, max_real_use, 230 title, faitle, projet 230 title, faitle, projet, bilan_plot 231 231 ): 232 232 """ 233 233 """ 234 #from matplotlib.ticker import AutoMinorLocator234 from matplotlib.ticker import AutoMinorLocator 235 235 236 236 # ... Config axes ... … … 279 279 ax_conso.plot( 280 280 x_list, y_list, 281 color="blue", alpha=line_alpha, 281 linewidth=0.5, 282 color="blue", 283 alpha=line_alpha, 282 284 label=line_label, 283 285 ) … … 312 314 ) 313 315 314 # minor_locator = AutoMinorLocator() 315 # ax.yaxis.set_minor_locator(minor_locator) 316 minor_locator = AutoMinorLocator() 317 ax_conso.yaxis.set_minor_locator(minor_locator) 318 minor_locator = AutoMinorLocator() 319 ax_theo.yaxis.set_minor_locator(minor_locator) 316 320 317 321 ax_conso.set_yticks(conso_yticks) 318 319 322 ax_theo.set_yticks(theo_yticks) 320 323 … … 324 327 325 328 for x, d in zip(xcoord, dates): 326 # if d.weekday() == 0 and d.hour == 0:327 329 if d.weekday() == 0: 328 330 ax_conso.axvline( … … 359 361 "Allocation(s):\n" + 360 362 "\n".join([ 361 "{:%d/%m/%Y}-{:%d/%m/%Y} : {: 8,.0f}h".format(363 "{:%d/%m/%Y}-{:%d/%m/%Y} : {:10,.0f}h".format( 362 364 item.start_date, item.end_date, item.alloc 363 365 ) for item in projet.alloc_items … … 370 372 ) 371 373 374 range_label = "{:%d/%m/%Y} - {:%d/%m/%Y}".format( 375 bilan_plot.date_min, 376 bilan_plot.date_max, 377 ) 372 378 plt.figtext( 373 x=0.5, y=0.93, s= faitle,379 x=0.5, y=0.93, s=range_label, 374 380 ha="center", va="bottom", fontsize="large" 381 ) 382 383 faitle_label = "fait le {:%d/%m/%Y}".format(bilan_plot.faitle) 384 plt.figtext( 385 x=0.02, y=0.98, s=faitle_label, 386 ha="left", va="top", fontsize="x-small" 375 387 ) 376 388 … … 441 453 if not os.path.isfile(config_file): 442 454 print("File {} missing ".format(config_file)) 443 exit( 1)455 exit(9) 444 456 445 457 (DIR, DODS) = parse_config(config_file) … … 457 469 ) 458 470 459 # if args.verbose:460 # print("Save plot as >{}<".format(img_name))461 462 471 conn, cursor = cdb.connect_db( 463 472 db_data.db_host, 464 473 db_data.db_name, 465 db_data.db_user 466 ) 467 468 # today = os.path.basename(file_param).strip(OUT["PARAM"]) 469 # today = dt.date.strftime(dt.date.today(), "%Y%m%d") 474 db_data.db_user, 475 db_data.db_pwd, 476 ) 477 470 478 today = dt.date.today() 471 479 … … 474 482 print(fmt_str.format("args", args)) 475 483 print(fmt_str.format("today", today)) 476 # print(fmt_str.format("file_param", file_param))477 # print(fmt_str.format("file_utheo", file_utheo))478 # print(fmt_str.format("file_data", file_data))479 484 print(fmt_str.format("img_name", img_name)) 480 485 print("") … … 495 500 ) 496 501 bilan_plot = PlotData(date_min, date_max) 497 498 # print(bilan_plot.__dict__) 499 # exit() 502 bilan_plot.faitle = today 500 503 501 504 # .. Get project info .. 502 505 # ====================== 503 # projet = Project(project_name)504 # projet.fill_data(file_param)505 # projet.get_date_init(file_utheo)506 507 506 table_name = "conso.tbl_allocation" 508 507 request = ( … … 517 516 # print(cursor.rowcount) 518 517 # print(cursor.fetchall()) 518 # print(cursor.description) 519 519 520 520 projet = Project(args.project, args.center) 521 # print(cursor.description)522 521 for row in cursor: 523 # if row["start_date"].year == today.year:524 522 if (bilan_plot.date_min >= row["start_date"].date() and 525 523 bilan_plot.date_min <= row["end_date"].date()) or \ … … 587 585 588 586 theo_uses = [] 589 for date in dates: 587 real_uses2 = [] 588 for idx, date in enumerate(dates): 590 589 for item in projet.alloc_items: 591 590 if date >= item.start_date.date() and \ 592 591 date <= item.end_date.date(): 593 592 poly_theo = item.theo_eq 593 alloc_val = item.alloc 594 594 break 595 595 theo_uses.append(100. * poly_theo(dates.index(date))) 596 real_uses2.append((100 * cumul[idx]) / alloc_val) 596 597 delay_uses = delay * [0., ] + theo_uses[:-delay] 597 598 theo_uses = np.array(theo_uses, dtype=float) … … 631 632 # ... Tweak figure ... 632 633 # -------------------- 633 # title = "Consommation {}\n({:%d/%m/%Y} - {:%d/%m/%Y})".format(634 # projet.project.upper(),635 # projet.start_date,636 # projet.end_date637 # )638 # title = "Consommation {}\n(le {:%d/%m/%Y})".format(639 # projet.project.upper(),640 # today,641 # )642 634 title = "Consommation {})".format( 643 635 projet.project.upper(), … … 650 642 fig, ax_conso, ax_theo, 651 643 xcoord, dates, real_uses[dates.index(last_filled_date)], 652 title, faitle, projet 644 title, faitle, projet, bilan_plot 653 645 ) 654 646 655 647 # ... Save figure ... 656 648 # ------------------- 657 img_out = os.path.join( 658 DIR["PLOT"], args.center, args.project, 659 "{}_{:%Y%m%d}.pdf".format(img_name, today) 660 ) 649 if args.range: 650 img_out = os.path.join( 651 DIR["PLOT"], args.center, args.project, 652 "{}_{:%Y%m%d}_{:%Y%m%d}.pdf".format(img_name, *args.range) 653 ) 654 else: 655 img_out = os.path.join( 656 DIR["PLOT"], args.center, args.project, 657 "{}_{:%Y%m%d}.pdf".format(img_name, today) 658 ) 661 659 if args.verbose: 662 660 print("Save image as {}".format(img_out)) … … 674 672 # plt.show() 675 673 676 #exit(0)674 exit(0)
Note: See TracChangeset
for help on using the changeset viewer.