Skip to content

Commit

Permalink
cleaner
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Oct 29, 2024
1 parent 5085725 commit 3e2b0c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zoo-kcl"
version = "0.1.43"
version = "0.1.44"
edition = "2021"
repository = "https://github.com/kittycad/kcl.py"

Expand Down
51 changes: 7 additions & 44 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,50 +183,13 @@ fn get_output_format(
}

async fn new_context(units: UnitLength) -> Result<ExecutorContext> {
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
let http_client = reqwest::Client::builder()
.user_agent(user_agent)
// For file conversions we need this to be long.
.timeout(std::time::Duration::from_secs(600))
.connect_timeout(std::time::Duration::from_secs(60));
let ws_client = reqwest::Client::builder()
.user_agent(user_agent)
// For file conversions we need this to be long.
.timeout(std::time::Duration::from_secs(600))
.connect_timeout(std::time::Duration::from_secs(60))
.connection_verbose(true)
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();

let token = if let Ok(token) = std::env::var("KITTYCAD_API_TOKEN") {
token
} else if let Ok(token) = std::env::var("ZOO_API_TOKEN") {
token
} else {
return Err(anyhow::anyhow!(
"No API token found in environment variables. Use KITTYCAD_API_TOKEN or ZOO_API_TOKEN"
));
};

// Create the client.
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
// Set a local engine address if it's set.
if let Ok(addr) = std::env::var("ZOO_HOST") {
client.set_base_url(addr);
} else if let Ok(addr) = std::env::var("KITTYCAD_HOST") {
client.set_base_url(addr);
}

let ctx = ExecutorContext::new(
&client,
ExecutorSettings {
units,
highlight_edges: true,
enable_ssao: false,
show_grid: false,
replay: None,
},
)
let ctx = ExecutorContext::new_with_default_client(ExecutorSettings {
units,
highlight_edges: true,
enable_ssao: false,
show_grid: false,
replay: None,
})
.await?;
Ok(ctx)
}
Expand Down

0 comments on commit 3e2b0c7

Please sign in to comment.