-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add pip module for installing requirements
- Loading branch information
Showing
6 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod env; | ||
pub mod pip; | ||
pub mod settings; | ||
pub mod configs_files; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use std::{ | ||
error::Error, | ||
|
||
process::{ | ||
Stdio, | ||
Command, | ||
}, | ||
}; | ||
|
||
use crate::{ | ||
ui::{ | ||
ui_base::UI, | ||
success_alerts::SuccessAlerts, | ||
}, | ||
|
||
consts::{ | ||
addons::Addons, | ||
folders::Folders, | ||
}, | ||
|
||
utils::{ | ||
remote::Remote, | ||
file::FileUtils, | ||
}, | ||
}; | ||
|
||
pub struct Pip; | ||
|
||
impl Pip { | ||
|
||
async fn exec(path: &str) -> Result<(), Box<dyn Error>> { | ||
let output = Command::new("pip") | ||
.arg("install") | ||
.arg("-r") | ||
.arg("requirements.txt") | ||
.current_dir(path) | ||
.stdout(Stdio::piped()) | ||
.output()?; | ||
|
||
if output.status.success() { | ||
let _ = String::from_utf8_lossy(&output.stdout); | ||
SuccessAlerts::pip(); | ||
} else { | ||
let stderr = String::from_utf8_lossy(&output.stderr); | ||
println!("{}", stderr); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
pub async fn install() -> Result<(), Box<dyn Error>> { | ||
UI::section_header("Installing requirements", "info"); | ||
let path = Folders::SCRIPTS_FOLDER.to_str().unwrap_or_default().to_string(); | ||
|
||
FileUtils::create_path(&path); | ||
Remote::download(&Addons::INSTALL_REQUIREMENTS_PLUGINS, &path).await?; | ||
|
||
Self::exec(&path).await?; | ||
Ok(()) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters