recupdatanetcdf.py 52.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
import xlrd
from netCDF4 import Dataset
import numpy as np
import os
from tkinter import *
from tkinter.filedialog import *
import sys
import getopt
import glob
import re
import math
import shlex
from classe_variable import variable
import usage
from netCDF4 import Dataset
import numpy as np
import pandas as pd
import os
from tkinter import *
from tkinter.filedialog import *
import testexcel as te
import databtlType as dbt
import testbtl as tb
import testPostgres as pf
import traceback
import sys
from tkinter import *
from tkinter import ttk, messagebox
import pandas as pd
import chargementSGDEexcelavecbtl as iF
import seconnecter as ex
def geoliste(g):
    r=[i for i in range(0,len(g)) if not g[i].isdigit()]
    return [int(g[0:r[0]]),int(g[r[0]+1:r[1]]),int(g[r[1]+1:r[2]]),int(g[r[2]+1:])]
def centrefenetre(fen):
    fen.update_idletasks()
    l,h,x,y=geoliste(fen.geometry())
    fen.geometry("%dx%d%+d%+d" % (l,h,(fen.winfo_screenwidth()-l)//2,(fen.winfo_screenheight()-h)//2))

#interface pour la creation d un fichier de chargement
class AccesGraphic(Tk):

    def __init__(self):
        Tk.__init__(self)
        #self.minsize(1200,700)
        self.title('fichier de chargement d un jeu de donnees')
        self.creerWidgets()

##interface pour la mission
    def creerWidgets(self):
        self.mainWindow = Frame(self, bg="blue")
        self.mainWindow.pack(fill=BOTH, expand=1)
        self.frameSaisie = Frame(self.mainWindow, bg="blue")
        self.frameSaisie.pack(fill=BOTH)

        self.frameButtonsauve = Frame(self.frameSaisie, bg="blue")
        #s#elf.frameButtonsauve.pack(side=RIGHT)
        self.btnsauve = Button(self.frameButtonsauve, text="sauvegarder",font=('arial',50,'bold'),bd=4, bg="blue", fg="white", command=self.sauvegarder)
        self.frameResult10 = Frame(self.mainWindow)
        self.frameResult10.pack(fill=BOTH)

        self.frameResult = Frame(self.frameResult10, bd=4, relief=SUNKEN)
        self.frameResult.pack(side=LEFT,fill=X)
        self.ent_label = Label(self.frameResult,font=('arial',50,'bold'),bd=4,bg="blue", fg="white", text="Criteres de Recherche:")
        #self.ent_label.configure(font=('Helvetica', 12),bg="blue", fg="white")
        self.ent_label.pack(side=TOP,padx=5, pady=5)

        self.frameResult00 = Frame(self.frameResult, bd=4, relief=SUNKEN)
        self.frameResult00.pack(fill=BOTH,padx=5, pady=5)
        self.modified_label53321 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "Producteur:")
        #self.modified_label53321.configure(font=('Helvetica', 12))
        #self.modified_label53321.pack(side=LEFT,padx=5, pady=5)
        self.modified5332100=StringVar()
        self.modified_entry53321=ttk.Combobox(self.frameResult00,font=('arial',50,'bold'),textvariable=self.modified5332100,state = 'readonly', background = 'blue')
        #self.modified_entry5['values']=
        #combo.state(['readonly'])
        #combo.grid(row=0,sticky=NW)
        ex.bd.cursor.execute("""select acr_nom_int from intervenant order by acr_nom_int""")
        resultat1=ex.bd.cursor.fetchall()
        ad=[]
        for el in resultat1:
            ad.append(el[0])
        #self.modified5.set(resultat1)
        self.modified_entry53321["values"]=ad
        self.modified_label53321.grid(row =9)
        #self.modified_entry53321.grid(row =9, column=1)
        #self.modified_entry53321.pack(side=LEFT,padx=5, pady=5)
        #self.modified_entry53321.focus()
        #self.frameResult21 = Frame(self.frameResult10, bd=2, relief=SUNKEN)
        #self.frameResult21.pack(side=LEFT,fill=Y)
        self.modified_label51 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "droit d'acces:")
        #self.modified_label51.configure(font=('Helvetica', 12))
        #self.modified_label51.pack(side=LEFT,padx=25, pady=25)
        self.modified_label51.grid(row =1, column =0)

        self.modified51=StringVar()
        self.modified_entry51=ttk.Combobox(self.frameResult00,font=('arial',50,'bold'),textvariable=self.modified51,state = 'readonly', background = 'blue')
        ex.bd.cursor.execute("select nom from groupe order by nom")
        resultat1=ex.bd.cursor.fetchall()

        #self.modified5.set(resultat1)
        self.modified_entry51["values"]=resultat1
        self.modified_entry51.grid(row =1,column =1)

        self.modified_label5 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "type de jeu de donnees:")
        #self.modified_label5.configure(font=('Helvetica', 12))
        self.modified_label5.grid(row =2, column =0)

        #self.modified_label5.pack(side=LEFT,padx=25, pady=25)
        self.modified5=StringVar()
        self.modified_entry5=ttk.Combobox(self.frameResult00,font=('arial',50,'bold'),textvariable=self.modified5,state = 'readonly', background = 'blue')
        #self.modified_entry5['values']=
        #combo.state(['readonly'])
        #combo.grid(row=0,sticky=NW)
        ex.bd.cursor.execute("select typ_jd from typ_jd order by typ_jd")
        resultat1=ex.bd.cursor.fetchall()
        #self.modified5.set(resultat1)
        self.modified_entry5["values"]=resultat1
        #self.modified_entry5.pack(side=LEFT)
        #self.modified_entry5.focus()
        self.modified_entry5.grid(row =2, column =1)
        self.modified_label = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "Statu:")
        #self.modified_label.configure(font=('Helvetica', 12))
        #self.modified_label.grid(row =1, column =2)
        #self.modified_label.pack(side=LEFT,padx=25, pady=25,anchor=CENTER)
        self.nom=StringVar()
        self.modified_entry = Entry(self.frameResult00,font=('arial',50,'bold'),bd=4,textvariable=self.nom)

        self.modified_label533 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "choisissez le doc joint:")
        #self.modified_label533.configure(font=('Helvetica', 12))
        #self.modified_label533.pack()
        self.modified533=StringVar()
        self.modified_entry533=Entry(self.frameResult00,font=('arial',50,'bold'),bd=4,textvariable=self.modified533)
        #self.modified_entry5['values']=
        #combo.state(['readonly'])
        #combo.grid(row=0,sticky=NW)
        #ex.bd.cursor.execute("select ACR_PRJ from PROJ_PROG order by ACR_PRJ")
        #resultat1=ex.bd.cursor.fetchall()
        #self.modified5.set(resultat1)
        #self.modified_entry533["values"]=resultat1
        #self.modified_entry533.pack()
        #self.modified_entry533.focus()

        self.modified_entry533.grid(row =3, column =1)
        #
        self.btndoc = Button(self.frameResult00, text="Document joint",font=('arial',50,'bold'),command=self.recupJD_LIE_JD)
        self.btndoc.grid(row =3, column =0)

        #self.modified_entry533.grid(row =3, column =1)

        self.modified_label5333 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "station fixe:")
        #self.modified_label5333.configure(font=('Helvetica', 12))
        #self.modified_label5333.pack()
        self.modified5333=StringVar()
        self.modified_entry5333=ttk.Combobox(self.frameResult00,font=('arial',50,'bold'),textvariable=self.modified5333,state = 'readonly', background = 'blue')
        #self.modified_entry5['values']=
        #combo.state(['readonly'])
        #combo.grid(row=0,sticky=NW)
        ex.bd.cursor.execute("select ACR_STA_FIX from STA_TRANS_FIX order by ACR_STA_FIX")
        resultat1=ex.bd.cursor.fetchall()
        #self.modified5.set(resultat1)
        self.modified_entry5333["values"]=resultat1
        #self.modified_entry533.pack()
        #self.modified_entry533.focus()

        self.modified_label5333.grid(row =4, column =0)
        self.modified_entry5333.grid(row =4, column =1)




        #self.frameLogin = Frame(self.frameSaisie, bg="blue")
        #self.frameLogin.pack(side=RIGHT)
        self.login = StringVar()
        self.loginEntry = Entry(self.frameResult00, textvariable=self.login, width=50)
        #self.loginEntry.pack(padx=5, pady=5)
        #self.loginEntry.focus()
        #self.frameText = Frame(self.frameSaisie, bg="blue")
        #self.frameText.pack(side=RIGHT)
        self.label = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text="Description")
        #self.label.pack(padx=5, pady=5)
        self.label.grid(row =5, column =0)
        self.loginEntry.grid(row =5, column =1)

        self.login1 = StringVar()
        self.loginEntry1 = Entry(self.frameResult00, textvariable=self.login1, width=10)

        self.modified_label5330 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "Fuseau:")
        #self.modified_label533.configure(font=('Helvetica', 12))
        #self.modified_label5330.pack()
        self.modified5330=StringVar()
        self.modified_entry5330=ttk.Combobox(self.frameResult00,font=('arial',50,'bold'),textvariable=self.modified5330,state = 'readonly', background = 'blue')
        #self.modified_entry5['values']=
        #combo.state(['readonly'])
        #combo.grid(row=0,sticky=NW)
        ex.bd.cursor.execute("select distinct fus_hor_jd from JEU_DONNEES order by fus_hor_jd")
        resultat1=ex.bd.cursor.fetchall()
        #self.modified5.set(resultat1)
        self.modified_entry5330["values"]=resultat1
        #self.modified_entry5330.pack()
        #self.modified_entry5330.focus()
        self.modified_entry5330.grid(row =6, column =1)
        self.modified_label5330.grid(row =6, column =0)

        self.modified_label53301 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "TYP_EVEN_JD:")
        #self.modified_label533.configure(font=('Helvetica', 12))
        #self.modified_label5330.pack()
        self.modified53301=StringVar()
        self.modified_entry53301=ttk.Combobox(self.frameResult00,font=('arial',50,'bold'),textvariable=self.modified53301,state = 'readonly', background = 'blue')
        #self.modified_entry5['values']=
        #combo.state(['readonly'])
        #combo.grid(row=0,sticky=NW)
        ex.bd.cursor.execute("select distinct fus_hor_jd from JEU_DONNEES order by fus_hor_jd")
        resultat1=ex.bd.cursor.fetchall()
        #self.modified5.set(resultat1)
        self.modified_entry53301["values"]=['LEVE ','EXPERIMENTAL ']
        #self.modified_entry5330.pack()
        #self.modified_entry5330.focus()
        self.modified_entry53301.grid(row =7, column =1)
        self.modified_label53301.grid(row =7, column =0)



        self.modified_label533011 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "FORM_FICH_JD:")
        #self.modified_label533.configure(font=('Helvetica', 12))
        #self.modified_label5330.pack()
        self.modified533011=StringVar()
        self.modified_entry533011=ttk.Combobox(self.frameResult00,font=('arial',50,'bold'),textvariable=self.modified533011,state = 'readonly', background = 'blue')
        #self.modified_entry5['values']=
        #combo.state(['readonly'])
        #combo.grid(row=0,sticky=NW)
        ex.bd.cursor.execute("select distinct fus_hor_jd from JEU_DONNEES order by fus_hor_jd")
        resultat1=ex.bd.cursor.fetchall()
        #self.modified5.set(resultat1)
        self.modified_entry533011["values"]= ['ASCII','EXCEL', 'WORD', 'BINAIRE','NETCDF']
        #self.modified_entry5330.pack()
        #self.modified_entry5330.focus()
        self.modified_entry533011.grid(row =8, column =1)
        self.modified_label533011.grid(row =8, column =0)

        #self.loginEntry.pack(padx=5, pady=5)
        #self.loginEntry.focus()
        #self.frameText = Frame(self.frameSaisie, bg="blue")
        #self.frameText.pack(side=RIGHT)
        #self.label1 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text="seq_jd")
        #self.label.pack(padx=5, pady=5)
        #self.label1.grid(row =6, column =0)
        #self.loginEntry1.grid(row =6, column =1)
        self.modified_label533212 = Label(self.frameResult00,font=('arial',50,'bold'),bd=4, text = "acr mission dans le fichier netcdf")
        self.modified_label53321200 = Label(self.frameResult00,font=('arial',50,'bold'),bd=0, text = "Producteur correspondant dans la base:")

        #self.modified_label53321.configure(font=('Helvetica', 12))
        #self.modified_label53321.pack(side=LEFT,padx=5, pady=5)
        self.modified53321002=StringVar()
        self.modified_entry533212=ttk.Combobox(self.frameResult00,font=('arial',50,'bold'),textvariable=self.modified53321002,state = 'readonly', background = 'blue')
        #self.modified_entry5['values']=
        #combo.state(['readonly'])
        #combo.grid(row=0,sticky=NW)
        ex.bd.cursor.execute("""select acr_miss from mission_exp order by acr_miss""")
        resultat1=ex.bd.cursor.fetchall()
        ad=[]
        for el in resultat1:
            ad.append(el[0])
        #self.modified5.set(resultat1)
        self.modified_entry533212["values"]=ad
        self.modified_label533212.grid(row =0)
        self.modified_label53321200.grid(row =0,column=1)
        #self.modified_entry533212.grid(row =0, column=1)

        self.btnan = Button(self.frameResult00,font=('arial',50,'bold'),bd=4, text="creer matsge", bg="blue", fg="white", command=self.resultatmission21)
        self.btnan.grid(row=1,column=2)
        #self.frameButtonnew = Frame(self.frameSaisie, bg="blue")
        #self.frameButtonnew.grid()
        self.btntablenew = Button(self.frameResult00, text="initialiser",font=('arial',50,'bold'),bd=4, bg="blue", fg="white",command=self.nouveauD)
        #self.btntablenew.grid(row=2,column=2)

        #self.frameButtontable1 = Frame(self.frameSaisie, bg="blue")
        #self.frameButtontable1.pack(side=LEFT)
        self.btnacceuille = Button(self.frameResult00, text="Acceuil",font=('arial',50,'bold'),bd=4, bg="red", fg="white",command=self.acceuil)
        self.btnacceuille.grid(row=3,column=2)

        self.frameResult2 = Frame(self.frameResult10, bd=4, relief=SUNKEN)
        self.frameResult2.pack(side=LEFT,fill=BOTH)
        self.modified53323=StringVar()
        self.modified_entry53323=Entry(self.frameResult00,font=('arial',50,'bold'),bd=4,textvariable=self.modified53323)
        #self.modified_entry5['values']=
        #combo.state(['readonly'])
        #combo.grid(row=0,sticky=NW)
        #ex.bd.cursor.execute("select ACR_PRJ from PROJ_PROG order by ACR_PRJ")
        #resultat1=ex.bd.cursor.fetchall()
        #self.modified5.set(resultat1)
        #self.modified_entry533["values"]=resultat1
        #self.modified_entry533.pack()
        #self.modified_entry533.focus()

        self.modified_entry53323.grid(row =10, column =1)
        #
        self.btndoc1 = Button(self.frameResult00, text="Rep des fichiers",font=('arial',50,'bold'),command=self.recupJD_Rep)
        self.btndoc1.grid(row =10, column =0)



        self.exit_button = Button(self.mainWindow,font=('arial',50,'bold'),bd=4,bg="red",fg="black", text = "Exit", command = self.mainWindow.quit)
        self.exit_button.pack()
        #self.update_layout()



    def acceuil(self):
        #prob = self.loginEntry.get().strip().split(' ')
        try:
            self.destroy()
            self.groupe= iF.InterfaceGraphic()
            #self.groupe.mainloop()
            #print("bonjour")

        except Exception as err:
            print("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\
                    % (err))
            messagebox.showerror("Erreur de saisie", "impossible de lancer cette interface.")
    def nouveauD(self):
        #self.dose.set("")
        self.modified51.set("")
        self.login.set("")
        self.modified5332100.set("")
        self.modified5.set("")
        self.modified533.set("")
        self.modified5333.set("")
    def particularites(self):
        #prob = self.loginEntry.get().strip().split(' ')
        try:
            #self.inter = gI.IntervenantGraphic()
            #self.inter.mainloop()
            self.destroy()
            self.inter = JeuDeDonneesGraphicbis()
            #self.inter.mainloop()
        except Exception as err:
            print("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\
                    % (err))
            messagebox.showerror("Erreur de saisie", "impossible de lancer cette interface.")

    def localisation(self):
        #prob = self.loginEntry.get().strip().split(' ')
        try:
            #self.inter = gI.IntervenantGraphic()
            #self.inter.mainloop()
            self.destroy()
            self.inter = JeuDeDonneesGraphic()
            #self.inter.mainloop()
        except Exception as err:
            print("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\
                    % (err))
            messagebox.showerror("Erreur de saisie", "impossible de lancer cette interface.")

    def selectionner(self):
        return str(self.v.get())
    #double clique de bouton sur Scrollbar
    def on_configure(self, event):
        w,h = event.x, event.y
        #natural = self.frameResult1.winfo_reqwidth()
        #print(self.tree.identify_element(w,h))
        seltxt = self.tree.set(self.tree.selection(), 'nom_fich_jd')
        if ex.bd.echec:
            raise ValueError("Erreur : connection echoue")
            #prob = [float(i) for i in prob if i!='' and i!='0']
        ex.bd.cursor.execute("""select seq_jd,drt_acce_jd,nom_fich_jd,desc_jd,acr_miss,statut_jd,typ_jd,lat_1_jd,lngt_1_jd,dat_min_jd,dat_max_jd,fus_hor_jd,lat_2_jd,lngt_2_jd,profd_min_jd,profd_max_jd from JEU_DONNEES where nom_fich_jd= '%s'"""%seltxt)
        resultat=ex.bd.cursor.fetchone()

        #self.dose.set(resultat[0])
        self.modified51.set(resultat[1])
        self.login.set(resultat[2])
    #    self.modified4.set(resultat[3])

        self.modified5332100.set(resultat[4])

    #    self.nom.set(resultat[5])
        self.modified5.set(resultat[6])

    #    self.modified122.set(resultat[7])
    #    self.modified1221.set(resultat[8])

    #    self.modified1.set(resultat[9])
    #    self.modified11.set(resultat[10])
        self.modified533.set(resultat[11])
        self.modified5333.set(resultat[0])
    #    self.modified12210.set(resultat[12])
    #    self.modified12211.set(resultat[13])
    #    self.modified122121.set(resultat[14])
    #    self.modified1221121.set(resultat[15])
    #    self.modified_entry441.delete(0,END)
    #    self.modified_entry44100.delete(0,END)
    #    self.modified_entry441000.delete(0,END)



        #self.modified444.set(resultat1[0])
    #ajout de projet dans l espace
    def ajoutnew(self, event):
        w,h = event.x, event.y
        #natural = self.frameResult1.winfo_reqwidth()
        #print(self.tree.identify_element(w,h))
        seltxt =self.modified_entry44.get(self.modified_entry44.curselection())
        if ex.bd.echec:
            raise ValueError("Erreur : connection echoue")
            #prob = [float(i) for i in prob if i!='' and i!='0']
        ex.bd.cursor.execute("""select acr_miss from mission_exp where acr_miss= '%s'"""%seltxt)
        resultat=ex.bd.cursor.fetchone()
        self.modified444.set(resultat[0])
    def ajoutnew1(self, event):
        w,h = event.x, event.y
        #natural = self.frameResult1.winfo_reqwidth()
        #print(self.tree.identify_element(w,h))
        seltxt =self.modified_entry441.get(self.modified_entry441.curselection())
        if ex.bd.echec:
            raise ValueError("Erreur : connection echoue")
            #prob = [float(i) for i in prob if i!='' and i!='0']
        ex.bd.cursor.execute("""select acr_miss from mission_exp where acr_miss= '%s'"""%seltxt)
        resultat=ex.bd.cursor.fetchone()
        self.modified444.set(resultat[0])
        #self.tree.itemconfigure('inner', width= w if w>natural else natural)
        #self.tree.configure(scrollregion=self.tree.bbox('.'))
    #sauvegarder une nouvelle mission
    def recupDonnees(self):
        liste=[]
        liste=(self.dose.get(),self.modified51.get(),self.modified1221121.get(),self.modified122121.get())
        return self.login.get()
    def sauvegarder(self):
        dat_deb=pd.to_datetime(self.modified1.get(),errors="coerce")
        dat_fin=pd.to_datetime(self.modified11.get(),errors="coerce")
        #if self.dose.get()=="":
        #    messagebox.showerror("Erreur de requête", "le champs seq int doit contenir une valeur.")
        #    return
        if self.nom.get()=="":
            messagebox.showerror("Erreur de requête", "le champs nom projet doit contenir une valeur.")
            return
        elif str(dat_deb)=="NaT" or str(dat_fin)=="NaT":
            messagebox.showerror("Erreur de requête", "le champs date_deb ou date fin format invalide.")
            return
        elif dat_deb > dat_fin:
            messagebox.showerror("Erreur de requête", "le champs date_deb est apres date fin.")
            return
        elif self.modified11.get()=="":
            messagebox.showerror("Erreur de requête", "le champs date_fin doit contenir une valeur.")
            return
        elif self.modified4.get()=="":
            messagebox.showerror("Erreur de requête", "le champs desc_proj doit contenir une valeur.")
            return
        elif self.modified5.get()=="":
            messagebox.showerror("Erreur de requête", "le champs acr nom int  doit etre choisi.")
            return
        elif self.login.get()=="":
            messagebox.showerror("Erreur de requête", "le champs acronyme projet doit contenir une valeur.")
            return
        elif self.v.get()=="":
            messagebox.showerror("Erreur de requête", "choisissez un type .")
            return
        else:
            ex.bd.cursor.execute("""select acr_prj from proj_prog where acr_prj= '%s'"""%self.login.get())
            resultat=ex.bd.cursor.fetchone()
            if resultat != None:
                messagebox.showerror("Erreur de requête","Existe deja dans la base de données '%s'"""%self.login.get())
                return
            else:
        #base="""INSERT INTO mission_exp (nom,courriel,organisation,coor_int) VALUES (sql)"""
                #namedict = {"acronyme":self.login.get(),"nom":self.nom.get(),"cour":self.modified1.get(),"orga":self.modified3.get(),"coord":self.modified2.get()}
                #print(namedict["orga"])
                base="""INSERT INTO PROJ_PROG(ACR_PRJ,NOM_PRJ,DAT_DEB_PRJ,DAT_FIN_PRJ,ACR_NOM_INT,TYP_PRJ,DESC_PRJ,SOUR_FINA_PRJ) VALUES(%s, %s, %s, %s, %s, %s, %s, %s)"""
                #sql=(self.login.get(),self.nom.get(),dat_deb,dat_fin,self.modified2.get(),int(self.v.get()),self.modified4.get(),self.modified3.get())
                try:
                    ex.bd.cursor.execute(base,(self.login.get(),self.nom.get(),dat_deb,dat_fin,self.modified5.get(),int(self.v.get()),self.modified4.get(),self.modified3.get()))
                    messagebox.showinfo("Information","Insertion d'un nouveau projet.")
                    ex.bd.commit()
                    self.resultatmission()
                except Exception as err:

            # afficher la requête et le message d'erreur système :

                    print ("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\

                            % (base, err))
                    messagebox.showerror("Erreur de saisie", "La requête n est pas correcte.")
                    ex.bd.rollback()
        #self.tree.itemconfigure('inner', width= w if w>natural else natural)
        #self.tree.configure(scrollregion=self.tree.bbox('.'))
    #modier une mission
    def modifier(self):
        #natural = self.frameResult1.winfo_reqwidth()
        #print(self.tree.identify_element(w,h))
        #sql.append((str(self.nom.get()).encode("utf8"),str(self.modified1.get()).encode("utf8"),str(self.modified3.get()).encode("utf8"),str(self.modified2.get()).encode("utf8")))
        dat_deb=pd.to_datetime(self.modified1.get(),errors="coerce")
        dat_fin=pd.to_datetime(self.modified11.get(),errors="coerce")
        #if self.dose.get()=="":
        #    messagebox.showerror("Erreur de requête", "le champs seq int doit contenir une valeur.")
        #    return
        if self.nom.get()=="":
            messagebox.showerror("Erreur de requête", "le champs nom projet doit contenir une valeur.")
            return
        elif str(dat_deb)=="NaT" or str(dat_fin)=="NaT":
            messagebox.showerror("Erreur de requête", "le champs date_deb ou date fin format invalide.")
            return
        elif dat_deb > dat_fin:
            messagebox.showerror("Erreur de requête", "le champs date_deb est apres date fin.")
            return
        elif self.modified11.get()=="":
            messagebox.showerror("Erreur de requête", "le champs date_fin doit contenir une valeur.")
            return
        elif self.modified4.get()=="":
            messagebox.showerror("Erreur de requête", "le champs desc_proj doit contenir une valeur.")
            return
        elif self.modified5.get()=="":
            messagebox.showerror("Erreur de requête", "le champs acr nom int  doit etre choisi.")
            return
        elif self.login.get()=="":
            messagebox.showerror("Erreur de requête", "le champs acronyme projet doit contenir une valeur.")
            return
        elif self.v.get()=="":
            messagebox.showerror("Erreur de requête", "choisissez un type .")
            return
        else:

            base="UPDATE PROJ_PROG SET ACR_PRJ=%s, NOM_PRJ=%s, DAT_DEB_PRJ=%s ,DAT_FIN_PRJ=%s, ACR_NOM_INT=%s, TYP_PRJ=%s, DESC_PRJ=%s, SOUR_FINA_PRJ=%s where acr_prj=%s"
                #sql=(self.login.get(),self.nom.get(),dat_deb,dat_fin,self.modified2.get(),int(self.v.get()),self.modified4.get(),self.modified3.get())
            try:
                ex.bd.cursor.execute(base,(self.login.get(),self.nom.get(),dat_deb,dat_fin,self.modified5.get(),int(self.v.get()),self.modified4.get(),self.modified3.get(),self.login.get()))
                messagebox.showinfo("Information","Modification de projet reussi.")
                ex.bd.commit()

                self.resultatmission()
            except Exception as err:

            # afficher la requête et le message d'erreur système :

                print ("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\

                        % (base, err))
                messagebox.showerror("Erreur de saisie", "La requête n est pas correcte.")
                ex.bd.rollback()
        #self.tree.itemconfigure('inner', width= w if w>natural else natural)
        #self.tree.configure(scrollregion=self.tree.bbox('.'))
#nouvequ projet dans la base
    def ajouterProjet(self):
        #prob = self.loginEntry.get().strip().split(' ')
        if self.modified444.get()=="":
            messagebox.showerror("Erreur de requête", "le champs nom projet doit contenir une valeur.")
            return
        else:
            ex.bd.cursor.execute("""select acr_prj from proj_prog where acr_prj= '%s'"""%self.modified444.get())
            resultat=ex.bd.cursor.fetchone()
            if resultat != None:
                messagebox.showerror("Erreur de requête","Existe deja dans la base de données '%s'"""%self.modified444.get())
                return
            else:
        #base="""INSERT INTO mission_exp (nom,courriel,organisation,coor_int) VALUES (sql)"""
                #namedict = {"acronyme":self.login.get(),"nom":self.nom.get(),"cour":self.modified1.get(),"orga":self.modified3.get(),"coord":self.modified2.get()}
                #print(namedict["orga"])
                base="""INSERT INTO mission_exp(acr_miss,nom_miss,dat_deb_miss,dat_fin_miss,typ_miss,nom_nav_miss,idt_nav_miss,desc_miss,acr_nom_int) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)"""
                sql=(self.login.get(),self.nom.get(),dat_deb,dat_fin,int(self.v.get()),self.modified2.get(),self.modified3.get(),self.modified4.get(),self.modified5.get())
                #print(sql)
                #base="INSERT INTO intervenant(seq_int,acr_nom_int,nom,courriel,organisation,coor_int) VALUES(%s,%s, %s, %s, %s, %s)"
                #ex.bd.cursor.execute("""select max(seq_int) from intervenant """)
                #seq=ex.bd.cursor.fetchone()
                #print(seq)
                try:
                    #if ex.bd.echec:
        #    raise ValueError("Erreur : connection echoue")
            #prob = [float(i) for i in prob if i!='' and i!='0']
                    #ex.bd.cursor.execute(base,(self.login.get(),self.nom.get(),self.modified1.get(),self.modified3.get(),self.modified2.get()))
                    #resultat=ex.bd.cursor.fetchone()
                    #print(base)
                    messagebox.showinfo("Information","Insertion d'une nouvelle mission.")
                    #ex.bd.commit()
                except Exception as err:

            # afficher la requête et le message d'erreur système :

                    print ("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\

                            % (base, err))
                    messagebox.showerror("Erreur de saisie", "La requête n est pas correcte.")
                    ex.bd.rollback()

    def supprimer(self):
        #prob = self.loginEntry.get().strip().split(' ')
        #prob = self.loginEntry.get()
        if ex.bd.echec:
            raise ValueError("Erreur : connection echoue")
        try:
            #prob = [float(i) for i in prob if i!='' and i!='0']
            tables={"pp_gen_me":"acr_prj"}
            for i,j in tables.items():
                ex.bd.cursor.execute("SELECT count(*) from "+i+" where "+j+"='"+(self.login.get())+"' ")
                seq=ex.bd.cursor.fetchone()
                if seq[0] > 0 :
                    messagebox.showerror("requete","Le projet "+(self.login.get())+" ne peut pas etre supprimé car il apparait deja dans la table "+i+".")
                    return
            ex.bd.cursor.execute("DELETE from proj_prog where acr_prj='"+(self.login.get())+"' ")
            messagebox.showinfo("requete", "suppression faite avec succes.")
            ex.bd.commit()
            self.resultatmission()
        except Exception as err:
            print ("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\
                    % (err))
            messagebox.showerror("Erreur de requete", "ces donnees ont associes  a d'autres tables.")
            return
            ex.bd.rollback()
    def resultatrequete(self):
        #prob = self.loginEntry.get().strip().split(' ')
        prob = self.loginEntry.get()
        if ex.bd.echec:
            raise ValueError("Erreur : connection echoue")
        try:
            #prob = [float(i) for i in prob if i!='' and i!='0']
            ex.bd.cursor.execute(prob)
            resultat=ex.bd.cursor.fetchall()
            self.frameHL.pack(fill=BOTH, padx=15, pady=5)
            self.tree.delete(END, 'end',tags = ('oddrow',))
            for el in resultat:
                self.tree.insert('', END, values=(el), tags = ('oddrow',))

            #self.treeHL.heading('H(X)', text='H(X) = '+str(resultat), anchor=CENTER)
            #self.treeHL.heading('L', text='L = '+str(result[2]), anchor=CENTER)
            #self.treeHL.heading('u', text='Efficacité(µ) = '+str(result[3]), anchor=CENTER)
            self.treeHL.grid(in_=self.frameHL, row=0, column=0, sticky=NSEW)
            self.frameHL.rowconfigure(0, weight=1)
            self.frameHL.columnconfigure(0, weight=1)
        except:
            messagebox.showerror("Erreur de saisie", "La requête n est pas correcte. saisie")
    def listedeProjet(self):
        #prob = self.loginEntry.get().strip().split(' ')
        if self.modified444.get()=="":
            messagebox.showerror("Erreur de requête", "le champs acr mission doit contenir une valeur.")
            return
        elif self.login.get()=="":
            messagebox.showerror("Erreur de requête", "le champs acr projet doit contenir une valeur.")
            return
        else:
            print()
            ex.bd.cursor.execute("""select acr_miss from mission_exp where acr_miss='%s'"""%self.modified444.get())
            resultat=ex.bd.cursor.fetchone()
            if resultat == None:
                messagebox.showerror("Erreur de requête","la mission n'existe pas '%s'"""%self.modified444.get())
                return
            else:

                ex.bd.cursor.execute("""select acr_prj from proj_prog where acr_prj= '%s'"""%self.login.get())
                resultat=ex.bd.cursor.fetchone()
                if resultat == None:
                    messagebox.showerror("Erreur de requête","le projet n'existe pas '%s'"""%self.login.get())
                    return
                else:
                    ex.bd.cursor.execute("""select acr_prj from pp_gen_me where acr_prj= '%s' and acr_miss= '%s'"""%(self.login.get(),self.login.get()))
                    resultat=ex.bd.cursor.fetchone()
                    if resultat != None:
                        messagebox.showerror("Erreur de requête","existe deja dans la ('%s')"""%self.login.get())
                        return
                    else:
        #base="""INSERT INTO mission_exp (nom,courriel,organisation,coor_int) VALUES (sql)"""
                #namedict = {"acronyme":self.login.get(),"nom":self.nom.get(),"cour":self.modified1.get(),"orga":self.modified3.get(),"coord":self.modified2.get()}
                #print(namedict["orga"])
                        base="""INSERT INTO pp_gen_me(acr_miss,acr_prj) VALUES(%s,%s)"""
                        sql=(self.modified444.get(),self.login.get())
                #base="INSERT INTO intervenant(seq_int,acr_nom_int,nom,courriel,organisation,coor_int) VALUES(%s,%s, %s, %s, %s, %s)"
                #ex.bd.cursor.execute("""select max(seq_int) from intervenant """)
                #seq=ex.bd.cursor.fetchone()
                #print(seq)
                        try:
                    #if ex.bd.echec:
        #    raise ValueError("Erreur : connection echoue")
            #prob = [float(i) for i in prob if i!='' and i!='0']
                            ex.bd.cursor.execute(base,(self.modified444.get(),self.login.get()))
                    #resultat=ex.bd.cursor.fetchone()
                    #print(base)
                            messagebox.showinfo("Information","Insertion d'un projet acr_miss-acr_prj.")

                            self.modified_entry441.delete(0,END)
                                #prob = [float(i) for i in prob if i!='' and i!='0']
                            ex.bd.cursor.execute("""select acr_miss from pp_gen_me where acr_prj= '%s'"""%self.login.get())
                            resultat1=ex.bd.cursor.fetchall()
                            for el in resultat1:
                                self.modified_entry441.insert(END,el[0])
                        # afficher la requête et le message d'erreur système :
                            ex.bd.commit()
                        except Exception as err:

            # afficher la requête et le message d'erreur système :

                            print ("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\

                                    % (base, err))
                            messagebox.showerror("Erreur de saisie", "La requête n est pas correcte.")
                            ex.bd.rollback()

    def listedeProjet1(self):
        #prob = self.loginEntry.get().strip().split(' ')
        if self.modified444.get()=="":
            messagebox.showerror("Erreur de requête", "le champs acr mission doit contenir une valeur.")
            return
        elif self.login.get()=="":
            messagebox.showerror("Erreur de requête", "le champs acr projet doit contenir une valeur.")
            return
        else:

            try:
                ex.bd.cursor.execute("DELETE from pp_gen_me where acr_prj='"+(self.login.get())+"' and acr_miss='"+self.modified444.get()+"' ")
                messagebox.showinfo("requete", "suppression faite avec succes.")
                    #resultat=ex.bd.cursor.fetchone()
                    #print(base)
                self.modified_entry441.delete(0,END)
                                #prob = [float(i) for i in prob if i!='' and i!='0']
                ex.bd.cursor.execute("""select acr_miss from pp_gen_me where acr_prj= '%s'"""%self.login.get())
                resultat1=ex.bd.cursor.fetchall()
                for el in resultat1:
                    self.modified_entry441.insert(END,el[0])
                        # afficher la requête et le message d'erreur système :
                ex.bd.commit()
            except Exception as err:

            # afficher la requête et le message d'erreur système :

                print ("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\
                        % (base, err))
                messagebox.showerror("Erreur de saisie", "La requête n est pas correcte.")
                ex.bd.rollback()

    """liste de tou les missions"""
    def resultatmission(self):
        #prob = self.loginEntry.get().strip().split(' ')
        a=[]
        self.tree.delete(*self.tree.get_children())
        prob = self.loginEntry.get()
        if ex.bd.echec:
            raise ValueError("Erreur : connection echoue")
        try:
            #prob = [float(i) for i in prob if i!='' and i!='0']
            k=0
            sql1="select nom_fich_jd,acr_miss,acr_nom_int_prod  from JEU_DONNEES "
            sql="select nom_fich_jd,acr_miss,acr_nom_int_prod  from JEU_DONNEES where "
            if self.modified5332100.get()!="":
                sql=sql+"acr_miss='%s' and" %self.modified5332100.get()
                k=1
            if self.modified51.get()!="":
                sql=sql+"  acr_nom_int_prod='%s' and "%self.modified51.get()
                k=1
            if self.modified5.get()!="":
                sql=sql+" typ_jd='%s' and"%self.modified5.get()
                k=1
            if self.modified533.get()!="":
                sql=sql+"  ACR_MISS in (select ACR_MISS from PP_GEN_ME where ACR_PRJ ='%s') and"%self.modified533.get()
                k=1
            #print(self.modified5332100.get(),self.modified51.get(),self.modified5.get(),self.modified533.get(),self.modified5333.get())
            #if self.modified5333.get()!="":
            #    sql=sql+"  ACR_MISS in (select ACR_MISS from PP_GEN_ME where ACR_PRJ ='%s')"%self.modified533.get()
            if self.login.get()!="":
                sql=sql+"  nom_fich_jd='%s' and"%self.login.get()
                k=1
            if self.login1.get()!="":
                sql=sql+" seq_jd='%d' and"%int(self.login1.get())
                k=1
            if k==0:
                sql=sql1
            else:
                sql=sql+" 1=1"
            ex.bd.cursor.execute(sql)
            resultat=ex.bd.cursor.fetchall()
            if resultat==[]:
                messagebox.showinfo("Resultat", "La requête na donnée aucun resultat.")
                return
            #self.frameHL.pack(fill=BOTH, padx=15, pady=5)
            for el in resultat:
                #self.tree.delete(el[0], END)
                self.tree.insert('', END, values=(el[0],el[1],el[2]), tags = ('oddrow',))
                #self.tree.delete('', END, values=(el[0],el[1],el[2],el[3],el[4],el[5]))
                #selected_item = self.tree.selection()[1] ## get selected item
                #print(selected_item)
                #self.tree.delete(selected_item)
                #self.tree.delete('',END,values=(el[0],el[1],el[2],el[3],el[4],el[5]), tags = ('oddrow',))
                #self.tree.insert('', END, values=(el[0],el[1],el[2],el[3],el[4],el[5]), tags = ('oddrow',))
                #a.append(el[0])
            #self.treeHL.heading('H(X)', text='H(X) = '+str(resultat), anchor=CENTER)
            #self.treeHL.heading('L', text='L = '+str(result[2]), anchor=CENTER)
            #self.treeHL.heading('u', text='Efficacité(µ) = '+str(result[3]), anchor=CENTER)
            #self.treeHL.grid(in_=self.frameHL, row=0, column=0, sticky=NSEW)
            #self.frameHL.rowconfigure(0, weight=1)
            #self.frameHL.columnconfigure(0, weight=1)
            #ex.bd.cursor.execute("select acr_nom_int from intervenant")
            #resultat1=ex.bd.cursor.fetchall()
            #self.modified5.set(resultat1)
            #self.modified_entry["values"]=resultat1
        except Exception as err:

    # afficher la requête et le message d'erreur système :

            print ("Requête SQL incorrecte :\n%s\nErreur détectée :\n%s"\

                    % ( err))
            messagebox.showerror("Erreur de saisie", "La requête n est pas correcte.")

    def resultattable(self):
        #prob = self.loginEntry.get().strip().split(' ')
        prob = self.loginEntry.get()
        if ex.bd.echec:
            raise ValueError("Erreur : connection echoue")
        try:
            #prob = [float(i) for i in prob if i!='' and i!='0']
            ex.bd.cursor.execute("select tablename from pg_tables where schemaname='sgde'")
            resultat=ex.bd.cursor.fetchall()
            self.frameHL.pack(fill=BOTH, padx=15, pady=5)
            for el in resultat:
                self.tree.insert('', END, values=(el), tags = ('oddrow',))

            #self.treeHL.heading('H(X)', text='H(X) = '+str(resultat), anchor=CENTER)
            #self.treeHL.heading('L', text='L = '+str(result[2]), anchor=CENTER)
            #self.treeHL.heading('u', text='Efficacité(µ) = '+str(result[3]), anchor=CENTER)
            self.treeHL.grid(in_=self.frameHL, row=0, column=0, sticky=NSEW)
            self.frameHL.rowconfigure(0, weight=1)
            self.frameHL.columnconfigure(0, weight=1)
        except:
            messagebox.showerror("Erreur de saisie", "La requête n est pas correcte.")
    """#le fuseau horaire dans la base de donnees"""
    def recupFUS_HOR_JD(self):
        return self.modified5330.get()
    """#evenement jd"""
    def recupTYP_EVEN_JD(self):
        return self.modified53301.get()
    """#acces public par default"""
    def recupDRT_ACCE_JD(self):
        return self.modified51.get()
    """#type de jeu exemple nc botl"""
    def recupTYP_JD(self):
        return self.modified5.get()
    """#description pour le chargement"""
    def recupDESC_JD(self):
        return self.login.get()
    def recupFORM_FICH_JD(self):
        return self.modified533011.get()
    """#choix d la mission"""
    def recupACR_MISS(self,nc):
        bas=getattr(nc,"CRUISE_HEADER_CRUISE_NAME")
        bas=bas.split(" ")
        ex.bd.cursor.execute("""select acr_miss from mission_exp order by acr_miss""")
        resultat1=ex.bd.cursor.fetchall()
        ad=[]
        for el in resultat1:
            ad.append(el[0])
        for i in ad:
            for j in bas:
                if j in i:
                    res=0
                else:
                    res=1
            if res==0:
                self.modified53321002.set(i)
            else:
                res=1
        ex.bd.cursor.execute("""select acr_nom_int from mission_exp where acr_miss= '%s'"""%self.modified53321002.get())
        resultat=ex.bd.cursor.fetchone()
        self.modified5332100.set(str(resultat[0]))
        #print(self.modified5332100.get())
        if self.modified53321002.get()=="":
            messagebox.showerror("Erreur de requête", "le choix acr_miss est important pour le producteur.")
            return
        if self.modified5332100.get()=="":
            messagebox.showerror("Erreur de requête", "le choix du Producteur est automatique.")
            return
        return self.modified53321002.get()
    """#le chef de mission"""
    def recup_ACR_NOM_INT_PROD(self,nc):
        if self.modified53321002.get()=="":
            messagebox.showerror("Erreur de requête", "le Choississez juste une mission.")
        self.recupACR_MISS(nc)
        return self.modified5332100.get()
    """contient les donnees des variables comme PRES"""
    def recupJD_LIE_JD(self):
        temp=askopenfilename(title="Ouvrir un tampon csv",filetypes=[('all files','.*')])
        self.modified533.set(temp)
        return temp
    def recupJD_Rep(self):
        rep = askdirectory(title='Choisissez un repertoire')
        self.modified53323.set(rep)
        return rep
    def recupDESC_LIAIS(self,filename):
        return "fichier brute " + os.path.basename(filename)

    def recupNOM_FICH_JD(self,filename):
        return os.path.basename(filename)
    """date min jd dans le nc file"""
    def recupDAT_MIN_JD(self,nc):
        i=0
        #print(pd.to_datetime(getattr(nc,"EVENT_HEADER_START_DATE_TIME")))
        s=getattr(nc,"EVENT_HEADER_START_DATE_TIME")
        for f in s:
            if f=="[":
                g=len(s)-i
                return s[:-g]
            i=i+1
        return s
    """date max jd dans le nc file"""
    def recupDAT_MAX_JD(self,nc):
        i=0
        #print(pd.to_datetime(getattr(nc,"EVENT_HEADER_START_DATE_TIME")))
        s=getattr(nc,"EVENT_HEADER_START_DATE_TIME")
        for f in s:
            if f=="[":
                g=len(s)-i
                return s[:-g]
            i=i+1
        return s
    """recup lat long profondeur"""
    def recupLAT_1_JD(self,nc):
        return getattr(nc,"EVENT_HEADER_INITIAL_LATITUDE")
    def recupLNGT_1_JD(self,nc):
        return getattr(nc,"EVENT_HEADER_INITIAL_LONGITUDE")
    def recupLAT_2_JD(self,nc):
        return getattr(nc,"EVENT_HEADER_END_LATITUDE")
    def recupLNGT_2_JD(self,nc):
        return getattr(nc,"EVENT_HEADER_END_LONGITUDE")
    def recupPROFD_MIN_JD(self,nc):
        return getattr(nc,"EVENT_HEADER_MIN_DEPTH")
    def recupPROFD_MAX_JD(self,nc):
        return getattr(nc,"EVENT_HEADER_MAX_DEPTH")
    def recupAcr(self,nc):
        bas=getattr(nc,"CRUISE_HEADER_CRUISE_NAME")
        bas=bas.split(" ")
        ex.bd.cursor.execute("""select acr_miss from mission_exp order by acr_miss""")
        resultat1=ex.bd.cursor.fetchall()
        ad=[]
        for el in resultat1:
            ad.append(el[0])
        for i in ad:
            for j in bas:
                if j in i:
                    res=0
                else:
                    res=1
            if res==0:
                return i
            else:
                res=1
        return ""
    def recupFAN_MULT_EVEN_JD(self,nc):
        return 0
    def getsizzeoctet(self,size_bytes):
        return "%s %s" % (size_bytes, "Octet")
    """la taille du fichier btl"""
    def recupVOL_JD(self,filename):
        #return os.path.getsize(filename[-6:])
        #m=re.findall('\d+', filename[:-6])
        m=(filename[:-6])[-2:]
        temp=glob.glob(self.modified53323.get()+'/*.btl')
        for fichier in temp:
            s=os.path.basename(fichier)[:-4]
            if m==s[-2:]:
                return self.getsizzeoctet(os.path.getsize(fichier))

    def recupSTAT_JD(self,filename):
        return (os.path.basename(filename)[-8:])[:2]
    def recupCOT_QUAL_JD(self,filename):
        return 0
    """recup les variables du fichiers netdcf"""
    def recupACR_DICT_MD(self,nc):
        liste=[]
        liste2=[]
        for name in nc.variables.keys():
            liste.append(name)
        for i in liste:
            if i[-3:]=="_01" or i[-3:]=="_02":
                liste2.append(i[:-3])
            elif "LATITUDE" in i:
                continue
            elif "LONGITUDE" in i:
                continue
            elif "TIME" in i:
                continue
            elif "TE090C" in i or "TE90" in i :
                liste2.append("TE90")
            else:
                liste2.append(i)
        return list(set(liste2))
    def recupACR_STA_FIX(self,filename):
        return ""
    def recupACR_MOTS_CLEF(self,filename):
        return "ARGENTINA"
    def recupNOM_DOC_JOINT(self,filename):
        return ""
    """liste pour creer le fichier ed chargement"""
    def recupDonneesNC(self,dirname,filename):
        nc=Dataset(filename)
        Babacar=[]
        self.recupACR_MISS(nc)
        liste=(self.recupNOM_FICH_JD(filename),self.recupFUS_HOR_JD(),self.recupDAT_MIN_JD(nc),self.recupDAT_MAX_JD(nc), \
                self.recupLAT_1_JD(nc),self.recupLNGT_1_JD(nc),self.recupLAT_2_JD(nc),self.recupLNGT_2_JD(nc),self.recupPROFD_MIN_JD(nc), \
                    self.recupPROFD_MAX_JD(nc),self.recupTYP_EVEN_JD(),self.recupFAN_MULT_EVEN_JD(nc),self.recupVOL_JD(filename), \
                        self.recupDRT_ACCE_JD(),self.recupSTAT_JD(filename),self.recupTYP_JD(),self.recup_ACR_NOM_INT_PROD(nc), \
                            self.recupDESC_JD(),self.recupFORM_FICH_JD(),self.recupCOT_QUAL_JD(filename),self.recupACR_MISS(nc),self.recupACR_DICT_MD(nc), \
                                os.path.basename(self.modified533.get()),self.recupDESC_LIAIS(filename),self.recupACR_STA_FIX(filename),self.recupACR_MOTS_CLEF(filename),self.recupNOM_DOC_JOINT(filename))
        return liste
    """fichier tampon a charger"""
    def recupTempon(self,liste):
    #current_dir = os.getcwd()
    #data_dir = os.path.join(current_dir, 'btl')
    #current_dir = os.getcwd()
        #self.recupACR_MISS(nc)
        temp=self.modified533.get()
        #temp=list(temp)
        liste1=(os.path.basename(temp),self.recupFUS_HOR_JD(),min(liste["DAT_MIN_JD"]),min(liste["DAT_MAX_JD"]), \
                min(liste["LAT_1_JD"]),min(liste["LNGT_1_JD"]),min(liste["LAT_2_JD"]),min(liste["LNGT_2_JD"]),min(liste["PROFD_MIN_JD"]), \
                min(liste["PROFD_MAX_JD"]),self.recupTYP_EVEN_JD(),-1,self.getsizzeoctet(os.path.getsize(temp)), \
                    self.recupDRT_ACCE_JD(),"","BRUTE-"+ (self.recupTYP_JD())[-4:],liste["ACR_NOM_INT_PROD"][0], \
                        liste["DESC_JD"][0],liste["FORM_FICH_JD"][0],liste["COT_QUAL_JD"][0],liste["ACR_MISS"][0],"", \
                            "","","","","")
        return liste1
    """creation du fichier de chargement"""
    def mergeAll(self,dirname):
        liste=[]
        #current_dir = os.getcwd()
        #data_dir = os.path.join(current_dir, 'btl')
        #current_dir = os.getcwd()
        #self.recupACR_MISS(nc)
        temp=glob.glob(dirname+'/*.nc')
        if self.modified5330.get()=="":
            messagebox.showerror("Erreur de requête", "le choix du fus_hor_jd est important.")
            return
        #elif self.modified53321002.get()=="":
        #    messagebox.showerror("Erreur de requête", "le choix acr_miss est important pour le producteur.")
        #    return
        elif self.modified51.get()=="":
            messagebox.showerror("Erreur de requête", "le choix du droit acces est important.")
            return
        elif self.modified5.get()=="":
            messagebox.showerror("Erreur de requête", "le choix du type jeu de donnees est important.")
            return
        elif self.modified533.get()=="":
            messagebox.showerror("Erreur de requête", "le choix du doc joint est important.")
            return
        elif self.modified53301.get()=="":
            messagebox.showerror("Erreur de requête", "le choix du type even jd (LEVE) par default est important.")
            return
        elif self.modified533011.get()=="":
            messagebox.showerror("Erreur de requête", "le choix du type de donnees par default BINAIRE est important.")
            return
        #elif self.modified5332100.get()=="":
        #    messagebox.showerror("Erreur de requête", "le choix du Producteur est automatique.")
        #    return
        else:
            for i in temp:
                liste.append(self.recupDonneesNC(dirname,i))
                label=["NOM_FICH_JD","FUS_HOR_JD","DAT_MIN_JD","DAT_MAX_JD","LAT_1_JD","LNGT_1_JD","LAT_2_JD","LNGT_2_JD",\
                    "PROFD_MIN_JD","PROFD_MAX_JD","TYP_EVEN_JD","FAN_MULT_EVEN_JD","VOL_JD","DRT_ACCE_JD","STAT_JD",\
                        "TYP_JD","ACR_NOM_INT_PROD","DESC_JD","FORM_FICH_JD","COT_QUAL_JD","ACR_MISS","ACR_DICT_MD",\
                            "JD_LIE_JD","DESC_LIAIS","ACR_STA_FIX","MOTS_CLEF","NOM_DOC_JOINT"]
        #current_dir = os.getcwd()
        #data_dir = os.path.join(current_dir, 'btl')
            df= pd.DataFrame.from_records(liste,columns=label)
            liste.append(self.recupTempon(df))
            df= pd.DataFrame.from_records(liste,columns=label)
            fichier=dirname+"/chargement_"+(df["NOM_FICH_JD"][0])[:-9]+".csv"
            df.to_csv(fichier, sep = ';',encoding="utf-8", index=False)
            print("fichier de chargement: %s" % fichier)
    """le bouton creer le fichier de chargement"""
    def resultatmission21(self):
        self.mergeAll(self.modified53323.get())
        self.destroy()
        #nc=Dataset("btl/BOTL_2014001_01_1_.nc")
        #print(self.recupDonneesNC(self.modified53323.get(),"btl/BOTL_2014001_01_1_.nc"))
        #print(self.recup_ACR_NOM_INT_PROD())
        #jeu_donnees_colnames = ['NOM_FICH_JD', 'DAT_MIN_JD', 'DAT_MAX_JD', 'FUS_HOR_JD', 'LAT_1_JD',\
        #    'LNGT_1_JD', 'LAT_2_JD', 'LNGT_2_JD', 'PROFD_MIN_JD', 'PROFD_MAX_JD', 'TYP_EVEN_JD',\
        #        'FAN_MULT_EVEN_JD', 'VOL_JD', 'DAT_CREA_MAJ_JD', 'CLAS_ACCE_JD', 'DRT_ACCE_JD',\
        #            'STAT_JD', 'TYP_JD', 'ACR_NOM_INT_PROD', 'ACR_NOM_INT_INSC', 'DESC_JD', 'FORM_FICH_JD',\
        #                'COT_QUAL_JD', 'ACR_MISS', 'STATUT_JD', 'NO_CHARGEMENT']
        #print(len(jeu_donnees_colnames),len(label))
def recupInterface(dirname):
    ex.main()
    huff = AccesGraphic()
    huff.mainloop()
    #huff.mergeAll(dirname)