interface.py 3.09 KB

#!/usr/bin/env python
#! python

#####################################
#
#Conversion de fichiers excel a netCDF + chargement
#
#Auteur: Babacar THIAM
#
#$Id$
#
####################################
import xlrd
from netCDF4 import Dataset
import numpy as np
import os
from tkinter import *
from tkinter.filedialog import *
import sys
import getopt
import re
import math
import shlex
from classe_variable import variable
import usage
from netCDF4 import Dataset
import numpy as np
import os
import glob
from tkinter import *
from tkinter.filedialog import *
import testexcel as te
import databtlType as dbt
import recupdatanetcdf as rd
import testPostgres as pf
import loadjd as ld
import conn as cn
import jeudedonneesdelete as jd

intervalle = 1.0
#On recupere les parametres d'appel
def main():

    try:
        opts,args = getopt.getopt(sys.argv[1:],"i:h",["input=","help"])
    except getopt.GetoptError as msg:
        print(msg)
        usage.usagefile()
        sys.exit(2)
    for o , a in opts:
        if o in ("-h","--help"):
            usage.usagefile()
            sys.exit(2)#

        elif o in ("-i","--input"):
            if a in ("-i","--input",\
                     "-h","--help"):
                usage.usagefile()
                sys.exit(2)
            fnomin = a
        else:
            print("Option inconnue")
            usage.usagefile()
            sys.exit(2)
    #fnomin=os.path.basename(fnomin)
    fnomin=os.path.abspath(fnomin)
    if not (os.path.isdir(fnomin)):
        print("Choississez le repertoire des fichiers btl")
        return
    else:
        temp=glob.glob(fnomin+'/*.xlsx')
        if len(temp) <= 0 :
            print("il n'existe pas de fichier btl dans ce repertoire")
        else:
            data_dir = os.path.join(fnomin, 'data')
            if not(os.path.exists(data_dir)):
                os.mkdir(data_dir)
            data_dir = os.path.join(fnomin, 'log')
            if not(os.path.exists(data_dir)):
                os.mkdir(data_dir)
            #print(te.recupTete(fnomin))
            #rd.mergeAll(fnomin)
            """les fichiers netcdf sont creer par: """
            #print(te.creerAllbtl(fnomin))
            """creer le file matsgde """
            #print(rd.recupInterface(fnomin))
            """chargement dans la base de donnees et archivage des donnees"""
            #print(ld.chargementbtl(fnomin))
            """suppression dun jeu de donnees"""
            #print(jd.recupdelete(fnomin))

            #print(te.createTestbis(fnomin,"/home/thib0010/Bureau/QO/codeTest/chargerfinal/src/btl/1401007.btl"))
            #
            #print(te.supprimeVide(fnomin,"1306001"))
            #print(te.createTestbis(fnomin,"1306001"))
            #print(ld.testtampon(fnomin))
            #print(rd.recupInterface(fnomin))
            #print(te.csvexcel(fnomin))
            #print(te.nomallliste(fnomin))
            #print(ld.recupforseriebis(fnomin,j))
            #print(ld.loadjeudedonnees(fnomin))
            #resultatmission21(self)
            #te.recupalldata(fnomin)
            #print(tb.recupvaleurname(a))


if __name__== '__main__':
    main()
#Processing des parametres