File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 11// You can copy/paste this file every time you need a simple GObject
22// to hold some data
33
4+ use anyhow:: Context ;
45use futures:: prelude:: * ;
56use glib:: subclass:: prelude:: * ;
67use glib:: Properties ;
@@ -10,9 +11,9 @@ use std::cell::OnceCell;
1011use std:: cell:: RefCell ;
1112use std:: path:: Path ;
1213use std:: time:: Duration ;
14+ use tracing:: { debug, warn} ;
1315use tracing:: error;
1416use tracing:: info;
15- use tracing:: { debug, warn} ;
1617
1718use crate :: container:: Container ;
1819use crate :: distrobox;
@@ -400,15 +401,20 @@ impl RootStore {
400401 // uses lspci to check if the host has an NVIDIA GPU
401402 debug ! ( "Checking if host is NVIDIA" ) ;
402403 let cmd = Command :: new ( "lspci" ) ;
403- let output = self . run_to_string ( cmd) . await ;
404+ let output = glib:: future_with_timeout ( Duration :: from_secs ( 2 ) , async move {
405+ self . run_to_string ( cmd) . await . context ( "Calling lspci" )
406+ } )
407+ . await
408+ . context ( "timeout" )
409+ . flatten ( ) ;
404410 match output {
405411 Ok ( output) => {
406412 let is_nvidia = output. contains ( "NVIDIA" ) || output. contains ( "nVidia" ) ;
407- debug ! ( is_nvidia, "Checked if host is NVIDIA " ) ;
413+ debug ! ( is_nvidia, "lspci ran successfully " ) ;
408414 is_nvidia
409415 }
410416 Err ( e) => {
411- debug ! ( ?e, "Failed to check if host is NVIDIA" ) ;
417+ warn ! ( ?e, "Failed to check if host is NVIDIA" ) ;
412418 false // If we can't run lspci, we assume it's not NVIDIA
413419 }
414420 }
You can’t perform that action at this time.
0 commit comments