コード例 #1
0
def delete_comment(global_config, issue_id, tag):
 
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])
    
    IssueTrackerDataModel.deleteIssueCommentsByTag(session, issue_id, tag)
    session.commit()
    return '/issue/%s' % issue_id
コード例 #2
0
def get_platform_issues(global_config, platform_type, status=''):
    global_config['logger'].debug( 'GET Issues for platform: %s', platform_type )
 
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])

    if status.lower() == 'open':
        issues = IssueTrackerDataModel.getIssuesByPlatformAndMultipleStatus(session, platform_type, 'Open', 'Working', 
                                                                                 order_by_priority=True)
    elif status.lower() == 'closed':
        issues = IssueTrackerDataModel.getIssuesByPlatformAndMultipleStatus(session, platform_type, 'Closed', 'Resolved')
    else:
        issues = IssueTrackerDataModel.getIssuesByPlatform(session, platform_type, status)
                
    web.header('Content-Type', 'application/json')
    result = []
    result.append('{ "issues": [\n')
    
    for issue in issues:
        result.append(issue.json())
        result.append(',\n')
    if len(issues) > 0:
        result = result[:-1]
        result.append('\n')
    result.append(']}')
    
    session.remove()
    return ''.join(result)
コード例 #3
0
def process_issue_comment_form(global_config, form, issue_id, username):
    global_config['logger'].debug( 'Process Issue Comment Form: %s', issue_id )
    
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])                   
    comment = form[issue_comment_label].value
    timestamp = str(int(time.time()))

    if comment != '':    
        IssueTrackerDataModel.addOrUpdateIssueComment(session, issue_id, 
                                                      username, timestamp,
                                                      comment)
        session.commit()
    return '/issue/%s' % issue_id            
コード例 #4
0
def get_issue_json(global_config, issue_id, allow_update=False):
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])
    issue = IssueTrackerDataModel.getIssue(session, issue_id)
    if issue:
        return issue.json()
    else:
        return None
コード例 #5
0
def get_issue_form(global_config, issue_id):
    global_config['logger'].debug( 'GET Issue Form, Issue: %s', issue_id )
        
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])
    users_session = DbSession.open_db_session(global_config['users_db_name'] + global_config['this_season'])

    issue_id = issue_id
    platform = issue_id.split('-')[0]
    issue = IssueTrackerDataModel.getIssue(session, issue_id)
    
    form = issueform()
    form[issue_id_label].value = issue_id
    form[issue_platform_label].value = platform
    form[issue_summary_label].value = issue.summary
    form[issue_status_label].value = issue.status
    form[issue_priority_label].value = issue.priority
    
    # TODO: can also extract the subgroup and taskgroup(component) lists from the 
    #       database and override the form with the contents
    #       IssueTrackerDataModel.getSubgroupList() and getTaskgroupList()
    form[issue_subgroup_label].value = issue.subgroup
    form[issue_component_label].value = issue.component
    
    # apply the valid list of user names to the dropdown 
    # for the owner field and the submitter field
    username_list = UsersDataModel.getDisplayNameList(users_session)
    form[issue_owner_label].args = username_list
    form[issue_submitter_label].args = username_list

    form[issue_owner_label].value = issue.owner
    form[issue_submitter_label].value = issue.submitter
    form[issue_description_label].value = issue.description

    return form
コード例 #6
0
def process_issue_form(global_config, form, issue_id, username):
    global_config['logger'].debug( 'Process Issue Form Issue: %s', issue_id )
    
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])
                    
    platform = issue_id.split('-')[0]
    summary = form[issue_summary_label].value
    status = form[issue_status_label].value
    priority = form[issue_priority_label].value
    subgroup = form[issue_subgroup_label].value
    owner = form[issue_owner_label].value
    submitter = form[issue_submitter_label].value
    component = form[issue_component_label].value
    description = form[issue_description_label].value
    comment = form[issue_comment_label].value
    timestamp = str(int(time.time()))
    
    issue_string =  'Id:' + issue_id + '\n'
    issue_string += 'Timestamp:%s\n' % timestamp 
    issue_string += issue_platform_label + platform + '\n'
    issue_string += issue_summary_label + summary + '\n'
    issue_string += issue_status_label + status + '\n'
    issue_string += issue_priority_label + priority + '\n'
    issue_string += issue_subgroup_label + subgroup + '\n'
    issue_string += issue_component_label + component + '\n'
    issue_string += issue_owner_label + owner + '\n'
    issue_string += issue_submitter_label + submitter + '\n'
    issue_string += issue_description_label + description + '\n'
    
    #TODO: Add platform to the data model
    issue = IssueTrackerDataModel.addOrUpdateIssue(session, issue_id, summary, 
                                           status, priority, subgroup, 
                                           component, submitter, owner, 
                                           description, timestamp)
    if issue != None:
        competition = global_config['this_competition'] + global_config['this_season']
        issue.create_file('./static/data/%s/ScoutingData' % competition)

    if comment != '':
        IssueTrackerDataModel.addOrUpdateIssueComment(session, issue_id, 
                                                      username, timestamp,
                                                      comment)
    session.commit()
    session.remove()
    
    return '/issue/%s' % issue_id            
