Changeset 7082


Ignore:
Timestamp:
25/06/10 08:54:43 (9 years ago)
Author:
astephen
Message:

getting status monitoring working properly.

Location:
cows_wps/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cows_wps/trunk/cows_wps/controllers/test.py

    r7034 r7082  
    3131                 
    3232        return resp 
     33 
     34    def setcookie(self): 
     35        response.set_cookie('wps_ui_error_msg', 'The WPS was run with the inputs you provided. The WPS rejected the job submission with the following error message. You may be able to modify your request to overcome this error.'.replace(" ", "_"), expires=3600) 
     36        return "I set it" 
     37 
     38        
     39    def getcookie(self): 
     40        cookie_msg = request.cookies["wps_ui_error_msg"] 
     41        return "COOKIE: %s" % cookie_msg.replace("_", " ") 
    3342 
    3443    def beaker(self): 
  • cows_wps/trunk/cows_wps/public/js/ui/jobviewer_utils.js

    r7018 r7082  
    6868    }); 
    6969 
    70     // ProcessStarted percentCompleted="$percent" 
    71     var pc; 
     70    // Look for ProcessStarted and percentCompleted="$percent" 
     71    var pc = "0"; 
    7272    $(xml).find("ProcessStarted").each(function() 
    7373    { 
    74         pc = $(this).attr("percentComplete");  
    75         $("#poll_info").html("Your job is currently running. The job is " + pc + "% complete."); 
     74        pc = $(this).attr("percentCompleted");  
    7675    }); 
    7776 
     77    $("#poll_info").html("Your job is currently running. The job is " + pc + "% complete."); 
    7878 
    7979    // Assume we found ProcessStarted or ProcessAccepted so keep polling 
  • cows_wps/trunk/cows_wps/public/js/ui/submit_utils.js

    r7067 r7082  
    9393} 
    9494 
     95/* 
     96  function checkForWPSCaughtException: 
     97   - checks if an exception caught when submitting a job 
     98   - parses exception and displays it if found 
     99  Inputs: 
     100    * xml - xml response 
     101  Returns: 
     102    * boolean (true if exception caught) 
     103*/ 
     104function checkForWPSCaughtException(xml) { 
     105    // Returns true if error caught and false if not 
     106    var job_rejected = false; 
     107    $(xml).find("ProcessFailed").each(function() 
     108    { 
     109        job_rejected = true; 
     110    }); 
     111 
     112    if (job_rejected) { 
     113        var exception_text = "Error unknown"; 
     114        $(xml).find("ows\\:ExceptionText").each(function() 
     115        { 
     116            exception_text = trim($(this).text()); 
     117        }); 
     118 
     119        html = "The WPS was sent a job request based on the inputs you have provided. The WPS rejected the job submission with the following error message: <br/><br/><div style='background: white; border: solid;'>" + exception_text + "</div><br/>You may be able to click the browser 'back' button and modify your request to overcome this error."; 
     120 
     121        $("#wps_response_div").empty(); 
     122        $("#wps_response_div").html(html); 
     123        return true; 
     124    } else { 
     125        return false; 
     126    } 
     127} 
     128 
     129 
    95130function parseWPSResponse(xml) 
    96131{ 
     132    // Check for error first 
     133    if (checkForWPSCaughtException(xml) == true) { 
     134        return; 
     135    } 
     136 
     137    // Since no error we parse the response for info we need 
    97138    var html = "The system estimates has estimated the following information for your job:<br>" 
    98 //    var items = ["FileSize", "FileInfo"]; 
    99139    var volume; 
    100140    var duration; 
     
    126166} 
    127167 
    128  
  • cows_wps/trunk/cows_wps/utils/common.py

    r7003 r7082  
    269269    return resp 
    270270 
     271 
    271272def mapDownloadURLToFilePath(url): 
    272273    from cows_wps.model.managers import requestManager 
  • cows_wps/trunk/process_modules/extract_uk_station_data.py

    r7071 r7082  
    6565        # Now check limit on number of station IDs 
    6666        nStations = len(stationList) 
     67        STATION_LIMIT = 100 
     68        nYears = int(a["EndDateTime"][:4]) - int(a["StartDateTime"][:4]) 
    6769 
    68         STATION_LIMIT = 10000 
    69         if nStations > STATION_LIMIT  and a["OutputTimeChunk"] == "decadal": 
     70        if nStations > STATION_LIMIT and a["OutputTimeChunk"] == "decadal": 
     71            a["OutputTimeChunk"] = "year" 
    7072            raise Exception("The number of selected station IDs has been calculated to be greater than %d. Please select a chunk size other than 'decadal' for such as large volume of data." % STATION_LIMIT) 
    71  
    72         nYears = int(a["EndDateTime"][:4]) - int(a["StartDateTime"][:4]) 
    7373 
    7474        if nYears > 1 and nStations > STATION_LIMIT: 
     
    9393            outputPaths = exuk_utils.extractStationDataByTimeChunk([a["ObsTableName"]], a["StartDateTime"],  
    9494                       a["EndDateTime"], stationList, a["OutputTimeChunk"], dataFileBase, a["Delimiter"], 
    95                        ext, procTmpDir) 
     95                       ext, procTmpDir, context) 
    9696        
    9797            for outputPath in outputPaths:  
  • cows_wps/trunk/process_modules/lib_extract_uk_station_data/utils.py

    r7010 r7082  
    1010import urllib 
    1111 
     12from cows_wps.process_handler.context.process_status import STATUS 
    1213from cows_wps.utils.duration_splitter import * 
    1314 
     
    1920 
    2021def extractStationDataByTimeChunk(obs_tables, startTime, endTime, src_ids, time_chunk,  
    21                     output_file_base, delimiter, ext, tempDir): 
     22                    output_file_base, delimiter, ext, tempDir, context): 
    2223    """ 
    2324    Loops through time chunks extracting data to files in required time chunks. 
     25    We pass the context object through here so that we can report progress. 
    2426    Returns a list of output file paths produced. 
    2527    """  
     
    3537    output_file_paths = [] 
    3638 
     39    progress = 5 # % of way through 
    3740    for (start_date, end_date) in time_splits:  
    3841 
     
    5659        midasSubsetter.MIDASSubsetter(obs_tables, output_file_path, startTime = start, 
    5760                       endTime = end, src_ids = src_ids, delimiter = delimiter, tempDir = tempDir) 
     61 
     62        # Report on progress 
     63        progress += (int(list(time_splits).index((start_date, end_date)) / len(time_splits)) * 100 - 5) 
     64        context.setStatus(STATUS.STARTED, 'Job is now running', progress) 
    5865         
    5966    return output_file_paths 
Note: See TracChangeset for help on using the changeset viewer.