Commit 673f87f6 authored by Jonathan Carter's avatar Jonathan Carter
Browse files

Yay it works

parent 5b566fbd
......@@ -3,6 +3,8 @@
import sys
import pygame
import time
from subprocess import run
import os
pygame.init()
pygame.font.init()
......@@ -31,6 +33,8 @@ screen.fill(grey)
# Load images
usbimg = pygame.image.load('usb.png')
logoimg = pygame.image.load('aims-desktop.png')
def clear_screen():
screen.fill(grey)
......@@ -42,7 +46,8 @@ def drawcard_intro():
titlefont = pygame.font.SysFont("Cantarell Extra Bold", 120)
label = titlefont.render("AIMS Desktop", 1, (255, 255, 255))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 105))
screen.blit(label, text_rect)
img_rect = logoimg.get_rect(center=(SCREEN_WIDTH/2, 105))
screen.blit(logoimg, img_rect)
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("This tool will check the integrity of files on this installation media.",
......@@ -61,13 +66,144 @@ def drawcard_intro():
pygame.display.flip()
def drawcard_offair():
def drawcard_letswork():
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if (event.key == pygame.K_ESCAPE):
print("Escape pressed, exiting...")
drawcard_bye()
sys.exit()
clear_screen()
pygame.draw.rect(screen, (40, 80, 80), (50, 50, SCREEN_WIDTH-110, 110))
myfont = pygame.font.SysFont("Cantarell Extra Bold", 120)
label = myfont.render("Testing media", 1, (255, 255, 255))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 105))
screen.blit(label, text_rect)
pygame.display.flip()
md5sums = [line.rstrip('\n') for line in open('md5sum.txt')]
md5sum_count = (len(md5sums))
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("Found %s checksums that need to be checked." % md5sum_count,
1, (200, 200, 200))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 240))
screen.blit(label, text_rect)
pygame.display.flip()
time.sleep(2)
checked_count = 0
for entry in md5sums:
checked_count = checked_count + 1
checksum = entry.split(' ')[0]
filename = entry.split(' ')[2]
checkedsum = os.popen('md5sum ' + filename).read()
print(checkedsum.split(' ')[0])
if checksum == checkedsum.split(' ')[0]:
print("Checksum for file %s passed" % filename)
else:
print("Checksum for file %s failed" % filename)
drawcard_report(filename)
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("%s files left to check...." % str(md5sum_count-checked_count) ,
1, (200, 200, 200))
phonylabel = textfont.render("9999 files left to check...." ,
1, (200, 200, 200))
text_rect = phonylabel.get_rect(center=(SCREEN_WIDTH/2, 340))
pygame.draw.rect(screen, (grey), phonylabel.get_rect(center=(SCREEN_WIDTH/2, 340)))
screen.blit(label, text_rect)
pygame.display.flip()
if checked_count == md5sum_count:
time.sleep(1)
print("we're done!")
drawcard_report('success')
def drawcard_bye():
clear_screen()
pygame.draw.rect(screen, (40, 200, 200), (50, 50, 700, 110))
pygame.draw.rect(screen, (180, 38, 34), (50, 50, SCREEN_WIDTH-110, 110))
myfont = pygame.font.SysFont("Cantarell Extra Bold", 120)
label = myfont.render("TESTING", 1, (255, 255, 255))
screen.blit(label, (225, 60))
label = myfont.render("Good bye!", 1, (255, 255, 255))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 105))
screen.blit(label, text_rect)
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("Rebooting...",
1, (200, 200, 200))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, SCREEN_HEIGHT/2))
screen.blit(label, text_rect)
pygame.display.flip()
time.sleep(1)
def drawcard_report(status):
clear_screen()
if status == "success":
pygame.draw.rect(screen, (40, 100, 100), (50, 50, SCREEN_WIDTH-110, 110))
myfont = pygame.font.SysFont("Cantarell Extra Bold", 120)
label = myfont.render("Report: Success", 1, (255, 255, 255))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 105))
screen.blit(label, text_rect)
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("Good news! Your installation media is in good shape.",
1, (200, 200, 200))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 340))
screen.blit(label, text_rect)
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("Press any key to reboot.",
1, (200, 200, 200))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 440))
screen.blit(label, text_rect)
pygame.display.flip()
else:
print("Failed: " + status)
pygame.draw.rect(screen, (220, 100, 100), (50, 50, SCREEN_WIDTH-110, 110))
myfont = pygame.font.SysFont("Cantarell Extra Bold", 120)
label = myfont.render("Report: Failure", 1, (255, 255, 255))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 105))
screen.blit(label, text_rect)
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("Unfortunately, the recorded checksums didn't match what's on this media.",
1, (200, 200, 200))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 240))
screen.blit(label, text_rect)
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("Verify your download or try another disk.",
1, (200, 200, 200))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 340))
screen.blit(label, text_rect)
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("For help, visit https://desktop.aims.ac.za",
1, (200, 200, 200))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 440))
screen.blit(label, text_rect)
textfont = pygame.font.SysFont("Cantarell Bold", 40)
label = textfont.render("Press any key to reboot...",
1, (200, 200, 200))
text_rect = label.get_rect(center=(SCREEN_WIDTH/2, 540))
screen.blit(label, text_rect)
screen.blit(label, text_rect)
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
drawcard_bye()
sys.exit()
while True:
......@@ -75,7 +211,12 @@ while True:
if event.type == pygame.KEYDOWN:
if (event.key == pygame.K_ESCAPE):
print("Escape pressed, exiting...")
drawcard_bye()
sys.exit()
if (event.key == pygame.K_SPACE):
print("Space pressed, let's draw work card...")
drawcard_letswork()
if event.type == pygame.QUIT:
sys.exit()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment