def single_point_table(): file_path = 'sample/layman.layer/single_point.shp' workspace = WORKSPACE layername = 'single_point' with layman.app_context(): ensure_layer_input_file_dir(workspace, layername) db.import_layer_vector_file(workspace, layername, file_path, None) yield workspace, layername with layman.app_context(): delete_layer(workspace, layername)
def country10m_table(): file_path = 'tmp/naturalearth/10m/cultural/ne_10m_admin_0_countries.geojson' workspace = WORKSPACE layername = 'staty10m' with layman.app_context(): db.ensure_workspace(workspace) ensure_layer_input_file_dir(workspace, layername) db.import_layer_vector_file(workspace, layername, file_path, None) yield workspace, layername with layman.app_context(): delete_layer(workspace, layername)
def road_table(): file_path = 'sample/data/upper_attr.geojson' workspace = WORKSPACE layername = 'silnice' with layman.app_context(): db.ensure_workspace(workspace) ensure_layer_input_file_dir(workspace, layername) db.import_layer_vector_file(workspace, layername, file_path, None) yield workspace, layername with layman.app_context(): delete_layer(workspace, layername)
def boundary_table(): file_path = 'tmp/naturalearth/110m/cultural/ne_110m_admin_0_boundary_lines_land.shp' workspace = WORKSPACE layername = 'hranice' with layman.app_context(): db.ensure_workspace(workspace) ensure_layer_input_file_dir(workspace, layername) db.import_layer_vector_file(workspace, layername, file_path, None) yield workspace, layername with layman.app_context(): delete_layer(workspace, layername)
def populated_places_table(): file_path = 'tmp/naturalearth/110m/cultural/ne_110m_populated_places.geojson' workspace = WORKSPACE layername = 'ne_110m_populated_places' with layman.app_context(): db.ensure_workspace(workspace) ensure_layer_input_file_dir(workspace, layername) db.import_layer_vector_file(workspace, layername, file_path, None) yield workspace, layername with layman.app_context(): delete_layer(workspace, layername)
def sm5building_table(): file_path = 'tmp/sm5/vektor/Budova.shp' workspace = WORKSPACE layername = 'sm5_building' with layman.app_context(): db.ensure_workspace(workspace) ensure_layer_input_file_dir(workspace, layername) db.import_layer_vector_file(workspace, layername, file_path, None) yield workspace, layername with layman.app_context(): delete_layer(workspace, layername)
def data200road_table(): file_path = 'tmp/data200/trans/RoadL.shp' workspace = WORKSPACE layername = 'data200_road' with layman.app_context(): db.ensure_workspace(workspace) ensure_layer_input_file_dir(workspace, layername) db.import_layer_vector_file(workspace, layername, file_path, None) yield workspace, layername with layman.app_context(): delete_layer(workspace, layername)
def empty_table(): file_path = 'sample/layman.layer/empty.shp' workspace = WORKSPACE layername = 'empty' with layman.app_context(): db.ensure_workspace(workspace) ensure_layer_input_file_dir(workspace, layername) with layman.app_context(): db.import_layer_vector_file(workspace, layername, file_path, None) yield workspace, layername with layman.app_context(): delete_layer(workspace, layername)
def test_abort_import_layer_vector_file(): username = '******' layername = 'ne_10m_admin_0_countries' src_dir = 'tmp/naturalearth/10m/cultural' input_file_dir = ensure_layer_input_file_dir(username, layername) filename = layername + '.geojson' main_filepath = os.path.join(input_file_dir, filename) crs_id = None shutil.copy( os.path.join(src_dir, filename), input_file_dir ) def abort_layer_import(): process = db.import_layer_vector_file_async(username, layername, main_filepath, crs_id) time1 = time.time() while process.poll() is None: if time.time() - time1 > 0.1: # print('terminating process') process.terminate() time.sleep(0.1) return_code = process.poll() return return_code return_code = abort_layer_import() assert return_code != 0 layerdir = get_layer_dir(username, layername) shutil.rmtree(layerdir)