Ejemplo n.º 1
0
def main():
    realpath=os.path.dirname(os.path.abspath(__file__))
    parameterpath=realpath.replace('py','parameter')
    #HARDCODING
    raw_data_name_file=os.path.join(parameterpath,'raw_data_name.txt')  #this data conclude the VP_NUM HULL_NUM VESSEL_NAME
    output_path=realpath.replace('py','result')  #use to save the data 
    telemetry_status=os.path.join(parameterpath,'telemetry_status.csv')
    # below hardcodes is the informations to upload local data to student drifter. 
    subdir=['Matdata','checked']
    mremote='/Raw_Data'
    remote_subdir=['Matdata','checked']
    ###########################
    end_time=datetime.now()
    start_time,end_time=week_start_end(end_time,interval=1)
    #download raw data from website
    files=ftpdownload.download(os.path.join(output_path,'Matdata'),ftppath='/Matdata')
    #classify the file by every boat
    rdm.classify_by_boat(indir=os.path.join(output_path,'Matdata'),outdir=os.path.join(output_path,'classified'),pstatus=telemetry_status)
    print('classfy finished!')
    #check the reformat of every file:include header,heading,lat,lon,depth,temperature.
    rdm.check_reformat_data(indir=os.path.join(output_path,'classified'),outdir=os.path.join(output_path,'checked'),startt=start_time,\
                        endt=end_time,pstatus=telemetry_status,rdnf=raw_data_name_file)
    print('check format finished!')
    for i in range(len(subdir)):
        local_dir=os.path.join(output_path,subdir[i])
        remote_dir=os.path.join(mremote,remote_subdir[i])
        up.sd2drf(local_dir,remote_dir,filetype='csv',keepfolder=True)
#if __name__=='__main__':
#    main()
def main():
    # realpath=os.path.dirname(os.path.abspath(__file__))
    realpath = 'C:\\Weekly_Project\\Weekly_Project\\programe\\raw_data_match\\py'
    parameterpath = realpath.replace('py', 'parameter')
    #HARDCODING
    raw_data_name_file = os.path.join(
        parameterpath, 'raw_data_name.txt'
    )  #this data conclude the VP_NUM HULL_NUM VESSEL_NAME
    #raw_data_name_file='E:/programe/raw_data_match/parameter/raw_data_name.txt'
    output_path = realpath.replace('py', 'result')  #use to save the data
    #telemetry_status=os.path.join(parameterpath,'telemetry_status.csv')
    telemetry_status = 'C:\\Weekly_Project\\Weekly_Project\\programe\\aqmain\\parameter\\telemetry_status.csv'
    lack_data_path = os.path.join(output_path, 'lack_data.txt')
    #lack_data_path='E:/programe/raw_data_match/result/lack_data.txt'#store the name of file that lacked data after 'classfy finished'
    # below hardcodes is the informations to upload local data to student drifter.
    subdir = ['Matdata', 'checked']
    mremote = '/Raw_Data'
    #mremote='\Raw_Data'
    remote_subdir = ['Matdata', 'checked']
    ###########################
    end_time = datetime.utcnow()
    #start_time,end_time=week_start_end(end_time,interval=1)
    start_time = end_time - timedelta(weeks=2)
    #download raw data from website
    files = ftpdownload.download(
        localpath=
        'C:\\Weekly_Project\\Weekly_Project\\programe\\raw_data_match\\result\\Matdata',
        ftppath='/Matdata')
    #classify the file by every boats
    #rdm.classify_by_boat(indir='E:\\programe\\raw_data_match\\result\\Matdata',outdir='E:\\programe\\raw_data_match\\result\\classified',pstatus=telemetry_status)
    classify_by_boat(
        indir=
        'C:\\Weekly_Project\\Weekly_Project\\programe\\raw_data_match\\result\\Matdata',
        outdir=
        r'C:\\Weekly_Project\\Weekly_Project\\programe\\raw_data_match\\result\\classified',
        pstatus=telemetry_status)
    print('classfy finished!')
    #check the reformat of every file:include header,heading,lat,lon,depth,temperature.
    check_reformat_data(indir='C:\\Weekly_Project\\Weekly_Project\\programe\\raw_data_match\\result\\classified',outdir='C:\\Weekly_Project\\Weekly_Project\\programe\\raw_data_match\\result\\checked',startt=start_time,\
                        endt=end_time,pstatus=telemetry_status,rdnf=raw_data_name_file,lack_data=lack_data_path)
    print('check format finished!')
    for i in range(len(subdir)):
        local_dir = os.path.join(output_path, subdir[i])
        #remote_dir=os.path.join(mremote,remote_subdir[i])
        remote_dir = os.path.join(mremote, remote_subdir[i]).replace('\\', '/')
        #up.sd2drf(local_dir,remote_dir,filetype='csv',keepfolder=True)
        try:
            sd2drf(local_dir, remote_dir, filetype='csv', keepfolder=True)
        except TimeoutError:
            print('Timeout Error')