fix: fix open config file error

pull/539/head
zanllp 2024-03-10 05:18:51 +08:00
parent 5deacaf9c5
commit c5c21167c2
6 changed files with 41 additions and 12 deletions

3
app.py
View File

@ -1,3 +1,4 @@
import codecs
from typing import List
from fastapi import FastAPI
from fastapi.responses import FileResponse
@ -19,7 +20,7 @@ default_host = "127.0.0.1"
def sd_webui_paths_check(sd_webui_config: str, relative_to_config: bool):
conf = {}
with open(sd_webui_config, "r") as f:
with codecs.open(sd_webui_config, "r", "utf-8") as f:
conf = json.loads(f.read())
if relative_to_config:
for dir in sd_img_dirs:

View File

@ -50,7 +50,7 @@ def get_sd_webui_conf(**kwargs):
pass
try:
sd_conf_path = kwargs.get("sd_webui_config")
with open(sd_conf_path, "r") as f:
with codecs.open(sd_conf_path, "r", "utf-8") as f:
obj = json.loads(f.read())
if kwargs.get("sd_webui_path_relative_to_config"):
for dir in sd_img_dirs:

View File

@ -440,8 +440,11 @@ checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"serde",
"time 0.1.45",
"wasm-bindgen",
"winapi",
]
@ -1575,6 +1578,7 @@ dependencies = [
name = "infinite_image_browsing"
version = "0.0.1"
dependencies = [
"chrono",
"reqwest",
"serde",
"serde_json",
@ -1770,7 +1774,7 @@ dependencies = [
"dirs-next",
"objc-foundation",
"objc_id",
"time",
"time 0.3.22",
]
[[package]]
@ -2355,7 +2359,7 @@ dependencies = [
"line-wrap",
"quick-xml 0.28.2",
"serde",
"time",
"time 0.3.22",
]
[[package]]
@ -2891,7 +2895,7 @@ dependencies = [
"serde",
"serde_json",
"serde_with_macros",
"time",
"time 0.3.22",
]
[[package]]
@ -3345,7 +3349,7 @@ dependencies = [
"sha2",
"tauri-utils",
"thiserror",
"time",
"time 0.3.22",
"uuid",
"walkdir",
]
@ -3515,6 +3519,17 @@ dependencies = [
"once_cell",
]
[[package]]
name = "time"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
dependencies = [
"libc",
"wasi 0.10.0+wasi-snapshot-preview1",
"winapi",
]
[[package]]
name = "time"
version = "0.3.22"
@ -3875,6 +3890,12 @@ version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"

View File

@ -18,6 +18,7 @@ tauri = { version = "1.4", features = [ "api-all", "devtools", "process-command-
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
reqwest = { version = "0.11", features = ["blocking", "json"] }
chrono = "0.4"
[features]
# this feature is used for production builds or when `devPath` points to the filesystem

View File

@ -3,13 +3,16 @@
use serde::Deserialize;
use std::fs::File;
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::io::Error;
use std::io::Write;
use tauri::api::process::Command;
use tauri::api::process::CommandEvent;
use tauri::WindowEvent;
use std::fs::OpenOptions;
use std::io::Write;
use chrono::Local;
use chrono::format::{DelayedFormat, StrftimeItems};
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
@ -81,9 +84,12 @@ fn main() {
match event {
CommandEvent::Stdout(line) => println!("{}", line),
CommandEvent::Stderr(line) => {
eprintln!("{}", line);
writeln!(&log_file, "{}", line).expect("Failed to write to log file");
},
let timestamp: DelayedFormat<StrftimeItems<'_>> =
Local::now().format("[%Y-%m-%d %H:%M:%S]");
let log_line = format!("{} {}", timestamp, line);
println!("{}", log_line);
writeln!(&log_file, "{}", log_line).expect("Failed to write to log file");
}
_ => (),
};
}

View File

@ -8,7 +8,7 @@
},
"package": {
"productName": "Infinite Image Browsing",
"version": "0.8.0"
"version": "0.8.1"
},
"tauri": {
"allowlist": {