コード例 #7
0
def isFileProcessed(session, db_name, filepath):
    if db_name == global_config['db_name']:
        is_processed = DataModel.isFileProcessed(session, filepath)
    elif db_name == global_config['issues_db_name']:
        is_processed = IssueTrackerDataModel.isFileProcessed(session, filepath)
    elif db_name == global_config['debriefs_db_name']:
        is_processed = DebriefDataModel.isFileProcessed(session, filepath)
        
    return is_processed
コード例 #8
0
def isFileProcessed(global_config, session, db_name, filepath):
    if db_name == (global_config["db_name"] + global_config["this_season"]):
        is_processed = DataModel.isFileProcessed(session, filepath)
    elif db_name == (global_config["issues_db_name"] + global_config["this_season"]):
        is_processed = IssueTrackerDataModel.isFileProcessed(session, filepath)
    elif db_name == (global_config["debriefs_db_name"] + global_config["this_season"]):
        is_processed = DebriefDataModel.isFileProcessed(session, filepath)

    return is_processed
コード例 #9
0
def process_issue_files(global_config, input_dir, recursive=True):

    # Initialize the database session connection
    issues_db_name  = global_config['issues_db_name'] + global_config['this_season']
    debrief_db_name = global_config['debriefs_db_name'] + global_config['this_season']
    debrief_session = DbSession.open_db_session(debrief_db_name)
    issues_session  = DbSession.open_db_session(issues_db_name)

    # The following regular expression will select all files that conform to 
    # the file naming format Issue*.txt. Build a list of all datafiles that match
    # the naming format within the directory passed in via command line 
    # arguments.
    file_regex = re.compile('Issue[a-zA-Z0-9_-]+.txt')
    files = get_files(global_config, issues_session, issues_db_name, input_dir, file_regex, recursive)
    
    files.sort()
    
    # Process data files
    for data_filename in files:
        print 'processing %s'%data_filename
        try:
            # Initialize the file_attributes dictionary in preparation for the
            # parsing of the data file
            issue_attributes = {}
            
            # Parse the data file, storing all the information in the file_attributes
            # dictionary
            FileParser.FileParser(data_filename).parse(issue_attributes)
    
            issue = IssueTrackerDataModel.addIssueFromAttributes(issues_session, issue_attributes)
            if issue.debrief_key != None:
                match_str, issue_key = issue.debrief_key.split('_')
                competition = global_config['this_competition'] + global_config['this_season']

                DebriefDataModel.addOrUpdateDebriefIssue(debrief_session, int(match_str), 
                                                         competition,
                                                         issue.issue_id, issue_key)
        except Exception, e:
            # log the exception but continue processing other files
            log_exception(global_config['logger'], e)

        # add the file to the set of processed files so that we don't process it again. Do it outside the
        # try/except block so that we don't try to process a bogus file over and over again.       
        IssueTrackerDataModel.addProcessedFile(issues_session, data_filename)
