def run(target_folder, coordinate_table, coordinate_column_x, coordinate_column_y, source_proj4, target_proj4): target_path = join(target_folder, 'converted_coordinate_table.csv') try: transform_x_y = get_transformPoint(source_proj4, target_proj4) except GeometryError: try: get_spatialReference(source_proj4) except GeometryError: exit(SPATIAL_REFERENCE_INVALID % ('source', source_proj4)) try: get_spatialReference(target_proj4) except GeometryError: exit(SPATIAL_REFERENCE_INVALID % ('target', target_proj4)) columns = list(coordinate_table.columns) column_x_index = _get_column_index(columns, coordinate_column_x, 'x') column_y_index = _get_column_index(columns, coordinate_column_y, 'y') columns, order_x_y = _prepare_columns(columns, target_proj4) csv_writer = csv.writer(open(target_path, 'w')) csv_writer.writerow(columns) for index, row in enumerate(coordinate_table.values): row = list(row) old_x, old_y = row[column_x_index], row[column_y_index] try: new_x, new_y = transform_x_y(old_x, old_y) except RuntimeError: print_error(COORDINATES_NOT_TRANSFORMED, index, old_x, old_y) csv_writer.writerow(row + ['', '']) continue csv_writer.writerow(row + order_x_y(new_x, new_y)) return [ ('converted_coordinate_table_path', target_path), ]
def run(self, args): print('Listening to %s' % args.relay_url) try: worker = Worker(args.server_url, args.queue_token) worker.work() Namespace.channel = 'q/' + args.queue_token Namespace.worker = worker socket = SocketIO(args.relay_url, Namespace=Namespace, wait_for_connection=False) socket.wait() except ServerConnectionError: print_error('The server is down. Try again later.') except RelayConnectionError: print_error('The relay is down. Try again later.') except HTTPBadRequest: print_error( 'There was an error processing your request.\n' '- Check that the server URL is correct (--server_url).\n' '- Upgrade the framework (pip install -U crosscompute).') except HTTPUnauthorized: print_error('The server rejected the token. ' 'Make sure your token is valid.') except KeyboardInterrupt: pass
def run(self, args): print('Listening to %s' % args.relay_url) try: worker = Worker(args.server_url, args.queue_token) worker.work() Namespace.channel = 'q/' + args.queue_token Namespace.worker = worker socket = SocketIO( args.relay_url, Namespace=Namespace, wait_for_connection=False) socket.wait() except ServerConnectionError: print_error('The server is down. Try again later.') except RelayConnectionError: print_error('The relay is down. Try again later.') except HTTPBadRequest: print_error( 'There was an error processing your request.\n' '- Check that the server URL is correct (--server_url).\n' '- Upgrade the framework (pip install -U crosscompute).') except HTTPUnauthorized: print_error( 'The server rejected the token. ' 'Make sure your token is valid.') except KeyboardInterrupt: pass
def run( target_folder, coordinate_table, coordinate_column_x, coordinate_column_y, source_proj4, target_proj4): target_path = join(target_folder, 'converted_coordinate_table.csv') try: transform_x_y = get_transformPoint(source_proj4, target_proj4) except GeometryError: try: get_spatialReference(source_proj4) except GeometryError: exit(SPATIAL_REFERENCE_INVALID % ('source', source_proj4)) try: get_spatialReference(target_proj4) except GeometryError: exit(SPATIAL_REFERENCE_INVALID % ('target', target_proj4)) columns = list(coordinate_table.columns) column_x_index = _get_column_index(columns, coordinate_column_x, 'x') column_y_index = _get_column_index(columns, coordinate_column_y, 'y') columns, order_x_y = _prepare_columns(columns, target_proj4) csv_writer = csv.writer(open(target_path, 'w')) csv_writer.writerow(columns) for index, row in enumerate(coordinate_table.values): row = list(row) old_x, old_y = row[column_x_index], row[column_y_index] try: new_x, new_y = transform_x_y(old_x, old_y) except RuntimeError: print_error(COORDINATES_NOT_TRANSFORMED, index, old_x, old_y) csv_writer.writerow(row + ['', '']) continue csv_writer.writerow(row + order_x_y(new_x, new_y)) return [ ('converted_coordinate_table_path', target_path), ]