Apply fixed directory of chromedriver
This commit is contained in:
parent
0c4e8ada55
commit
f7048b0c9a
BIN
chromedriver/chromedriver.exe
Normal file
BIN
chromedriver/chromedriver.exe
Normal file
Binary file not shown.
|
|
@ -11,11 +11,9 @@ use reqwest::{Client, ClientBuilder};
|
|||
use rust_decimal::{prelude::FromPrimitive, prelude::ToPrimitive, Decimal, RoundingStrategy};
|
||||
use rust_decimal_macros::dec;
|
||||
use sqlx::FromRow;
|
||||
use std::{io, io::Write, process::Stdio};
|
||||
use std::{io, io::Write, process::Stdio, path::Path};
|
||||
use tokio::{fs::*, io::ErrorKind, process::Command, task::JoinHandle, time::*};
|
||||
|
||||
const WEB_DRIVER_PATH: &str = "E:/[Cryptocurrency]/tradingbot/webdriver/chromedriver.exe";
|
||||
const WEB_DRIVER_PATH2: &str = "C:/tradingbot_complete/webdriver/chromedriver.exe";
|
||||
const STRATEGIST_NUMBER: u32 = 16;
|
||||
|
||||
pub async fn initialization() {
|
||||
|
|
@ -83,23 +81,36 @@ async fn initialize_webdriver() {
|
|||
io::stdout().flush();
|
||||
let mut output;
|
||||
|
||||
output = Command::new(WEB_DRIVER_PATH)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn();
|
||||
let os_type = std::env::consts::OS;
|
||||
let mut chrome_webdriver_path = std::path::PathBuf::new();
|
||||
chrome_webdriver_path.push(std::env::current_dir().unwrap());
|
||||
chrome_webdriver_path.push("chromedriver");
|
||||
|
||||
if output.is_ok() {
|
||||
output.unwrap();
|
||||
} else {
|
||||
output = Command::new(WEB_DRIVER_PATH2)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn();
|
||||
|
||||
output.unwrap();
|
||||
match os_type {
|
||||
"linux" => {
|
||||
chrome_webdriver_path.push("chromedriver");
|
||||
},
|
||||
"windows" => {
|
||||
chrome_webdriver_path.push("chromedriver.exe");
|
||||
},
|
||||
_ => {
|
||||
eprintln!("\ntradingbot supports only Linux and Windows.");
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
|
||||
if !chrome_webdriver_path.exists() {
|
||||
eprintln!("\nCheck if there is chromedriver.exe ({})", chrome_webdriver_path.to_str().unwrap());
|
||||
panic!();
|
||||
}
|
||||
|
||||
output = Command::new(chrome_webdriver_path)
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn();
|
||||
output.expect("\nOpening chromedriver failed!");
|
||||
|
||||
println!("Ok");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user