def get_previous_game_logs(url):
    """
	Get previous game logs of a certain player. 
	"""
    existing_names = helper.check_existing_csv()
    try:
        html_file = urlopen(url)
    except:
        print "Game log url does not exist. Skipping this player."
        return None
    soup = BeautifulSoup(html_file)
    player_name = soup.find_all("h1")[0].text
    if player_name in existing_names:
        print "Skipping players that were scraped."
        return None
    games = soup.find_all("tr")
    team = helper.get_team(soup)
    logs = []
    for game in games:
        raw_texts = game.find_all("td")
        if helper.validate_texts(str(raw_texts[0])):
            game_date = helper.get_date(str(raw_texts[0]))
            opponent, minutes, fgm, fga, fgp, tpm, tpa, tpp, ftm, fta, ftp, reb, ast, blk, stl, foul, turnover, pts = helper.format_data(
                raw_texts)
            log = Log(player_name, game_date, team, opponent, minutes, fgm,
                      fga, fgp, tpm, tpa, tpp, ftm, fta, ftp, reb, ast, blk,
                      stl, foul, turnover, pts)
            print game_date, player_name, team
            logs.append(log)
    return logs
def update_game_logs(url):
    """
	Update game logs of a certain player. 
	For prototype let's use Isaiah Thomas as an example. 
	"""
    # Check date to make sure because we're only getting
    # the lateest game.
    today_date = date.today()
    try:
        html_file = urlopen(url)
    except:
        print "Game log url does not exist. Skipping this player.", url
        return None
    soup = BeautifulSoup(html_file)
    player_name = soup.find_all("h1")[0].text
    team = helper.get_team(soup)
    # The 6th (counting from 1) tr element in the html texts
    # is the latest_game.
    latest_game = soup.find_all("tr")[5]
    raw_texts = latest_game.find_all("td")
    game_date_str = helper.get_date(str(raw_texts[0]))
    year, month, day = game_date_str.split("-")
    ONE_DAY = timedelta(1)
    # Transforming the scraped date into an date object.
    game_date = date(int(year), int(month), int(day))
    # On account of me being in China which is a day ahead of US time.
    if today_date - game_date == ONE_DAY:
        opponent, minutes, fgm, fga, fgp, tpm, tpa, tpp, ftm, fta, ftp, reb, ast, blk, stl, foul, turnover, pts = helper.format_data(
            raw_texts)
        log = Log(player_name, game_date, team, opponent, minutes, fgm, fga,
                  fgp, tpm, tpa, tpp, ftm, fta, ftp, reb, ast, blk, stl, foul,
                  turnover, pts)
        print game_date, player_name, team
        return log
def update_game_logs(url):
	"""
	Update game logs of a certain player. 
	For prototype let's use Isaiah Thomas as an example. 
	"""
	# Check date to make sure because we're only getting 
	# the lateest game. 
	today_date = date.today()
	try:
		html_file = urlopen(url)
	except: 
		print "Game log url does not exist. Skipping this player.", url
		return None
	soup = BeautifulSoup(html_file)
	player_name = soup.find_all("h1")[0].text
	team = helper.get_team(soup)
	# The 6th (counting from 1) tr element in the html texts 
	# is the latest_game.
	latest_game = soup.find_all("tr")[5]
	raw_texts = latest_game.find_all("td")
	game_date_str = helper.get_date(str(raw_texts[0]))
	year, month, day = game_date_str.split("-")
	ONE_DAY = timedelta(1)
	# Transforming the scraped date into an date object. 
	game_date = date(int(year), int(month), int(day))
	# On account of me being in China which is a day ahead of US time.
	if today_date - game_date == ONE_DAY:
		opponent, minutes, fgm, fga, fgp, tpm, tpa, tpp, ftm, fta, ftp, reb, ast, blk, stl, foul, turnover, pts = helper.format_data(raw_texts)
		log = Log(player_name, game_date, team, opponent, minutes, fgm, fga, fgp, tpm, tpa, tpp, 
						ftm, fta, ftp, reb, ast, blk, stl, foul, turnover, pts)
		print game_date, player_name, team
		return log 
def get_previous_game_logs(url):
	"""
	Get previous game logs of a certain player. 
	"""
	existing_names = helper.check_existing_csv()
	try:
		html_file = urlopen(url)
	except: 
		print "Game log url does not exist. Skipping this player."
		return None
	soup = BeautifulSoup(html_file)
	player_name = soup.find_all("h1")[0].text
	if player_name in existing_names:
		print "Skipping players that were scraped."
		return None
	games = soup.find_all("tr")
	team = helper.get_team(soup)
	logs = []
	for game in games:
		raw_texts = game.find_all("td")
		if helper.validate_texts(str(raw_texts[0])):
			game_date = helper.get_date(str(raw_texts[0])) 
			opponent, minutes, fgm, fga, fgp, tpm, tpa, tpp, ftm, fta, ftp, reb, ast, blk, stl, foul, turnover, pts = helper.format_data(raw_texts)
			log = Log(player_name, game_date, team, opponent, minutes, fgm, fga, fgp, tpm, tpa, tpp, 
							ftm, fta, ftp, reb, ast, blk, stl, foul, turnover, pts)
			print game_date, player_name, team
			logs.append(log)
	return logs