コード例 #10
0
def process_new_issue_form(global_config, form):
    global_config['logger'].debug( 'Process New Issue Form' )
    
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])
                    
    # TODO: need to come up with a way to generate the next available issue number
    platform = form[issue_platform_label].value
    issue_id = IssueTrackerDataModel.getIssueId(session, platform)
    
    summary = form[issue_summary_label].value
    status = form[issue_status_label].value
    priority = form[issue_priority_label].value
    subgroup = form[issue_subgroup_label].value
    owner = form[issue_owner_label].value
    submitter = form[issue_submitter_label].value
    component = form[issue_component_label].value
    description = form[issue_description_label].value
    timestamp = str(int(time.time()))
    
    issue_string =  'Id:' + issue_id + '\n'
    issue_string += 'Timestamp:%s\n' % timestamp 
    issue_string += issue_platform_label + platform + '\n'
    issue_string += issue_summary_label + summary + '\n'
    issue_string += issue_status_label + status + '\n'
    issue_string += issue_priority_label + priority + '\n'
    issue_string += issue_subgroup_label + subgroup + '\n'
    issue_string += issue_component_label + component + '\n'
    issue_string += issue_owner_label + owner + '\n'
    issue_string += issue_submitter_label + submitter + '\n'
    issue_string += issue_description_label + description + '\n'

    #TODO: Add component to the data model
    issue = IssueTrackerDataModel.addOrUpdateIssue(session, issue_id, summary, 
                                           status, priority, subgroup, 
                                           component, submitter, owner, 
                                           description, timestamp)
    if issue != None:
        competition = global_config['this_competition'] + global_config['this_season']
        issue.create_file('./static/data/%s/ScoutingData' % competition)
    session.commit()
    session.remove()
    
    return '/issue/%s' % issue_id            
コード例 #11
0
def get_platform_issues_home_page(global_config, platform_type, allow_create=False):
 
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])

    result = ''
    if global_config['issues_db_master'] == 'Yes' and allow_create == True:
        result += '<a href="/newissue/%s"> Create New Issue</a></td>' % platform_type
        result += '<br>'
    result += '<br>'
    result += '<hr>'
    
    #open_issues = IssueTrackerDataModel.getIssuesByPlatform(session, platform_type)
    open_issues = IssueTrackerDataModel.getIssuesByPlatformAndMultipleStatus(session, platform_type, 'Open', 'Working', 
                                                                             order_by_priority=True)
    result += insert_issues_table('Open', open_issues)

    result += '<br>'
    result += '<hr>'
    
    closed_issues = IssueTrackerDataModel.getIssuesByPlatformAndMultipleStatus(session, platform_type, 'Closed', 'Resolved')
    result += insert_issues_table('Closed', closed_issues)

    return result
コード例 #12
0
def get_issues_home_page(global_config, allow_create=False):
 
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])

    result = ''
    result += '<h3> Platforms' + '</h3>'
    issue_types = IssueTrackerDataModel.getIssueTypes(session)
    for platform in issue_types:
        result += '<a href="/issues/%s">%s</a>' % (platform.issue_type,platform.issue_type)
        result += '<br>'
    result += '<hr>'
    
    if global_config['issues_db_master'] == 'Yes' and allow_create == True:
        result += '<a href="/newissue"> Create New Issue</a></td>'
        result += '<br>'
    result += '<hr>'
    
    return result
