def ec2bootstrap(): """ Install chef and use it to fully install the application on an Amazon EC2 instance. """ # Fire up a new server id, host = createserver() # Add the new server's host name to the configuration file config = yaml.load(open('./config.yml', 'rb')) config['EC2_HOST'] = str(host) config_file = open('./config.yml', 'w') config_file.write(yaml.dump(config, default_flow_style=False)) config_file.close() print "- Waiting 60 seconds before logging in to configure machine" time.sleep(60) rendernodejson() # Install chef and run it installchef() cook() # Fire up the Django project migrate() collectstatic() # Done deal print(green("Success!")) print "Visit the app at %s" % host
def deploy(): """Run deployment tasks.""" from flask_migrate import upgrade, init, migrate # migrate database to latest revision init() migrate() upgrade()
def setUp(self): super(AppNpcTestCase, self).setUp() users = { 'player': ['player'], 'author': ['dm'], 'dm': ['dm'], } self.users = {} for name, role in list(users.items()): self.users[name] = self.createUser({ 'username': name, 'password': name, 'email': name + '@example.com', 'role': role, }) self.users[name]['password'] = name self.campaign = self.createCampaign({ 'name': 'Test', 'user_id': self.users['author']['id'], }) npcs = { 'generic': { 'name': 'John Doe', 'user_id': self.users['dm']['id'], 'size': 'small', }, 'specific': { 'name': 'Ortant Quessgi\'ver', 'race': 'Imp', 'user_id': self.users['author']['id'], 'campaign_id': self.campaign['id'], 'size': 'small', }, } self.npcs = {} for name, npc in npcs.items(): self.npcs[name] = self.createNpc(npc) migrate(self.app, ['npc']) genericId = self.npcs['generic']['id'] self.dmPages = { '/npc/list': (200, 'text/html'), '/npc/races/api': (200, 'application/json'), '/npc/classes/api': (200, 'application/json'), '/npc/api': (200, 'application/json'), '/npc/show/%d' % genericId: (200, 'text/html'), '/npc/api/%d' % genericId: (200, 'application/json'), '/npc/new': (200, 'text/html'), '/npc/edit/%d' % genericId: (200, 'text/html'), '/npc/copy/%d' % genericId: (302, None), } specificId = self.npcs['specific']['id'] self.authorPages = { '/npc/api/%d' % specificId: (200, 'application/json'), '/npc/copy/%d' % specificId: (302, None), }
def setUp(self): super(AppMonsterTestCase, self).setUp() users = { 'player': ['player'], 'author': ['dm'], 'dm': ['dm'], } self.users = {} for name, role in list(users.items()): self.users[name] = self.createUser({ 'username': name, 'password': name, 'email': name + '@example.com', 'role': role, }) self.users[name]['password'] = name self.campaign = self.createCampaign({ 'name': 'Test', 'user_id': self.users['author']['id'], }) monsters = { 'generic': { 'name': 'Little Beast', 'user_id': self.users['dm']['id'], 'size': 'small', }, 'specific': { 'name': 'Big Bad End Guy', 'user_id': self.users['author']['id'], 'campaign_id': self.campaign['id'], 'size': 'medium', }, } self.monsters = {} for name, monster in monsters.items(): self.monsters[name] = self.createMonster(monster) migrate(self.app, ['monster']) genericId = self.monsters['generic']['id'] self.dmPages = { '/monster/list': (200, 'text/html'), '/monster/api': (200, 'application/json'), '/monster/show/%d' % genericId: (200, 'text/html'), '/monster/api/%d' % genericId: (200, 'application/json'), '/monster/new': (200, 'text/html'), '/monster/edit/%d' % genericId: (200, 'text/html'), '/monster/copy/%d' % genericId: (302, None), } specificId = self.monsters['specific']['id'] self.authorPages = { '/monster/api/%d' % specificId: (200, 'application/json'), '/monster/copy/%d' % specificId: (302, None), }
def setUp(self): super(AppEncounterTestCase, self).setUp() users = { 'player': ['player'], 'dm': ['dm'], 'trudy': ['dm'], } monsters = { 'Small': {'size': 'small'}, 'Medium': {'size': 'medium'}, 'Large': {'size': 'large'}, } self.users = {} for name, role in list(users.items()): self.users[name] = self.createUser({ 'username': name, 'password': name, 'email': name + '@example.com', 'role': role, }) self.users[name]['password'] = name self.monsters = {} for name, monster in list(monsters.items()): monster.update({'name': name}) self.monsters[name] = self.createMonster(monster) self.campaign = self.createCampaign({ 'name': 'Test', 'user_id': self.users['dm']['id'], }) self.encounters = {} self.encounters['small'] = self.createEncounter( {'name': 'Small', 'campaign_id': self.campaign['id']}, {'Small': 2}, self.monsters, self.users['dm'], ) self.encounters['mixed'] = self.createEncounter( {'name': 'Mixed'}, {'Medium': 2, 'Large': 2}, self.monsters, self.users['dm'], ) migrate(self.app, ['monster', 'encounter']) encounterId = self.encounters['small']['id'] self.dmPages = { '/encounter/list': (200, 'text/html'), '/encounter/api': (200, 'application/json'), '/encounter/new': (200, 'text/html'), '/encounter/show/%d' % encounterId: (200, 'text/html'), '/encounter/edit/%d' % encounterId: (200, 'text/html'), } self.ownedPages = { '/encounter/api/%d' % encounterId: (200, 'application/json'), }
def setUp(self): super(AppPartyTestCase, self).setUp() users = { 'alice': ['player'], 'bob': ['player'], 'trudy': ['player'], 'dm': ['dm'] } self.users = {} self.characters = {} for name in ['alice', 'bob', 'trudy', 'dm']: self.users[name] = self.createUser({ 'username': name, 'password': name, 'email': name + '@example.com', 'role': users[name], }) self.users[name]['password'] = name self.characters[name] = self.createCharacter({ 'name': name, }, self.users[name]) self.party = self.createParty( { 'name': 'test', 'description': 'Test party', 'challenge': { 'easy': 50, 'medium': 100, 'hard': 150, 'deadly': 200, }, }, [ self.characters['alice'], self.characters['bob'], ], self.users['dm']) partyId = self.party['id'] self.dmPages = { '/party/new': (200, 'text/html'), '/party/show/%d' % partyId: (200, 'text/html'), '/party/edit/%d' % partyId: (200, 'text/html'), '/party/hosting': (200, 'application/json'), } self.partyPages = { '/party/list': (200, 'text/html'), '/party/api/%d' % partyId: (200, 'application/json'), } migrate(self.app, ['user', 'character', 'party'])
def setUp(self): super(AppCharacterTestCase, self).setUp() self.privatePages = { '/character/list': (200, 'text/html'), '/character/new': (200, 'text/html'), '/character/api': (200, 'application/json'), '/character/api/999': (404, None), '/character/copy/999': (404, None), #'/character/download/999': (404, None), '/character/races/api': (200, 'application/json'), '/character/classes/api': (200, 'application/json'), '/character/backgrounds/api': (200, 'application/json'), } users = { 'user': [], 'alice': ['player'], 'bob': ['player'], 'dm': ['dm'] } self.users = {} self.characters = {} for name, role in list(users.items()): self.users[name] = self.createUser({ 'username': name, 'password': name, 'email': name + '@example.com', 'role': role, }) self.users[name]['password'] = name self.characters[name] = self.createCharacter({'name': name}, self.users[name]) migrate(self.app, ['user', 'character']) charId = self.characters['alice']['id'] self.protectedPages = { '/character/show/%d' % charId: (200, 'text/html'), '/character/api/%d' % charId: (200, 'application/json'), '/character/reset/%d' % charId: (200, 'text/html'), '/character/copy/%d' % charId: (302, None), '/character/download/%d' % charId: (200, 'application/pdf'), } self.adminPages = { '/character/raw/%d' % charId: (200, 'application/json'), '/character/xp/%d/25' % charId: (302, None), }
def bootstrap(): """ Install Chef and use it to install the app on an EC2 instance. """ # Prepare node to use secrets from our configuration file rendernodejson() # Install chef and run it installchef() cook() # Copy local env to new instance copyconfig() # Fire up the Django project migrate() collectstatic() sudo("echo 'export CALACCESS_WEBSITE_ENV=%s' >> " "/apps/calaccess/bin/activate" % os.getenv('CALACCESS_WEBSITE_ENV')) # Done deal print(green("Success!")) print("Visit the app at %s" % env.EC2_HOST)