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::{prelude::FromPrimitive, prelude::ToPrimitive, Decimal, RoundingStrategy};
|
||||||
use rust_decimal_macros::dec;
|
use rust_decimal_macros::dec;
|
||||||
use sqlx::FromRow;
|
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::*};
|
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;
|
const STRATEGIST_NUMBER: u32 = 16;
|
||||||
|
|
||||||
pub async fn initialization() {
|
pub async fn initialization() {
|
||||||
|
|
@ -82,24 +80,37 @@ async fn initialize_webdriver() {
|
||||||
print!("Open webdriver...");
|
print!("Open webdriver...");
|
||||||
io::stdout().flush();
|
io::stdout().flush();
|
||||||
let mut output;
|
let mut output;
|
||||||
|
|
||||||
output = Command::new(WEB_DRIVER_PATH)
|
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");
|
||||||
|
|
||||||
|
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())
|
.stdin(Stdio::null())
|
||||||
.stdout(Stdio::null())
|
.stdout(Stdio::null())
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
.spawn();
|
.spawn();
|
||||||
|
output.expect("\nOpening chromedriver failed!");
|
||||||
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();
|
|
||||||
}
|
|
||||||
println!("Ok");
|
println!("Ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user