コード例 #13
0
def process_debrief_files(global_config, input_dir, recursive, test):

    # Initialize the database session connections
    issues_db_name  = global_config['issues_db_name']
    debrief_db_name = global_config['debriefs_db_name']
    debrief_session = DbSession.open_db_session(debrief_db_name)
    issues_session  = DbSession.open_db_session(issues_db_name)
    
    # Create the database if it doesn't already exist
    #if not os.path.exists('./' + db_name):    
    #   DebriefDataModel.create_db_tables(my_db)

    # The following regular expression will select all files that conform to 
    # the file naming format Debrief*.txt. Build a list of all datafiles that match
    # the naming format within the directory passed in via command line 
    # arguments.
    file_regex = re.compile('Debrief[a-zA-Z0-9_-]+.txt')
    files = get_files(debrief_session, debrief_db_name, input_dir, file_regex, recursive, test)
    
    # Process data files
    for data_filename in files:
        print 'processing %s'%data_filename
        try:
            # Initialize the debrief_attributes dictionary in preparation for the
            # parsing of the data file
            debrief_attributes = {}
            
            # Parse the data file, storing all the information in the attributes
            # dictionary
            FileParser.FileParser(data_filename).parse(debrief_attributes)
            DebriefDataModel.addDebriefFromAttributes(debrief_session, debrief_attributes)
            
            # Also, extract the competition name, too, if it has been included in
            # the data file
            if debrief_attributes.has_key('Competition'):
                competition = debrief_attributes['Competition']
            else:
                competition = global_config['this_competition'] + global_config['this_season']
                if competition == None:
                    raise Exception( 'Competition Not Specified!')
    
            # At competition, we will likely have multiple laptops manging the data, but we want
            # only one machine to be responsible for the issues database. In all likelihood,
            # that machine will be the one in the pits, or possibly the application running
            # in the cloud.
            if global_config['issues_db_master'] == 'Yes':
                match_id = debrief_attributes['Match']
                submitter = debrief_attributes['Scouter']
                timestamp = str(int(time.time()))
                subgroup = 'Unassigned'
                status = 'Open'
                owner = 'Unassigned'
                
                if debrief_attributes.has_key('Issue1_Summary'):
                    # look to see if there is already a debrief issue, and if so, do not attempt to create/update
                    # an issue, as there are already other issue files that would then conflict with this one
                    issue_key = 'Issue1'
                    if DebriefDataModel.getDebriefIssue(debrief_session, match_id, issue_key) == None:
                        summary = debrief_attributes['Issue1_Summary']
                        if debrief_attributes.has_key('Issue1_Priority'):
                            priority = debrief_attributes['Issue1_Priority']
                        else:
                            priority = 'Priority_3'
                        if debrief_attributes.has_key('Issue1_Taskgroup'):
                            component = debrief_attributes['Issue1_Taskgroup']
                        else:
                            component = ''
                        if debrief_attributes.has_key('Issue1_Description'):
                            description = debrief_attributes['Issue1_Description']
                        else:
                            description = ''
                        debrief_key = str(match_id) + '_' + issue_key
                    
                        issue_id = IssueTrackerDataModel.getIssueId(issues_session, 'Robot')
                        issue = IssueTrackerDataModel.addOrUpdateIssue(issues_session, issue_id, summary, status, priority, 
                                 subgroup, component, submitter, owner, description, timestamp, debrief_key)
                        if issue != None:
                            issue.create_file('./static/data/%s/ScoutingData' % competition)
                        DebriefDataModel.addOrUpdateDebriefIssue(debrief_session, match_id, competition, issue_id, issue_key)
                    
                if debrief_attributes.has_key('Issue2_Summary'):
                    issue_key = 'Issue2'
                    if DebriefDataModel.getDebriefIssue(debrief_session, match_id, issue_key) == None:
                        summary = debrief_attributes['Issue2_Summary']
                        if debrief_attributes.has_key('Issue2_Priority'):
                            priority = debrief_attributes['Issue2_Priority']
                        else:
                            priority = 'Priority_3'
                        if debrief_attributes.has_key('Issue2_Taskgroup'):
                            component = debrief_attributes['Issue2_Taskgroup']
                        else:
                            component = ''
                        if debrief_attributes.has_key('Issue3_Description'):
                            description = debrief_attributes['Issue3_Description']
                        else:
                            description = ''
                        debrief_key = str(match_id) + '_' + issue_key
                        
                        issue_id = IssueTrackerDataModel.getIssueId(issues_session, 'Robot')
                        issue = IssueTrackerDataModel.addOrUpdateIssue(issues_session, issue_id, summary, status, priority, 
                                 subgroup, component, submitter, owner, description, timestamp, debrief_key)
                        if issue != None:
                            issue.create_file('./static/data/%s/ScoutingData' % competition)
                        DebriefDataModel.addOrUpdateDebriefIssue(debrief_session, match_id, competition, issue_id, issue_key)
                    
                if debrief_attributes.has_key('Issue3_Summary'):
                    issue_key = 'Issue3'
                    if DebriefDataModel.getDebriefIssue(debrief_session, match_id, issue_key) == None:
                        summary = debrief_attributes['Issue3_Summary']
                        if debrief_attributes.has_key('Issue3_Priority'):
                            priority = debrief_attributes['Issue3_Priority']
                        else:
                            priority = 'Priority_3'
                        if debrief_attributes.has_key('Issue3_Taskgroup'):
                            component = debrief_attributes['Issue3_Taskgroup']
                        else:
                            component = ''
                        if debrief_attributes.has_key('Issue3_Description'):
                            description = debrief_attributes['Issue3_Description']
                        else:
                            description = ''
                        debrief_key = str(match_id) + '_' + issue_key
                    
                        issue_id = IssueTrackerDataModel.getIssueId(issues_session, 'Robot')
                        issue = IssueTrackerDataModel.addOrUpdateIssue(issues_session, issue_id, summary, status, priority, 
                                 subgroup, component, submitter, owner, description, timestamp, debrief_key)
                        if issue != None:
                            issue.create_file('./static/data/%s/ScoutingData' % competition)
                        DebriefDataModel.addOrUpdateDebriefIssue(debrief_session, match_id, competition, issue_id, issue_key)
        except Exception, e:
            # log the exception but continue processing other files
            log_exception(e)

        # add the file to the set of processed files so that we don't process it again. Do it outside the
        # try/except block so that we don't try to process a bogus file over and over again.       
        DebriefDataModel.addProcessedFile(debrief_session, data_filename)
