Skip to content
Snippets Groups Projects
Commit b5209375 authored by florian's avatar florian
Browse files

ENH: Print version info in a nice way

parent fec47721
No related branches found
No related tags found
2 merge requests!3TST: Add CI infrastructure for integration testing,!2ENH: Add minimal wrapping of libcaosdb's C interface
Pipeline #10278 passed
......@@ -270,9 +270,8 @@ to.
"""
function get_version_info(con::Ref{CaosDBConnection})
println("Entering get_version_info...")
info = Ref{CaosDB.Info.VersionInfo}(CaosDB.Info.VersionInfo())
println("Calling c function")
err_code = ccall(
(:caosdb_connection_get_version_info, "libccaosdb"),
Cint,
......@@ -280,7 +279,7 @@ function get_version_info(con::Ref{CaosDBConnection})
info,
con,
)
println("Return code $err_code")
# TODO Real error-code handling
if err_code != 0
......@@ -292,6 +291,29 @@ function get_version_info(con::Ref{CaosDBConnection})
end
"""
print_version_info(con::Ref{CaosDBConnection})
Retrieve the version info for the CaosDB server `con` is connected to,
and print the version in a nice message.
"""
function print_version_info(con::Ref{CaosDBConnection})
# Dereference to access the fields
info = get_version_info(con)[]
major = info.major
minor = info.minor
patch = info.patch
pre_release_str = unsafe_string(info.pre_release)
build_str = unsafe_string(info.build)
println(
"Connected to a CaosDB server with version $major.$minor.$patch-$pre_release_str-$build_str.",
)
end
function connect(
host::AbstractString = nothing,
port_str::AbstractString = nothing,
......@@ -308,7 +330,7 @@ function connect(
if port_str == nothing
port = CaosDB.Utility.get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTPS", "localhost")
port = CaosDB.Utility.get_env_var("CAOSDB_SERVER_GRPC_PORT_HTTPS", "8443")
end
......@@ -337,6 +359,7 @@ function connect(
CaosDB.Authentication.create_plain_password_authenticator(username, password)
config = create_tls_connection_configuration(host, port, authenticator, provider)
connection = create_connection(config)
print_version_info(connection)
return connection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment