Пример #1
0
def datatrack(request):
    form = TrackForm()
    user = request.user.username
    if request.method=="POST":
        form = TrackForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            sYear = data['sYear']
            sMonth = data['sMonth']
            sDay = data['sDay']
            sHour = data['sHour']
            eHour = data['eHour']
            sites = data['sites'].split()
            days = ymdToYd(sYear, sMonth, sDay)
            filedir = os.path.join(CONFIG.SOFTWAREPATH+user, 'track/track_data')
            cmd = "cd %s;csh %s/get_orbits -archive sopac -yr %s -doy %s -ndays 1" % (filedir, cwd, sYear, days)
            call(cmd, shell=True)

            now = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
            trackResult = track.track(sYear, sMonth, sDay, sHour, eHour, sites, now)
            if trackResult:
                return render_to_response("DataProc/suc.html", {},context_instance=RequestContext(request))
            else:
                return render_to_response("DataProc/fail.html", {},context_instance=RequestContext(request))
    return render_to_response("DataProc/track.html", {'form': form},context_instance=RequestContext(request))
Пример #2
0
def trackProcess(request):
    sYear = (int)(request.GET['sYear'])
    sMonth = (int)(request.GET['sMonth'])
    sDay = (int)(request.GET['sDay'])
    sHour = (int)(request.GET['sHour'])
    eHour = (int)(request.GET['eHour'])
    log.info(sYear, sMonth, sDay, sHour, eHour)
    sites = request.GET['sites'].split()
    log.info(sites)

    #下载一天的sp3数据
    days = monthToDay.ymdToYd(sYear, sMonth, sDay)
    filedir = os.path.join(cwd, 'track/track_data')
    cmd = "cd %s;csh %s/get_orbits -archive sopac -yr %s -doy %s -ndays 1" % (filedir, cwd, sYear, days)
    call(cmd, shell=True)

    now = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
    trackResult = track.track(sYear, sMonth, sDay, sHour, eHour, sites, now)
    if trackResult:
        return HttpResponse(trackResult)
    else:
        return render_to_response("png_track.html",
                {'png': '/track/track_picture/track%s.png' % now, 'file': '/track/log/CGDM056a.NEU.somt.LC'})