mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-03 05:54:33 +00:00
Update python_util.rs
This commit is contained in:
parent
2f881f1398
commit
1f07d8fc1a
1 changed files with 6 additions and 3 deletions
|
@ -11,10 +11,14 @@ pub fn which_python() -> String {
|
||||||
.arg(python)
|
.arg(python)
|
||||||
.output()
|
.output()
|
||||||
.expect("python not found");
|
.expect("python not found");
|
||||||
String::from_utf8(out.stdout)
|
let res = String::from_utf8(out.stdout)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.replace("\n", "")
|
.replace("\n", "")
|
||||||
.replace("\r", "")
|
.replace("\r", "");
|
||||||
|
if res == "" {
|
||||||
|
panic!("python not found");
|
||||||
|
}
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn detect_magic_number() -> u32 {
|
pub fn detect_magic_number() -> u32 {
|
||||||
|
@ -28,7 +32,6 @@ pub fn detect_magic_number() -> u32 {
|
||||||
.output()
|
.output()
|
||||||
.expect("cannot get the magic number from python");
|
.expect("cannot get the magic number from python");
|
||||||
let s_hex_magic_num = String::from_utf8(out.stdout).unwrap();
|
let s_hex_magic_num = String::from_utf8(out.stdout).unwrap();
|
||||||
dbg!(&s_hex_magic_num);
|
|
||||||
let first_byte = u8::from_str_radix(&s_hex_magic_num[0..=1], 16).unwrap();
|
let first_byte = u8::from_str_radix(&s_hex_magic_num[0..=1], 16).unwrap();
|
||||||
let second_byte = u8::from_str_radix(&s_hex_magic_num[2..=3], 16).unwrap();
|
let second_byte = u8::from_str_radix(&s_hex_magic_num[2..=3], 16).unwrap();
|
||||||
get_magic_num_from_bytes(&[first_byte, second_byte, 0, 0])
|
get_magic_num_from_bytes(&[first_byte, second_byte, 0, 0])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue