예제 #1
0
 def __init__(self, *cat_args):
     super(SolarSystem, self).__init__()
     self.the_sun = LikeFile(make_cat(*cat_args),
                             extrainboxes=("translation", "imaging"))
     self.the_sun.activate()
     self.planet = LikeFile(make_cat(*cat_args),
                            extrainboxes=("translation", "rotator",
                                          "imaging"))
     self.planet.activate()
     self.sun_position = tuple([x / 2 for x in screensize])
     self.planet_position = (screensize[0] / 4.0, screensize[1] / 2)
     self.planet_velocity = (0.0, 10)
예제 #2
0
 def test_badboxuse(self):
     """test that IO on a box name that doesn't exist will fail."""
     component = LikeFile(DyingShunt())
     component.activate()
     self.failUnlessRaises(KeyError, component.put, "boo",
                           "nonsensesendbox")
     self.failUnlessRaises(KeyError, component.get, "nonsensesendbox")
     component.shutdown()
예제 #3
0
 def test_nop(self):
     """Test that creating, activating, and deleting a wrapped component doesn't fail."""
     self.component = LikeFile(DyingShunt())
     self.component.activate()
     time.sleep(
         0.25
     )  # I think this might be a threading issue - the instant shutdown is not being processed.
     self.component.shutdown()
     del self.component
예제 #4
0
 def test_closed(self):
     """test that creating, activating, and then closing a likefile wrapper will result in an object you're not
     allowed to perform IO on."""
     component = LikeFile(DyingShunt())
     component.activate()
     time.sleep(0.1)
     component.shutdown()
     time.sleep(0.1)
     self.failUnlessRaises(AttributeError, component.get)
     self.failUnlessRaises(AttributeError, component.put, "boo")
예제 #5
0
 def testmany(self):
     compdict = dict()
     for i in xrange(1, 50):  # test 100 concurrent likefiles.
         compdict[i] = LikeFile(DyingShunt(),
                                extraInboxes="extrain",
                                extraOutboxes="extraout")
         compdict[i].activate()
     time.sleep(0.1)
     for num, component in compdict.iteritems():
         for i in randlist:
             # i is a random integer between 0 and 1, so the following manipulations guarantee that each box on each
             # component gets a different number, to eliminate crosstalk passing a test.
             component.put(num + i, "inbox")
             component.put(num + i % 0.5, "control")
             component.put(num + i % 0.25, "extrain")
     for num, component in compdict.iteritems():
         for i in randlist:
             self.failUnless(component.get("outbox") == num + i)
             self.failUnless(component.get("signal") == num + i % 0.5)
             self.failUnless(component.get("extraout") == num + i % 0.25)
     for component in compdict.itervalues():
         component.shutdown()
예제 #6
0
            files.append(x)

    image_location = files[random.randint(0,len(files)-1)]

    cat_surface = pygame.image.load("pictures/"+image_location)
    cat = cat_surface.convert()
    cat.set_colorkey((255,255,255), pygame.RLEACCEL)

    newCat = CatSprite(image=cat)
    return newCat

cat_args = (cat_location, screensize, border)
spritescheduler = SpriteScheduler(cat_args, [], background, screen_surface, MyGamesEvents).activate()

newcat = make_cat(*cat_args)
the_sun = LikeFile(make_cat(*cat_args), extrainboxes = ("translation", "imaging"))
the_sun.activate()

planet = LikeFile(make_cat(*cat_args), extrainboxes = ("translation", "rotator", "imaging"))
planet.activate()
sun_position = tuple([x/2 for x in screensize])

planet_position = (screensize[0]/4.0, screensize[1]/2)
planet_velocity = (0.0, 10)


# ugh, I should be using numpy but it works, that's the important thing
# This is merely a test of likefile. Really, kamaelia components should be written for a physics simulation like this.

def acceleration(pos_planet, pos_sun):
    g = 200 # fudge factor
예제 #7
0
 def test_aborted(self):
     """test that creating but not activating a likefile wrapper doesn't leave any cruft in the scheduler,
     and that you can't perform IO on a pre-activated component."""
     component = LikeFile(DyingShunt())
     self.failUnlessRaises(AttributeError, component.get)
     self.failUnlessRaises(AttributeError, component.put, "boo")