def setUp(self): self.sprite = Sprite('flags', images=[ ('brazil', get_absolute_path('country/flags/brazil.gif')), ('usa', get_absolute_path('country/flags/usa.jpg')), ], packing_class=HorizontalPacking )
def setUp(self): self.sprite = Sprite( 'flags', images=[ ('brazil', get_absolute_path('country/flags/brazil.gif')), ('usa', get_absolute_path('country/flags/usa.jpg')), ], packing_class=HorizontalPacking)
def setUp(self): self.sprite = Sprite('flags', images=[ ('brazil', get_absolute_path('country/flags/bra.png')), ('usa', get_absolute_path('country/flags/usa.png')), ('canada', get_absolute_path('country/flags/can.png')), ], packing_class=BinPacking )
def setUp(self): self.sprite = Sprite('flags', images=[ ('brazil', get_absolute_path('country/flags/bra.png')), ('usa', get_absolute_path('country/flags/usa.png')), ('canada', get_absolute_path('country/flags/can.png')), ], packing_class=BinPacking)
def config_and_start_webserver(port): app = web.Application(middlewares=[ web.normalize_path_middleware(append_slash=True, merge_slashes=True), exception_handler_middleware, ]) # Legacy routes app.add_routes([web.get('/data/json/samples', samples_legacy), web.get(r'/data/json/archive/{run}/{path:.+}', archive_legacy), web.get(r'/plotfairy/archive/{run}/{path:.+}', render_legacy), web.get('/plotfairy/overlay', render_overlay_legacy), web.get(r'/jsrootfairy/archive/{run}/{path:.+}', jsroot_legacy),]) # Version 1 API routes app.add_routes([web.get('/api/v1/samples', samples_v1), web.get('/api/v1/layouts', layouts_v1), web.get(r'/api/v1/archive/{run}/{path:.+}', archive_v1), web.get(r'/api/v1/render/{run}/{path:.+}', render_v1), web.get('/api/v1/render_overlay', render_overlay_v1), web.get(r'/api/v1/json/{run}/{path:.+}', jsroot_legacy), web.get('/api/v1/json_overlay', jsroot_overlay), web.get(r'/api/v1/lumis/{run}/{dataset:.+}', available_lumis_v1), web.post('/api/v1/register', register), web.get('/api/v1/datasets', dataset_search), web.get('/api/v1/latest_runs', latest_runs)]) # Routes for HTML files app.add_routes([web.get('/', index), web.static('/', get_absolute_path('../frontend/'), show_index=True)]) app.on_shutdown.append(on_shutdown) web.run_app(app, port=port)
async def __start_rendering_process(self): """Starts the rendering process.""" render_plugins = ['--load', self.render_plugins_lib_path ] if self.render_plugins_lib_path else [] self.working_dir = tempfile.mkdtemp() self.render_process = await asyncio.subprocess.create_subprocess_exec( get_absolute_path('../bin/render'), '--state-directory', f'{self.working_dir}/', *render_plugins, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT) async def logoutput(): while True: q = await self.render_process.stdout.readline() if not q: return logger.info(f"render: {q}") self.log_task = asyncio.Task(logoutput()) # Wait for the socket to initialise and be ready to accept connections while not os.path.exists(f'{self.working_dir}/socket'): await asyncio.sleep(0.2)
def __get_render_plugins_lib_path(cls): """Returns an absolute path to libDQMRenderPlugins.so""" pattern = get_absolute_path('../lib/libDQMRenderPlugins.so') paths = glob.glob(pattern) if paths: return paths[0] return None
def test_image_can_be_saved(self): image1 = Image(get_absolute_path('country/flags/bra.png')) image2 = Image(get_absolute_path('country/flags/can.png')) image3 = Image(get_absolute_path('country/flags/usa.png')) out_image = OutputImage(48 * 3, 48) out_image.add(image1, 0, 0) out_image.add(image2, 48, 0) out_image.add(image3, 96, 0) path = 'country/flags/sprite.png' absolute_path = os.path.join(settings.MEDIA_ROOT, path) try: out_image.save(absolute_path) self.assertTrue(os.path.exists(absolute_path)) generated_from_fs = Image(absolute_path) self.assertEqual(out_image.width, generated_from_fs.width) self.assertEqual(out_image.height, generated_from_fs.height) finally: os.remove(absolute_path)
def test_image_filename_and_format(self): image = Image(get_absolute_path('country/flags/usa.jpg')) self.assertEqual('usa', image.filename) self.assertEqual('jpg', image.format)
def test_dimensions_for_usa(self): image = Image(get_absolute_path('country/flags/usa.jpg')) self.assertEqual(475, image.width) self.assertEqual(335, image.height) self.assertEqual(475, image.maxside) self.assertEqual(475 * 335, image.area)
def test_dimensions_for_brazil(self): image = Image(get_absolute_path('country/flags/brazil.gif')) self.assertEqual(476, image.width) self.assertEqual(330, image.height) self.assertEqual(476, image.maxside) self.assertEqual(476 * 330, image.area)
def setUp(self): self.image1 = Image(get_absolute_path('country/flags/bra.png')) self.image2 = Image(get_absolute_path('country/flags/can.png')) self.image3 = Image(get_absolute_path('country/flags/usa.png')) self.bin_packing = BinPacking(images=[self.image1, self.image2, self.image3])
def setUp(self): self.image1 = Image(get_absolute_path('country/flags/bra.png')) self.image2 = Image(get_absolute_path('country/flags/can.png')) self.image3 = Image(get_absolute_path('country/flags/usa.png')) self.bin_packing = BinPacking( images=[self.image1, self.image2, self.image3])
async def overlayPlotsWithDifferentNames(request): return web.FileResponse( get_absolute_path("../frontend/plotsLocalOverlay/index.html"))
async def index(request): return web.FileResponse(get_absolute_path('../frontend/index.html'))
This is an entry point to the DQM GUI application. It can be started like this: dqmgui.sh This file configures and initializes aiohttp web server and all DQM GUI services. Responsibilities of the endpoint methods here are to parse input parameters, call the corresponding service methods to get the result and format the output. Each method is defined twice: for legacy API and for new, v1 API. If a new version of the API needs to be provided, new /v2/ methods can be provided and configured here. """ from helpers import get_absolute_path # Add local python packages dir (if it exists) to python path. import sys, os local_packages_dir = get_absolute_path('.python_packages/') if os.path.isdir(local_packages_dir): sys.path.insert(0, local_packages_dir) # This is to make sure that the fork() happens before any imports, and before # any threads are created. processpoolexecutor = None if __name__ == '__main__': import multiprocessing # forkserver means that a dummy process (a fork server process) will be forked # right now, before any threads/locks are created. Whenever a new process will # be requested by the ProcessPoolExecutor, fork server process will be forked # instead of the main process. multiprocessing.set_start_method('forkserver') from concurrent.futures import ProcessPoolExecutor # concurrent.futures initializes the actual multiprocessing pool lazily. So we