def handle(self, *args, **options): version = options['game-version'] if version is None: print('game version MUST be specified', file=sys.stderr) sys.exit(1) print() print('GENERATE JAVASCRIPT CONSTANTS') print() run_django_command(['game_generate_js']) print() print('GENERATE CSS') print() run_django_command(['less_generate_css']) print() print('GENERATE META CONFIG') print() META_CONFIG.increment_static_data_version() META_CONFIG.version = version META_CONFIG.save_config()
def handle(self, *args, **options): if len(places_storage.places.all()) != 0: return logic.create_test_map() run_django_command(['map_update_map'])
def handle(self, *args, **options): regions_dir = options['regions'] output = options['output'] if not output: output = '/home/tie/tmp/m.mp4' print 'REGIONS DIR: %s' % regions_dir regions = sorted([os.path.join(regions_dir, filename) for filename in os.listdir(regions_dir) if os.path.isfile(os.path.join(regions_dir, filename)) and filename.startswith('region-')]) temp_dir = tempfile.mkdtemp(prefix='the-tale-map-viz') # temp_dir = '/tmp/the-tale-map-viz3yLsjQ' print 'TEMP DIR: %s' % temp_dir print 'FOUND %d regions' % len(regions) for i, region_filename in enumerate(regions): print 'process region %d: %s' % (i, region_filename) output_file = os.path.join(temp_dir, '%.10d.png' % i) run_django_command(['map_visualize_region', '-r', region_filename, '-o', output_file]) if os.path.exists(output): os.remove(output) subprocess.call(['ffmpeg', '-i', os.path.join(temp_dir, '%10d.png'), '-sameq', output])
def handle(self, *args, **options): regions_dir = options["regions"] output = options["output"] if not output: output = "/home/tie/tmp/m.mp4" print("REGIONS DIR: %s" % regions_dir) regions = sorted( [ os.path.join(regions_dir, filename) for filename in os.listdir(regions_dir) if os.path.isfile(os.path.join(regions_dir, filename)) and filename.startswith("region-") ] ) temp_dir = tempfile.mkdtemp(prefix="the-tale-map-viz") # temp_dir = '/tmp/the-tale-map-viz3yLsjQ' print("TEMP DIR: %s" % temp_dir) print("FOUND %d regions" % len(regions)) for i, region_filename in enumerate(regions): print("process region %d: %s" % (i, region_filename)) output_file = os.path.join(temp_dir, "%.10d.png" % i) run_django_command(["map_visualize_region", "-r", region_filename, "-o", output_file]) if os.path.exists(output): os.remove(output) subprocess.call(["ffmpeg", "-i", os.path.join(temp_dir, "%10d.png"), "-sameq", output])
def handle(self, *args, **options): linguistics_logic.sync_static_restrictions() self.create_map() run_django_command(['map_update_map'])
def handle(self, *args, **options): for migration in MIGRATIONS: app_name, migration_name = migration.split('.') if migration_name.startswith('0001'): run_django_command(['migrate', '--fake-initial', app_name]) else: run_django_command(['migrate', '--fake', app_name, migration_name])
def handle(self, *args, **options): places_storage.places[52].is_frontier = False places_storage.places[48].is_frontier = False place = places_logic.create_place(x=49, y=49, size=1, utg_name=dictionary.noun(['Киралода', 'Киралоды', 'Киралоде', 'Киралоду', 'Киралодой', 'Киралоде', 'Киралоды', 'Киралод', 'Киралодам', 'Киралоды', 'Киралодами', 'Киралодах'], 'но,жр').word, race=relations.RACE.ELF, is_frontier=True) persons_logic.create_person(place=place, race=relations.RACE.ELF, gender=relations.GENDER.FEMININE, type=persons_relations.PERSON_TYPE.MAGICIAN, personality_cosmetic=persons_relations.PERSONALITY_COSMETIC.GUARANTOR, personality_practical=persons_relations.PERSONALITY_PRACTICAL.RELIABLE, utg_name=dictionary.noun(['Оуримм', 'Оуримм', 'Оуримм', 'Оуримм', 'Оуримм', 'Оуримм', 'Оуриммы', 'Оуримм', 'Оуриммам', 'Оуримм', 'Оуриммами', 'Оуриммах'], 'од,жр').word) roads_prototypes.RoadPrototype.create(point_1=place, point_2=places_storage.places[52]).update() for place in places_storage.places.all(): place.refresh_attributes() places_storage.places.save_all() run_django_command(['map_update_map'])
def handle(self, *args, **options): for migration in MIGRATIONS: app_name, migration_name = migration.split('.') if migration_name.startswith('0001'): run_django_command(['migrate', '--fake-initial', app_name]) else: run_django_command( ['migrate', '--fake', app_name, migration_name])
def run(self, *args, **kwargs): # to sync map size and do other unpredictable operations run_django_command(['map_update_map']) self.INITIAL_PERSON_POWER = persons_storage.get_medium_power_for_person( ) with transaction.atomic(): p35 = places_storage[35] p35._model.is_frontier = False p35.save() p8x13 = self._create_place( x=8, y=13, roads_to=[p35], name_forms=noun( forms=(u'Сольвейг', u'Сольвейга', u'Сольвейгу', u'Сольвейг', u'Сольвейгом', u'Сольвейге', u'Сольвейги', u'Сольвейгов', u'Сольвейгам', u'Сольвейги', u'Сольвейгами', u'Сольвейгах'), properties=(u'мр,но'))) p39 = places_storage[39] p39._model.is_frontier = False p39.save() p52x26 = self._create_place( x=52, y=26, roads_to=[p39, places_storage[40]], name_forms=noun(forms=(u'Аматир', u'Аматира', u'Аматиру', u'Аматир', u'Аматиром', u'Аматире', u'Аматиры', u'Аматиров', u'Аматирам', u'Аматиры', u'Аматирами', u'Аматирах'), properties=(u'мр,но'))) p36 = places_storage[36] p36._model.is_frontier = False p36.save() p22x8 = self._create_place( x=22, y=8, roads_to=[p36], name_forms=noun(forms=(u'Залесье', u'Залесья', u'Залесью', u'Залесье', u'Залесьем', u'Залесье', u'Залесьи', u'Залесьев', u'Залесьям', u'Залесьи', u'Залесьями', u'Залесьях'), properties=(u'ср,но'))) update_waymarks() persons_logic.sync_social_connections() # update map with new places run_django_command(['map_update_map'])
def handle(self, *args, **options): run_django_command(['roads_update_roads']) run_django_command(['roads_update_waymarks']) run_django_command(['places_update_nearest_cells']) run_django_command(['map_generate_map'])
def _run_django_subprocess(self, name, cmd): self.logger.info('run %s command' % name) result = run_django_command(cmd) if result: self.logger.error('%s ENDED WITH CODE %d' % (name, result)) else: self.logger.info('%s command was processed correctly' % name)
def handle(self, *args, **options): region = options['region'] if not region: region = map_settings.GEN_REGION_OUTPUT % map_info_storage.version output = options['output'] if not output: output = '/tmp/the-tale-map.png' with open(region) as region_file: data = json.loads(region_file.read()) format_version = data.get('format_version') if format_version is None: run_django_command( ['map_visualize_old_region', '-r', region, '-o', output]) return draw_info = data['draw_info'] width = data['width'] height = data['height'] image = PIL.Image.new( 'RGBA', (width * map_settings.CELL_SIZE, height * map_settings.CELL_SIZE)) texture = PIL.Image.open(map_settings.TEXTURE_PATH) for y, row in enumerate(draw_info): for x, cell in enumerate(row): sprites = cell if isinstance(cell, list) else [cell] for sprite in sprites: rotate = 0 if isinstance(sprite, list): sprite, rotate = sprite draw_sprite(image, texture, SPRITES(sprite), x, y, rotate=rotate) image.crop(OUTPUT_RECTANGLE).resize(REAL_SIZE, PIL.Image.ANTIALIAS).save(output)
def run(self, *args, **kwargs): # to sync map size and do other unpredictable operations run_django_command(['map_update_map']) self.INITIAL_PERSON_POWER = persons_storage.get_medium_power_for_person() with transaction.atomic(): p35 = places_storage[35] p35._model.is_frontier = False p35.save() p8x13 = self._create_place(x=8, y=13, roads_to=[p35], name_forms=noun(forms=(u'Сольвейг', u'Сольвейга', u'Сольвейгу', u'Сольвейг', u'Сольвейгом', u'Сольвейге', u'Сольвейги', u'Сольвейгов', u'Сольвейгам', u'Сольвейги', u'Сольвейгами', u'Сольвейгах'), properties=(u'мр,но'))) p39 = places_storage[39] p39._model.is_frontier = False p39.save() p52x26 = self._create_place(x=52, y=26, roads_to=[p39, places_storage[40]], name_forms=noun(forms=(u'Аматир', u'Аматира', u'Аматиру', u'Аматир', u'Аматиром', u'Аматире', u'Аматиры', u'Аматиров', u'Аматирам', u'Аматиры', u'Аматирами', u'Аматирах'), properties=(u'мр,но'))) p36 = places_storage[36] p36._model.is_frontier = False p36.save() p22x8 = self._create_place(x=22, y=8, roads_to=[p36], name_forms=noun(forms=(u'Залесье', u'Залесья', u'Залесью', u'Залесье', u'Залесьем', u'Залесье', u'Залесьи', u'Залесьев', u'Залесьям', u'Залесьи', u'Залесьями', u'Залесьях'), properties=(u'ср,но'))) update_waymarks() persons_logic.sync_social_connections() # update map with new places run_django_command(['map_update_map'])
def handle(self, *args, **options): regions_dir = options['regions'] output = options['output'] if not output: output = '/home/tie/tmp/m.mp4' print('REGIONS DIR: %s' % regions_dir) regions = sorted([ os.path.join(regions_dir, filename) for filename in os.listdir(regions_dir) if os.path.isfile(os.path.join(regions_dir, filename)) and filename.startswith('region-') ]) temp_dir = tempfile.mkdtemp(prefix='the-tale-map-viz') # temp_dir = '/tmp/the-tale-map-viz3yLsjQ' print('TEMP DIR: %s' % temp_dir) print('FOUND %d regions' % len(regions)) for i, region_filename in enumerate(regions): print('process region %d: %s' % (i, region_filename)) output_file = os.path.join(temp_dir, '%.10d.png' % i) run_django_command([ 'map_visualize_region', '-r', region_filename, '-o', output_file ]) if os.path.exists(output): os.remove(output) subprocess.call([ 'ffmpeg', '-i', os.path.join(temp_dir, '%10d.png'), '-sameq', output ])
def handle(self, *args, **options): region = options['region'] if not region: region = map_settings.GEN_REGION_OUTPUT % map_info_storage.version output = options['output'] if not output: output = '/tmp/the-tale-map.png' with open(region) as region_file: data = json.loads(region_file.read()) format_version = data.get('format_version') if format_version is None: run_django_command(['map_visualize_old_region', '-r', region, '-o', output]) return draw_info = data['draw_info'] width = data['width'] height = data['height'] image = PIL.Image.new('RGBA', (width*map_settings.CELL_SIZE, height*map_settings.CELL_SIZE)) texture = PIL.Image.open(map_settings.TEXTURE_PATH) for y, row in enumerate(draw_info): for x, cell in enumerate(row): sprites = cell if isinstance(cell, list) else [cell] for sprite in sprites: rotate = 0 if isinstance(sprite, list): sprite, rotate = sprite draw_sprite(image, texture, SPRITES(sprite), x, y, rotate=rotate) image.crop(OUTPUT_RECTANGLE).resize(REAL_SIZE, PIL.Image.ANTIALIAS).save(output)
def handle(self, *args, **options): subprocess.call("rm -f `find ./ -name '*.pyc'`", shell=True) tests = [] for application in django_apps.get_app_configs(): label = application.name.split('.') if label[0] == 'django': continue tests_path = '%s.tests' % application.name if discovering.is_module_exists(tests_path): tests.append(tests_path) result = run_django_command(['test', '--nomigrations'] + tests) print('test result: ', result)
def handle(self, *args, **options): self.create_map() run_django_command(['map_update_map'])
def handle(self, *args, **options): print print 'UPDATE MAP' print run_django_command(['map_update_map']) print print 'UPDATE LINGUISTICS' linguistics_logic.sync_static_restrictions() linguistics_logic.update_templates_errors() linguistics_logic.update_words_usage_info() print print 'SYNC MARKET' run_django_command(['market_sync_goods']) print print 'SYNC SOCIAL CONNECTIONS' persons_logic.sync_social_connections() print print 'SYNC ACTUAL BILLS' bills_logic.update_actual_bills_for_all_accounts() print print 'REMOVE OLD SDN INFO' if portal_settings.SETTINGS_CDN_INFO_KEY in settings: del settings[portal_settings.SETTINGS_CDN_INFO_KEY] if portal_settings.SETTINGS_PREV_CDN_SYNC_TIME_KEY in settings: del settings[portal_settings.SETTINGS_PREV_CDN_SYNC_TIME_KEY] print print 'SYNC GROUPS AND PERMISSIONS' print sync_group('content group', ['cms.add_page', 'cms.change_page', 'cms.delete_page', 'news.add_news', 'news.change_news', 'news.delete_news']) sync_group(forum_settings.MODERATOR_GROUP_NAME, ['forum.moderate_thread', 'forum.moderate_post']) sync_group('bills moderators group', ['bills.moderate_bill']) sync_group('developers group', ['mobs.moderate_mobrecord', 'artifacts.moderate_artifactrecord', 'linguistics.moderate_word', 'linguistics.moderate_template', 'linguistics.edit_template']) sync_group('folclor moderation group', ['blogs.moderate_post']) sync_group('mobs & artifacts create group', ['mobs.create_mobrecord', 'artifacts.create_artifactrecord']) sync_group('accounts moderators group', ['accounts.moderate_account']) sync_group('collections editors group', ['collections.edit_collection', 'collections.edit_kit', 'collections.edit_item']) sync_group('collections moderators group', ['collections.moderate_collection', 'collections.moderate_kit', 'collections.moderate_item']) sync_group('achievements editors group', ['achievements.edit_achievement']) sync_group(linguistics_settings.MODERATOR_GROUP_NAME, ['linguistics.moderate_word', 'linguistics.moderate_template', 'linguistics.edit_template']) sync_group(linguistics_settings.EDITOR_GROUP_NAME, ['linguistics.moderate_word', 'linguistics.edit_template'])
def handle(self, *args, **options): print() print('UPDATE MAP') print() run_django_command(['map_update_map']) print() print('UPDATE LINGUISTICS') linguistics_logic.sync_static_restrictions() linguistics_logic.update_templates_errors() linguistics_logic.update_words_usage_info() print() print('SYNC ACTUAL BILLS') bills_logic.update_actual_bills_for_all_accounts() print() print('REFRESH ATTRIBUTES') places_logic.refresh_all_places_attributes() persons_logic.refresh_all_persons_attributes() print() print('REMOVE OLD CDN INFO') if portal_settings.SETTINGS_CDN_INFO_KEY in settings: del settings[portal_settings.SETTINGS_CDN_INFO_KEY] if portal_settings.SETTINGS_PREV_CDN_SYNC_TIME_KEY in settings: del settings[portal_settings.SETTINGS_PREV_CDN_SYNC_TIME_KEY] print() print('SYNC GROUPS AND PERMISSIONS') print() sync_group('content group', ['news.add_news', 'news.change_news', 'news.delete_news']) sync_group(forum_settings.MODERATOR_GROUP_NAME, ['forum.moderate_thread', 'forum.moderate_post']) sync_group('bills moderators group', ['bills.moderate_bill']) sync_group('developers group', [ 'mobs.moderate_mobrecord', 'artifacts.moderate_artifactrecord', 'linguistics.moderate_word', 'linguistics.moderate_template', 'linguistics.edit_template' ]) sync_group('folclor moderation group', ['blogs.moderate_post']) sync_group( 'mobs & artifacts create group', ['mobs.create_mobrecord', 'artifacts.create_artifactrecord']) sync_group('accounts moderators group', ['accounts.moderate_account']) sync_group('clans moderators group', ['clans.moderate_clan']) sync_group('collections editors group', [ 'collections.edit_collection', 'collections.edit_kit', 'collections.edit_item' ]) sync_group('collections moderators group', [ 'collections.moderate_collection', 'collections.moderate_kit', 'collections.moderate_item' ]) sync_group('achievements editors group', ['achievements.edit_achievement']) sync_group(linguistics_settings.MODERATOR_GROUP_NAME, [ 'linguistics.moderate_word', 'linguistics.moderate_template', 'linguistics.edit_template' ]) sync_group(linguistics_settings.EDITOR_GROUP_NAME, ['linguistics.moderate_word', 'linguistics.edit_template'])