コード例 #14
0
def get_issue_page(global_config, issue_id, allow_update=False):
    session = DbSession.open_db_session(global_config['issues_db_name'] + global_config['this_season'])
    issue = IssueTrackerDataModel.getIssue(session, issue_id)
    result = None
    if issue:
        result = ''
        result += '<hr>'
    
        table_str = '<ul>'
        table_str += '<table border="1" cellspacing="5">'
        
        table_str += '<tr>'
        table_str += '<td>' + issue_id_label + '</td>'
        table_str += '<td>' + issue.issue_id + '</td>'
        table_str += '</tr>'
        table_str += '<tr>'
        table_str += '<td>' + issue_summary_label + '</td>'
        table_str += '<td>' + issue.summary + '</td>'
        table_str += '</tr>'
        table_str += '<tr>'
        table_str += '<td>' + issue_status_label + '</td>'
        table_str += '<td>' + issue.status + '</td>'
        table_str += '</tr>'
        table_str += '<tr>'
        table_str += '<td>' + issue_priority_label + '</td>'
        table_str += '<td>' + issue.priority + '</td>'
        table_str += '</tr>'
        table_str += '<tr>'
        table_str += '<td>' + issue_subgroup_label + '</td>'
        table_str += '<td>' + issue.subgroup + '</td>'
        table_str += '</tr>'
        table_str += '<tr>'
        table_str += '<td>' + issue_component_label + '</td>'
        table_str += '<td>' + issue.component + '</td>'
        table_str += '</tr>'
        table_str += '<tr>'
        table_str += '<td>' + issue_owner_label + '</td>'
        table_str += '<td>' + issue.owner + '</td>'
        table_str += '</tr>'
        table_str += '<tr>'
        table_str += '<td>' + issue_submitter_label + '</td>'
        table_str += '<td>' + issue.submitter + '</td>'
        table_str += '</tr>'
        table_str += '<tr>'
        table_str += '<td>' + issue_description_label + '</td>'
        table_str += '<td>' + issue.description + '</td>'
        table_str += '</tr>'
        table_str += '<tr>'
        table_str += '<td>' + issue_last_modified_label + '</td>'
        table_str += '<td>' + time.strftime('%b %d, %Y %I:%M:%S %p', time.localtime(float(issue.timestamp))) + '</td>'
        #table_str += '<td>' + time.strftime('%c', time.localtime(float(issue.timestamp))) + '</td>'
        table_str += '</tr>'
    
        if issue.debrief_key != None:
            match_str = issue.debrief_key.split('_')[0]           
            table_str += '<td>' + 'Reported In:' + '</td>'
            table_str += '<td><a href="/debrief/' + match_str + '">' + 'Match ' + match_str + '</a></td>'
            table_str += '</tr>'

        table_str += '</table>'
        table_str += '</ul>'
        result += table_str
        
        # result += '<br>'
        result += '<hr>'
        
        if global_config['issues_db_master'] == 'Yes' and allow_update == True:
            result += '<a href="/issueupdate/' + issue_id + '"> Update This Issue</a>'
            result += '<br>'
        result += '<a href="/issuecomment/' + issue_id + '"> Comment On This Issue</a>'
        result += '<br>'
        result += '<hr>'
        result += '<h3>Comments</h3>'
        
        comments = IssueTrackerDataModel.getIssueComments(session, issue_id)
        if len(comments) > 0:
            table_str = '<ul>'
            table_str += '<table border="1" cellspacing="5">'
            table_str += '<tr>'
            table_str += '<th>Timestamp</th>'
            table_str += '<th>Commented By</th>'
            table_str += '<th>Comment</th>'
            if allow_update == True:
                table_str += '<th>Delete</th>'
            table_str += '</tr>'
            for comment in comments:      
                table_str += '<tr>'
                table_str += '<td>' + time.strftime('%b %d, %Y %I:%M:%S %p', time.localtime(float(comment.tag))) + '</td>'
                table_str += '<td>' + comment.submitter + '</td>'
                table_str += '<td>' + comment.data + '</td>'
                if global_config['issues_db_master'] == 'Yes' and allow_update == True:
                    table_str += '<td><a href="/deletecomment/issue/' + issue_id + '/' + comment.tag + '">Delete</a></td>'

                table_str += '</tr>'
            table_str += '</table>'
            table_str += '</ul>'
        
            result += table_str   
        result += '<hr>'
      
    session.remove()
    return result    
