cleanup imports, allow config path in assets
This commit is contained in:
parent
8e9d114910
commit
52ce6197f0
@ -1,7 +1,4 @@
|
||||
use std::{
|
||||
process,
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
use std::process::{self, Command, Stdio};
|
||||
|
||||
use simplelog::*;
|
||||
|
||||
|
@ -138,22 +138,25 @@ impl GlobalConfig {
|
||||
/// Read config from YAML file, and set some extra config values.
|
||||
pub fn new() -> Self {
|
||||
let args = get_args();
|
||||
let mut config_path = match env::current_exe() {
|
||||
Ok(path) => path.parent().unwrap().join("ffplayout.yml"),
|
||||
Err(_) => PathBuf::from("./ffplayout.yml"),
|
||||
};
|
||||
let mut config_path = PathBuf::from("/etc/ffplayout/ffplayout.yml");
|
||||
|
||||
if let Some(cfg) = args.config {
|
||||
config_path = PathBuf::from(cfg);
|
||||
} else if Path::new("/etc/ffplayout/ffplayout.yml").is_file() {
|
||||
config_path = PathBuf::from("/etc/ffplayout/ffplayout.yml");
|
||||
}
|
||||
|
||||
if !config_path.is_file() {
|
||||
if Path::new("./assets/ffplayout.yml").is_file() {
|
||||
config_path = PathBuf::from("./assets/ffplayout.yml")
|
||||
} else if let Some(p) = env::current_exe().ok().as_ref().and_then(|op| op.parent()) {
|
||||
config_path = p.join("ffplayout.yml")
|
||||
};
|
||||
}
|
||||
|
||||
let f = match File::open(&config_path) {
|
||||
Ok(file) => file,
|
||||
Err(err) => {
|
||||
Err(_) => {
|
||||
println!(
|
||||
"{config_path:?} doesn't exists!\nPut \"ffplayout.yml\" in \"/etc/playout/\" or beside the executable!\n\nSystem error: {err}"
|
||||
"{config_path:?} doesn't exists!\nPut \"ffplayout.yml\" in \"/etc/playout/\" or beside the executable!"
|
||||
);
|
||||
process::exit(0x0100);
|
||||
}
|
||||
|
@ -1,17 +1,13 @@
|
||||
use chrono::prelude::*;
|
||||
use chrono::Duration;
|
||||
use ffprobe::{ffprobe, Format, Stream};
|
||||
use std::{
|
||||
fs,
|
||||
fs::metadata,
|
||||
fs::{self, metadata},
|
||||
io::{BufRead, BufReader, Error},
|
||||
path::Path,
|
||||
process::exit,
|
||||
process::{ChildStderr, Command, Stdio},
|
||||
time,
|
||||
time::UNIX_EPOCH,
|
||||
process::{exit, ChildStderr, Command, Stdio},
|
||||
time::{self, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use chrono::{prelude::*, Duration};
|
||||
use ffprobe::{ffprobe, Format, Stream};
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
Loading…
Reference in New Issue
Block a user