Fix shadowing of dnf module when module is executed directly
This commit is contained in:
parent
0eb825cdd8
commit
572f94eb87
@ -1,9 +1,17 @@
|
|||||||
from i3pystatus.updates import Backend
|
from i3pystatus.updates import Backend
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Remove first dir from sys.path to avoid shadowing dnf module from
|
||||||
|
# site-packages dir when this module executed directly on the CLI.
|
||||||
|
__module_dir = sys.path.pop(0)
|
||||||
try:
|
try:
|
||||||
import dnf
|
import dnf
|
||||||
HAS_DNF_BINDINGS = True
|
HAS_DNF_BINDINGS = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_DNF_BINDINGS = False
|
HAS_DNF_BINDINGS = False
|
||||||
|
finally:
|
||||||
|
# Replace the directory we popped earlier
|
||||||
|
sys.path.insert(0, __module_dir)
|
||||||
|
|
||||||
|
|
||||||
class Dnf(Backend):
|
class Dnf(Backend):
|
||||||
|
Loading…
Reference in New Issue
Block a user