コード例 #15
0
def process_debrief_files(global_config, input_dir, recursive=True):

    # Initialize the database session connections
    issues_db_name = global_config["issues_db_name"] + global_config["this_season"]
    debrief_db_name = global_config["debriefs_db_name"] + global_config["this_season"]
    debrief_session = DbSession.open_db_session(debrief_db_name)
    issues_session = DbSession.open_db_session(issues_db_name)

    # Create the database if it doesn't already exist
    # if not os.path.exists('./' + db_name):
    #   DebriefDataModel.create_db_tables(my_db)

    # The following regular expression will select all files that conform to
    # the file naming format Debrief*.txt. Build a list of all datafiles that match
    # the naming format within the directory passed in via command line
    # arguments.
    file_regex = re.compile("Debrief[a-zA-Z0-9_-]+.txt")
    files = get_files(global_config, debrief_session, debrief_db_name, input_dir, file_regex, recursive)

    # Process data files
    for data_filename in files:
        print "processing %s" % data_filename
        try:
            # Initialize the debrief_attributes dictionary in preparation for the
            # parsing of the data file
            debrief_attributes = {}

            # Parse the data file, storing all the information in the attributes
            # dictionary
            FileParser.FileParser(data_filename).parse(debrief_attributes)
            DebriefDataModel.addDebriefFromAttributes(debrief_session, debrief_attributes)

            # Also, extract the competition name, too, if it has been included in
            # the data file

            if debrief_attributes.has_key("Competition"):
                competition = debrief_attributes["Competition"]
                issue_base_name = WebCommonUtils.split_comp_str(competition)[0]
            else:
                competition = global_config["this_competition"] + global_config["this_season"]
                issue_base_name = global_config["this_competition"]

                if competition == None:
                    raise Exception("Competition Not Specified!")

            # At competition, we will likely have multiple laptops manging the data, but we want
            # only one machine to be responsible for the issues database. In all likelihood,
            # that machine will be the one in the pits, or possibly the application running
            # in the cloud.
            if global_config["issues_db_master"] == "Yes":
                match_id = debrief_attributes["Match"]
                submitter = debrief_attributes["Scouter"]
                timestamp = str(int(time.time()))
                subgroup = "Unassigned"
                status = "Open"
                owner = "Unassigned"

                if debrief_attributes.has_key("Issue1_Summary") or debrief_attributes.has_key("Issue1_Description"):
                    # look to see if there is already a debrief issue, and if so, do not attempt to create/update
                    # an issue, as there are already other issue files that would then conflict with this one
                    issue_key = "Issue1"
                    if DebriefDataModel.getDebriefIssue(debrief_session, competition, match_id, issue_key) == None:
                        # if no summary is provided, then use the description as the summary. Likewise, if no description
                        # is provided then use the summary as the description. Keep in mind that we need at least the
                        # summary or description to be provided.
                        if debrief_attributes.has_key("Issue1_Summary"):
                            summary = debrief_attributes["Issue1_Summary"]
                        else:
                            summary = debrief_attributes["Issue1_Description"]
                        if debrief_attributes.has_key("Issue1_Description"):
                            description = debrief_attributes["Issue1_Description"]
                        else:
                            description = debrief_attributes["Issue1_Summary"]

                        if debrief_attributes.has_key("Issue1_Priority"):
                            priority = debrief_attributes["Issue1_Priority"]
                        else:
                            priority = "Priority_3"

                        if debrief_attributes.has_key("Issue1_Taskgroup"):
                            component = debrief_attributes["Issue1_Taskgroup"]
                        else:
                            component = ""

                        debrief_key = str(match_id) + "_" + issue_key

                        issue_id = IssueTrackerDataModel.getIssueId(issues_session, issue_base_name)
                        issue = IssueTrackerDataModel.addOrUpdateIssue(
                            issues_session,
                            issue_id,
                            summary,
                            status,
                            priority,
                            subgroup,
                            component,
                            submitter,
                            owner,
                            description,
                            timestamp,
                            debrief_key,
                        )
                        if issue != None:
                            issue.create_file("./static/data/%s/ScoutingData" % competition)
                        DebriefDataModel.addOrUpdateDebriefIssue(
                            debrief_session, match_id, competition, issue_id, issue_key
                        )

                if debrief_attributes.has_key("Issue2_Summary") or debrief_attributes.has_key("Issue2_Description"):
                    # look to see if there is already a debrief issue, and if so, do not attempt to create/update
                    # an issue, as there are already other issue files that would then conflict with this one
                    issue_key = "Issue2"
                    if DebriefDataModel.getDebriefIssue(debrief_session, competition, match_id, issue_key) == None:
                        # if no summary is provided, then use the description as the summary. Likewise, if no description
                        # is provided then use the summary as the description. Keep in mind that we need at least the
                        # summary or description to be provided.
                        if debrief_attributes.has_key("Issue2_Summary"):
                            summary = debrief_attributes["Issue2_Summary"]
                        else:
                            summary = debrief_attributes["Issue2_Description"]
                        if debrief_attributes.has_key("Issue2_Description"):
                            description = debrief_attributes["Issue2_Description"]
                        else:
                            description = debrief_attributes["Issue2_Summary"]

                        if debrief_attributes.has_key("Issue2_Priority"):
                            priority = debrief_attributes["Issue2_Priority"]
                        else:
                            priority = "Priority_3"

                        if debrief_attributes.has_key("Issue2_Taskgroup"):
                            component = debrief_attributes["Issue2_Taskgroup"]
                        else:
                            component = ""

                        debrief_key = str(match_id) + "_" + issue_key

                        issue_id = IssueTrackerDataModel.getIssueId(issues_session, issue_base_name)
                        issue = IssueTrackerDataModel.addOrUpdateIssue(
                            issues_session,
                            issue_id,
                            summary,
                            status,
                            priority,
                            subgroup,
                            component,
                            submitter,
                            owner,
                            description,
                            timestamp,
                            debrief_key,
                        )
                        if issue != None:
                            issue.create_file("./static/data/%s/ScoutingData" % competition)
                        DebriefDataModel.addOrUpdateDebriefIssue(
                            debrief_session, match_id, competition, issue_id, issue_key
                        )

                if debrief_attributes.has_key("Issue3_Summary") or debrief_attributes.has_key("Issue3_Description"):
                    # look to see if there is already a debrief issue, and if so, do not attempt to create/update
                    # an issue, as there are already other issue files that would then conflict with this one
                    issue_key = "Issue3"
                    if DebriefDataModel.getDebriefIssue(debrief_session, competition, match_id, issue_key) == None:
                        # if no summary is provided, then use the description as the summary. Likewise, if no description
                        # is provided then use the summary as the description. Keep in mind that we need at least the
                        # summary or description to be provided.
                        if debrief_attributes.has_key("Issue3_Summary"):
                            summary = debrief_attributes["Issue3_Summary"]
                        else:
                            summary = debrief_attributes["Issue3_Description"]
                        if debrief_attributes.has_key("Issue3_Description"):
                            description = debrief_attributes["Issue3_Description"]
                        else:
                            description = debrief_attributes["Issue3_Summary"]

                        if debrief_attributes.has_key("Issue3_Priority"):
                            priority = debrief_attributes["Issue3_Priority"]
                        else:
                            priority = "Priority_3"

                        if debrief_attributes.has_key("Issue3_Taskgroup"):
                            component = debrief_attributes["Issue3_Taskgroup"]
                        else:
                            component = ""

                        debrief_key = str(match_id) + "_" + issue_key

                        issue_id = IssueTrackerDataModel.getIssueId(issues_session, issue_base_name)
                        issue = IssueTrackerDataModel.addOrUpdateIssue(
                            issues_session,
                            issue_id,
                            summary,
                            status,
                            priority,
                            subgroup,
                            component,
                            submitter,
                            owner,
                            description,
                            timestamp,
                            debrief_key,
                        )
                        if issue != None:
                            issue.create_file("./static/data/%s/ScoutingData" % competition)
                        DebriefDataModel.addOrUpdateDebriefIssue(
                            debrief_session, match_id, competition, issue_id, issue_key
                        )
        except Exception, e:
            # log the exception but continue processing other files
            log_exception(global_config["logger"], e)

        # add the file to the set of processed files so that we don't process it again. Do it outside the
        # try/except block so that we don't try to process a bogus file over and over again.
        DebriefDataModel.addProcessedFile(debrief_session, data_filename)
