本文整理汇总了Python中DataModel.setTeamScore方法的典型用法代码示例。如果您正苦于以下问题:Python DataModel.setTeamScore方法的具体用法?Python DataModel.setTeamScore怎么用?Python DataModel.setTeamScore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataModel
的用法示例。
在下文中一共展示了DataModel.setTeamScore方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_file_data
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import setTeamScore [as 别名]
def remove_file_data(global_config, session, attr_definitions, data_filename, remove_from_processed_files=False):
print 'removing data file: %s'%data_filename
competition = global_config['this_competition'] + global_config['this_season']
input_dir = './static/data/' + competition + '/ScoutingData/'
filepath = input_dir+data_filename
# Initialize the file_attributes dictionary in preparation for the
# parsing of the data file
file_attributes = {}
# Parse the data file, removing all the information in the file_attributes
# dictionary
try:
FileParser.FileParser(filepath).parse(file_attributes)
except:
raise ValueError('Error Opening File')
# The team number can be retrieved from the Team attribute, one of the
# mandatory attributes within the data file
team = file_attributes['Team']
# Also, extract the competition name, too, if it has been included in
# the data file
if file_attributes.has_key('Competition'):
competition = file_attributes['Competition']
else:
competition = global_config['this_competition'] + global_config['this_season']
if competition == None:
raise Exception( 'Competition Not Specified!')
# Loop through the attributes from the data file and post them to the
# database
for attribute, value in file_attributes.iteritems():
if value is None:
value = ''
attr_definition = attr_definitions.get_definition(attribute)
if attr_definition == None:
raise ValueError( 'No Attribute Defined For Attribute: %s' % attribute )
elif attr_definition['Database_Store']=='Yes':
DataModel.deleteAttributeValue(session, team, competition, attribute, value, attr_definition, no_throw=True)
if remove_from_processed_files:
DataModel.deleteProcessedFile(session, filepath)
score = DataModel.calculateTeamScore(session, team, competition, attr_definitions)
DataModel.setTeamScore(session, team, competition, score)
示例2: process_file
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import setTeamScore [as 别名]
def process_file(session, attr_definitions, data_filename):
print 'processing %s'%data_filename
# Initialize the file_attributes dictionary in preparation for the
# parsing of the data file
file_attributes = {}
# Parse the data file, storing all the information in the file_attributes
# dictionary
FileParser.FileParser(data_filename).parse(file_attributes)
# The team number can be retrieved from the Team attribute, one of the
# mandatory attributes within the data file
team = file_attributes['Team']
# Also, extract the competition name, too, if it has been included in
# the data file
if file_attributes.has_key('Competition'):
competition = file_attributes['Competition']
else:
competition = global_config['this_competition'] + global_config['this_season']
if competition == None:
raise Exception( 'Competition Not Specified!')
DataModel.addTeamToEvent(session, team, competition)
if file_attributes.has_key('Scouter'):
scouter = file_attributes['Scouter']
else:
scouter = 'Unknown'
if file_attributes.has_key('Match'):
category = 'Match'
else:
if '_Pit_' in data_filename:
category = 'Pit'
else:
category = 'Other'
# Loop through the attributes from the data file and post them to the
# database
for attribute, value in file_attributes.iteritems():
if value is None:
value = ''
try:
attr_definition = attr_definitions.get_definition(attribute)
if attr_definition == None:
err_str = 'ERROR: No Attribute Defined For Attribute: %s' % attribute
print err_str
elif attr_definition['Database_Store']=='Yes':
try:
DataModel.createOrUpdateAttribute(session, team, competition, category, attribute, value, attr_definition)
except Exception, exception:
traceback.print_exc(file=sys.stdout)
exc_type, exc_value, exc_traceback = sys.exc_info()
exception_info = traceback.format_exception(exc_type, exc_value,exc_traceback)
for line in exception_info:
line = line.replace('\n','')
global_config['logger'].debug(line)
except Exception:
err_str = 'ERROR: Attribute Could Not Be Processed: %s' % attribute
traceback.print_exc(file=sys.stdout)
exc_type, exc_value, exc_traceback = sys.exc_info()
exception_info = traceback.format_exception(exc_type, exc_value,exc_traceback)
for line in exception_info:
line = line.replace('\n','')
global_config['logger'].debug(line)
print err_str
if category == 'Match':
try:
match = file_attributes['Match']
DataModel.createOrUpdateMatchDataAttribute(session, team, competition, match, scouter, attribute, value)
except:
err_str = 'ERROR: Match Data Attribute Could Not Be Processed: %s' % attribute
traceback.print_exc(file=sys.stdout)
exc_type, exc_value, exc_traceback = sys.exc_info()
exception_info = traceback.format_exception(exc_type, exc_value,exc_traceback)
for line in exception_info:
line = line.replace('\n','')
global_config['logger'].debug(line)
print err_str
score = DataModel.calculateTeamScore(session, team, competition, attr_definitions)
DataModel.setTeamScore(session, team, competition, score)
示例3: process_issue_files
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import setTeamScore [as 别名]
data = sys.stdin.readlines()
if options.processissues:
# process any accumulated issues files
process_issue_files(global_config, input_dir, options.recursive, options.test)
# recalculate the team scores
if options.recalculate:
competition = global_config['this_competition'] + global_config['this_season']
if competition == None:
raise Exception( 'Competition Not Specified!')
team_rankings = DataModel.getTeamsInRankOrder(session, competition)
for team_entry in team_rankings:
score = DataModel.calculateTeamScore(session, team_entry.team, competition, attr_definitions)
DataModel.setTeamScore(session, team_entry.team, competition, score)
session.commit()
dump_database_as_csv_file(session, attr_definitions, competition)
if options.bluetoothServer:
server_sock=BluetoothSocket( RFCOMM )
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)
port = server_sock.getsockname()[1]
uuid = "00001073-0000-1000-8000-00805F9B34F7"
advertise_service( server_sock, "TTTService",
service_id = uuid,
service_classes = [ uuid, SERIAL_PORT_CLASS ],
示例4: remove_json_file_data
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import setTeamScore [as 别名]
def remove_json_file_data(global_config, request_path):
# Initialize the database session connection
db_name = global_config['db_name'] + global_config['this_season']
session = DbSession.open_db_session(db_name)
if request_path.startswith('static'):
fullpath = './' + request_path
if os.path.exists(fullpath) is False:
return
competition = request_path.split('/')[2]
print 'Removing scouting data from JSON file: %s' % fullpath
filename = fullpath.split('/')[-1]
with open(fullpath) as fd:
scouting_data = json.load(fd)
if filename.startswith('Match'):
team = scouting_data['Setup'].get('Team')
elif filename.startswith('Pit'):
team = scouting_data['Pit'].get('Team')
if team is not None and len(team) > 0:
attr_definitions = AttributeDefinitions.AttrDefinitions(global_config)
for section_name, section_data in scouting_data.iteritems():
if isinstance(section_data,dict):
for attr_name, attr_value in section_data.iteritems():
# use the attribute definitions to control whether information gets
# stored to the database rather than the hard coded stuff here.
# also need to consider the section/category name as the attributes
# and definitions are processed
# don't store the team number in the database
if attr_name == 'Team':
continue
# augment the attribute name with the section name in order to make the attribute
# unique
attr_name = '%s:%s' % (section_name, attr_name)
attribute_def = {}
attribute_def['Name'] = attr_name
if attr_value.isdigit():
attribute_def['Type'] = 'Integer'
attribute_def['Weight'] = 1.0
else:
attribute_def['Type'] = 'String'
attribute_def['Weight'] = 0.0
attribute_def['Statistic_Type'] = 'Average'
attr_definitions.add_definition(attribute_def)
category = 'Match'
try:
DataModel.deleteAttributeValue(session, int(team), competition,
attr_name, attr_value, attribute_def)
except Exception, exception:
traceback.print_exc(file=sys.stdout)
exc_type, exc_value, exc_traceback = sys.exc_info()
exception_info = traceback.format_exception(exc_type, exc_value,exc_traceback)
for line in exception_info:
line = line.replace('\n','')
global_config['logger'].debug(line)
else:
print 'Unexpected entry in scouting data file, name: %s, value: %s' % (section_name,section_data)
score = DataModel.calculateTeamScore(session, int(team), competition, attr_definitions)
DataModel.setTeamScore(session, int(team), competition, score)
session.commit()
示例5: process_json_files
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import setTeamScore [as 别名]
#.........这里部分代码省略.........
# don't store the team number in the database
if attr_name == 'Team':
continue
# augment the attribute name with the section name in order to make the attribute
# unique
attr_name = '%s:%s' % (section_name, attr_name)
attribute_def = {}
attribute_def['Name'] = attr_name
if attr_value.isdigit():
attribute_def['Type'] = 'Integer'
attribute_def['Weight'] = 1.0
else:
attribute_def['Type'] = 'String'
attribute_def['Weight'] = 0.0
attribute_def['Statistic_Type'] = 'Average'
attr_definitions.add_definition(attribute_def)
try:
DataModel.createOrUpdateAttribute(session, int(team), competition, category,
attr_name, attr_value, attribute_def)
except Exception, exception:
traceback.print_exc(file=sys.stdout)
exc_type, exc_value, exc_traceback = sys.exc_info()
exception_info = traceback.format_exception(exc_type, exc_value,exc_traceback)
for line in exception_info:
line = line.replace('\n','')
global_config['logger'].debug(line)
else:
print 'Unexpected entry in scouting data file, name: %s, value: %s' % (section_name,section_data)
score = DataModel.calculateTeamScore(session, int(team), competition, attr_definitions)
DataModel.setTeamScore(session, int(team), competition, score)
session.commit()
# ######################################################### #
# Google spreadsheet update
if google_intf_ctrl == 'Enabled':
row_data = []
for section_name, section_data in scouting_data.iteritems():
if isinstance(section_data,dict):
for attr_name, attr_value in section_data.iteritems():
# augment the attribute name with the section name in order to make the attribute
# unique
attr_name = '%s_%s' % (section_name, attr_name)
row_data.append((attr_name,attr_value))
else:
print 'Unexpected entry in scouting data file, name: %s, value: %s' % (section_name,section_data)
sheet_name = '%s_%s_Data' % (competition,category)
GoogleSheetsIntf.add_scouting_data_row( sheet_name, row_data )
# ######################################################### #
# ######################################################### #
'''
# ######################################################### #
# store the scouting data to a local dictionary
team_data = event_scouting_data.get(team)
if team_data is None:
team_data = { 'Summary': {}, 'MatchData': [] }
event_scouting_data[team] = team_data
示例6: process_file
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import setTeamScore [as 别名]
def process_file(global_config, session, attr_definitions, data_filename):
print "processing %s" % data_filename
# Initialize the file_attributes dictionary in preparation for the
# parsing of the data file
file_attributes = {}
# Parse the data file, storing all the information in the file_attributes
# dictionary
FileParser.FileParser(data_filename).parse(file_attributes)
# The team number can be retrieved from the Team attribute, one of the
# mandatory attributes within the data file
team = file_attributes["Team"]
# Also, extract the competition name, too, if it has been included in
# the data file
if file_attributes.has_key("Competition"):
# check if the global_config indicates that we're working with the 2014-era tablet UI that may not
# format the competition string as we expect it to be. If we are in 'legacy' mode, then ignore the
# competition setting in the file and apply the competition/season from the config
if global_config.has_key("legacy_tablet_ui") and global_config["legacy_tablet_ui"].lower() == "yes":
competition = global_config["this_competition"] + global_config["this_season"]
else:
competition = file_attributes["Competition"]
else:
# if no competition setting attribute is in the file, then apply the competition/season from the config
competition = global_config["this_competition"] + global_config["this_season"]
if competition == None:
raise Exception("Competition Not Specified!")
DataModel.addTeamToEvent(session, team, competition)
if file_attributes.has_key("Scouter"):
scouter = file_attributes["Scouter"]
else:
scouter = "Unknown"
if "_Match" in data_filename:
category = "Match"
if not file_attributes.has_key("Match"):
file_attributes["Match"] = "0"
elif "_Pit_" in data_filename:
category = "Pit"
else:
category = "Other"
# Loop through the attributes from the data file and post them to the
# database
for attribute, value in file_attributes.iteritems():
if value is None:
value = ""
try:
attr_definition = attr_definitions.get_definition(attribute)
if attr_definition == None:
err_str = "ERROR: No Attribute Defined For Attribute: %s" % attribute
print err_str
elif attr_definition["Database_Store"] == "Yes":
try:
DataModel.createOrUpdateAttribute(
session, team, competition, category, attribute, value, attr_definition
)
except Exception, exception:
traceback.print_exc(file=sys.stdout)
exc_type, exc_value, exc_traceback = sys.exc_info()
exception_info = traceback.format_exception(exc_type, exc_value, exc_traceback)
for line in exception_info:
line = line.replace("\n", "")
global_config["logger"].debug(line)
except Exception:
err_str = "ERROR: Attribute Could Not Be Processed: %s" % attribute
traceback.print_exc(file=sys.stdout)
exc_type, exc_value, exc_traceback = sys.exc_info()
exception_info = traceback.format_exception(exc_type, exc_value, exc_traceback)
for line in exception_info:
line = line.replace("\n", "")
global_config["logger"].debug(line)
print err_str
if category == "Match":
try:
match = file_attributes["Match"]
DataModel.createOrUpdateMatchDataAttribute(session, team, competition, match, scouter, attribute, value)
except:
err_str = "ERROR: Match Data Attribute Could Not Be Processed: %s" % attribute
traceback.print_exc(file=sys.stdout)
exc_type, exc_value, exc_traceback = sys.exc_info()
exception_info = traceback.format_exception(exc_type, exc_value, exc_traceback)
for line in exception_info:
line = line.replace("\n", "")
global_config["logger"].debug(line)
print err_str
score = DataModel.calculateTeamScore(session, team, competition, attr_definitions)
DataModel.setTeamScore(session, team, competition, score)