Beispiel #5
0
    def __init__(self, device):
        self.type = get_string(device.DeviceTypeID)
        self.id = get_string(device.DeviceIdentifier)
        self.serial = get_string(device.DeviceSerial)

        self.manufacturer_id = None
        if device.ManufacturerID:
            self.manufacturer_id = device.ManufacturerID.get_text().split(
                u":", 2)[2]
        self.manufacturer_name = get_string(device.ManufacturerName)

        self.model_number = get_string(device.ModelNumber)
        self.install_date = get_datetime(device.InstallDate)
        self.resolution = get_string(device.Resolution)
        self.active = get_boolean(device.IsActive)

        self.integrator = get_string(device.Integrator)
        self.vpf_finance_entity = get_string(device.VPFFinanceEntity)
        self.vpf_start_date = None
        if device.VPFStartDate:
            self.vpf_start_date = get_date(device.VPFStartDate)

        self.ip_addresses = []
        if device.IPAddressList:
            self.ip_addresses = [
                IPAddress(ip_address)
                for ip_address in device.IPAddressList(u"IPAddress")
            ]

        self.software = []
        if device.SoftwareList:
            self.software = [
                Software(program)
                for program in device.SoftwareList(u"Software")
            ]

        self.certificates = []
        if device.KeyInfoList:
            self.certificates = [
                Certificate(certificate)
                for certificate in device.KeyInfoList(u"X509Data")
            ]

        self.watermarking = []
        if device.WatermarkingList:
            self.watermarking = [
                Watermarking(watermark)
                for watermark in device.WatermarkingList(u"Watermarking")
            ]

        self.kdm_deliveries = deliveries(device.KDMDeliveryMethodList)
        self.dcp_deliveries = deliveries(device.DCPDeliveryMethodList)
Beispiel #6
0
def show_ratings_no_picture(request, challenge_type='Development', date=datetime.date.today()):
    date = helper.get_date(date)
    helper.get_members_result(challenge_type=challenge_type)
    members = Member.objects.filter(date=date, challenge_type=challenge_type).order_by('-mu', '-sigma')
    data = {
        "contestType": challenge_type,
        "updated_on": date,
        "text_updated_date": date.isoformat(),
        "base_url": "http://" + request.get_host(),
        "google_plus_url": "http://" + request.get_host() + "/ratings/" + challenge_type + "/" + date.isoformat()
    }
    context = {"members": members, "data": data}
    #return HttpResponse("Working")
    return render(request, 'ranktc/view_rankings.html', context)
Beispiel #7
0
def show_ratings(request, challenge_type=None, date=datetime.date.today()):
    date = helper.get_date(date)
    if not challenge_type:
        challenge_type = 'Development'
    #today = datetime.date.today()
    response = show_ratings_no_picture(request, date=date, challenge_type=challenge_type)
    m = models.RatingsPicture.objects.filter(date=date, challenge_type=challenge_type)

    base_url = "http://" + request.get_host()

    if m.count() > 0 and not m[0].picture_done:
        cmd = ['webkit2png',
               '-o', settings.RATING_IMG + "/" + challenge_type + "_" + date.isoformat()
               ,base_url + '/ratings_no_picture/' + challenge_type + "/" + date.isoformat()]
        subprocess.Popen(cmd)
        #subprocess.Popen(cmd).wait()

    return response
Beispiel #8
0
    def __init__(self, device):
        self.type = get_string(device.DeviceTypeID)
        self.id = get_string(device.DeviceIdentifier)
        self.serial = get_string(device.DeviceSerial)

        self.manufacturer_id = None
        if device.ManufacturerID:
            self.manufacturer_id = device.ManufacturerID.get_text().split(u":", 2)[2]
        self.manufacturer_name = get_string(device.ManufacturerName)

        self.model_number = get_string(device.ModelNumber)
        self.install_date = get_datetime(device.InstallDate)
        self.resolution = get_string(device.Resolution)
        self.active = get_boolean(device.IsActive)

        self.integrator = get_string(device.Integrator)
        self.vpf_finance_entity = get_string(device.VPFFinanceEntity)
        self.vpf_start_date = None
        if device.VPFStartDate:
            self.vpf_start_date = get_date(device.VPFStartDate)

        self.ip_addresses = []
        if device.IPAddressList:
            self.ip_addresses = [IPAddress(ip_address) for ip_address in device.IPAddressList(u"IPAddress")]

        self.software = []
        if device.SoftwareList:
            self.software = [Software(program) for program in device.SoftwareList(u"Software")]

        self.certificates = []
        if device.KeyInfoList:
            self.certificates = [Certificate(certificate) for certificate in device.KeyInfoList(u"X509Data")]

        self.watermarking = []
        if device.WatermarkingList:
            self.watermarking = [Watermarking(watermark) for watermark in device.WatermarkingList(u"Watermarking")]

        self.kdm_deliveries = deliveries(device.KDMDeliveryMethodList)
        self.dcp_deliveries = deliveries(device.DCPDeliveryMethodList)
Beispiel #9
0
def show_old_ratings(request, challenge_type, date):
    date = helper.get_date(date)
    return show_ratings(request, date=date, challenge_type=challenge_type)