@@ -385,6 +385,14 @@ def check_whenever_version() -> bool:
385385
386386# return the output of `whenever --options`
387387def retrieve_whenever_options () -> None :
388+ # first assume no feature is available
389+ AppConfig .set ("WHENEVER_HAS_DBUS" , False )
390+ AppConfig .set ("WHENEVER_HAS_WMI" , False )
391+ AppConfig .set ("WHENEVER_HAS_LUAHTTP" , False )
392+ AppConfig .set ("WHENEVER_HAS_LUASYNC" , False )
393+ # ...other options might appear above here
394+
395+ # then ask the executable for options
388396 whenever_path : str = AppConfig .get ("WHENEVER" ) # type: ignore
389397 try :
390398 result = subprocess .run (
@@ -397,37 +405,34 @@ def retrieve_whenever_options() -> None:
397405 subprocess .CREATE_NO_WINDOW if sys .platform .startswith ("win" ) else 0
398406 ),
399407 )
400- except Exception :
401- # maybe no executable has been found?
402- AppConfig .set ("WHENEVER_HAS_DBUS" , False )
403- AppConfig .set ("WHENEVER_HAS_WMI" , False )
404- # ...other options might appear
405- return None
406- if result :
407- # output has the form: `options: [wmi] [dbus]`, each one might or
408- # might not be present in the output, so we check whether the list
409- # below contains or not one of them
410- if result .returncode == 0 :
411- opts = result .stdout .strip ().split ()
412- if "dbus" in opts :
413- AppConfig .set ("WHENEVER_HAS_DBUS" , True )
414- else :
415- AppConfig .set ("WHENEVER_HAS_DBUS" , False )
416- if sys .platform .startswith ("win" ) and "wmi" in opts :
417- AppConfig .set ("WHENEVER_HAS_WMI" , True )
408+ if result :
409+ # output has the form: `options: <opt1> <opt2> ..`, each one might
410+ # or might not be present in the output, so we check whether the
411+ # list below contains or not one of them
412+ if result .returncode == 0 :
413+ opts = result .stdout .strip ().split ()
414+ if opts [0 ] != "options" :
415+ # maybe it is not the `whenever` we are looking for?
416+ return
417+ opts = opts [1 :]
418+ if "dbus" in opts :
419+ AppConfig .set ("WHENEVER_HAS_DBUS" , True )
420+ if sys .platform .startswith ("win" ) and "wmi" in opts :
421+ AppConfig .set ("WHENEVER_HAS_WMI" , True )
422+ if "lua_sync" in opts :
423+ AppConfig .set ("WHENEVER_HAS_LUASYNC" , True )
424+ if "lua_httpreq" in opts :
425+ AppConfig .set ("WHENEVER_HAS_LUAHTTPREQ" , True )
426+ # ...other options might appear
418427 else :
419- AppConfig . set ( "WHENEVER_HAS_WMI" , False )
420- # ...other options might appear
428+ # this might be an older version, assume DBus is available
429+ AppConfig . set ( "WHENEVER_HAS_DBUS" , True )
421430 else :
422- # this might be an older version, assume DBus is available
431+ # this too might be an older version, assume DBus is available
423432 AppConfig .set ("WHENEVER_HAS_DBUS" , True )
424- AppConfig .set ("WHENEVER_HAS_WMI" , False )
425- # ...other options might appear
426- else :
427- # this might be an older version, assume DBus is available
428- AppConfig .set ("WHENEVER_HAS_DBUS" , True )
429- AppConfig .set ("WHENEVER_HAS_WMI" , False )
430- # ...other options might appear
433+ except Exception :
434+ # maybe no executable has been found? Still, no available option.
435+ return
431436
432437
433438# check whether the scheduler is running
@@ -453,16 +458,23 @@ def is_whenever_running() -> None | bool:
453458 return False
454459
455460
456- # a couple of shortcuts for whenever options
461+ # some shortcuts for whenever options
457462def whenever_has_dbus () -> bool :
458463 res = bool (AppConfig .get ("WHENEVER_HAS_DBUS" ))
459464 return res
460465
461-
462466def whenever_has_wmi () -> bool :
463467 res = bool (AppConfig .get ("WHENEVER_HAS_WMI" ))
464468 return res
465469
470+ def whenever_has_lua_sync () -> bool :
471+ res = bool (AppConfig .get ("WHENEVER_HAS_LUASYNC" ))
472+ return res
473+
474+ def whenever_has_luahttpreq () -> bool :
475+ res = bool (AppConfig .get ("WHENEVER_HAS_LUAHTTPREQ" ))
476+ return res
477+
466478
467479# return the configuration file path
468480def get_configfile () -> str :
0 commit comments