コード例 #16
0
def get_debrief_page(global_config, competition, match_str, allow_update=False):

    session = DbSession.open_db_session(global_config["debriefs_db_name"] + global_config["this_season"])
    debrief = DebriefDataModel.getDebrief(session, competition, int(match_str))
    debrief_issues = DebriefDataModel.getDebriefIssues(session, competition, int(match_str))
    issues_session = DbSession.open_db_session(global_config["issues_db_name"] + global_config["this_season"])

    if debrief != None:
        result = ""
        result += "<hr>"

        table_str = "<h4>Match Info</h4>"
        table_str += "<ul>"
        table_str += '<table border="1" cellspacing="5">'
        table_str += "<tr>"
        table_str += "<td>Summary</td>"
        table_str += "<td>" + debrief.summary + "</td>"
        table_str += "</tr>"

        table_str += "<tr>"
        table_str += "<td>Description</td>"
        table_str += "<td>" + debrief.description + "</td>"
        table_str += "</tr>"
        table_str += "</table>"
        table_str += "</ul>"

        table_str += "<h4>Reported Issues From Match</h4>"
        table_str += "<ul>"
        table_str += '<table border="1" cellspacing="5">'
        for issue in debrief_issues:
            table_str += "<tr>"
            table_str += "<td>" + issue.priority + "</td>"
            table_str += '<td><a href="/issue/' + str(issue.issue_id) + '">' + str(issue.issue_id) + "</a></td>"
            issue = IssueTrackerDataModel.getIssue(issues_session, issue.issue_id)
            if issue:
                table_str += "<td>" + issue.summary + "</td>"

            table_str += "</tr>"
        table_str += "</table>"
        table_str += "</ul>"

        result += table_str

        result += "<br>"
        result += "<hr>"
        result += '<a href="/debriefcomment/' + competition + "/" + match_str + '"> Comment On This Match</a></td>'
        result += "<br>"
        result += "<hr>"
        result += "<h3>Comments</h3>"

        comments = DebriefDataModel.getDebriefComments(session, competition, int(match_str))
        if len(comments) > 0:
            table_str = "<ul>"
            table_str += '<table border="1" cellspacing="5">'
            table_str += "<tr>"
            table_str += "<th>Timestamp</th>"
            table_str += "<th>Commented By</th>"
            table_str += "<th>Comment</th>"
            if allow_update == True:
                table_str += "<th>Delete</th>"
            table_str += "</tr>"
            for comment in comments:
                table_str += "<tr>"
                table_str += (
                    "<td>" + time.strftime("%b %d, %Y %I:%M:%S %p", time.localtime(float(comment.tag))) + "</td>"
                )
                table_str += "<td>" + comment.submitter + "</td>"
                table_str += "<td>" + comment.data + "</td>"
                if allow_update == True:
                    table_str += (
                        '<td><a href="/deletecomment/debrief/'
                        + competition
                        + "/"
                        + match_str
                        + "/"
                        + comment.tag
                        + '">Delete</a></td>'
                    )
                table_str += "</tr>"
            table_str += "</table>"
            table_str += "</ul>"

            result += table_str
        result += "<hr>"

        return result
    else:
        return None