def album_data(): try: cwd = os.getcwd() coverart = cwd + '/coverart' f=open(coverart) coverart = f.readline() file = cStringIO.StringIO(urllib.urlopen(coverart).read()) img = pygame.image.load(file) screen.blit(pygame.transform.scale(img, (200, 200)), (140, 112)) pygame.draw.rect(screen, black, [ 4, 4, 480, 100]) make_label(song(),4,2,32,music_data_color) make_label(artist(),4,28,32,music_data_color) make_label(album(),4,52,32,music_data_color) make_label(station(),4,76,32,music_data_color) pygame.display.update() except IOError: pass
def parse_the_file(station_file): try: make_message('\tParsing %s' % basename(station_file), 2) year = basename(dirname(station_file)) output_dir = join(settings.out_dir, year) if not exists(output_dir): makedirs(output_dir) s = station(station_file) s.output_location = output_dir s.formats = settings.formats s.unzip() s.filter(settings.timestamp) s.export() make_message('\t\tDone...', 2) except IOError, e: make_message(e, 5)
import time import random """ this is the actual implementation of the network """ #the probability for a station to send his package SENT_PROB = 0.5 #initialize all the workstations stations = [ station.station(5,i) for i in range(8)] def auxiliary(): """ function that does nothing,to be passed to the timer """ pass def packagecreation(stations,probability,slot): """ function that handles the creation of the packages at each time slot """ for station in stations : station.createpack(probability,slot)