[general] Add Python3 support

* Change some formatting to please python3
* remote pyroute2 dependency, for which I didn't find a python3 module
  in Fedora24

this solves #1
This commit is contained in:
Tobias Witek 2016-11-05 16:33:35 +01:00
parent caceb6f20f
commit 4e0e3ef427
7 changed files with 16 additions and 22 deletions

View file

@ -37,7 +37,7 @@ def get_dnf_info(obj):
bugfixes = 0
enhancements = 0
other = 0
for line in res.split("\n"):
for line in res.decode().split("\n"):
if not line.startswith(" "): continue
elif "ecurity" in line:
for s in str.split(line):

View file

@ -1,4 +1,3 @@
import pyroute2
import netifaces
import bumblebee.module
@ -39,14 +38,9 @@ class Module(bumblebee.module.Module):
return result
def _iswlan(self, intf):
iw = pyroute2.IW()
ip = pyroute2.IPRoute()
idx = ip.link_lookup(ifname=intf)[0]
try:
iw.get_interface_by_ifindex(idx)
return True
except Exception as e:
return False
# wifi, wlan, wlp, seems to work for me
if intf.startswith("w"): return True
return False
def _istunnel(self, intf):
return intf.startswith("tun")

View file

@ -41,7 +41,7 @@ class Module(bumblebee.module.Module):
res = subprocess.check_output(shlex.split("pactl info"))
channel = "sinks" if self._module == "pasink" else "sources"
name = None
for line in res.split("\n"):
for line in res.decode().split("\n"):
if line.startswith("Default Sink: ") and channel == "sinks":
name = line[14:]
if line.startswith("Default Source: ") and channel == "sources":
@ -50,7 +50,7 @@ class Module(bumblebee.module.Module):
res = subprocess.check_output(shlex.split("pactl list {}".format(channel)))
found = False
for line in res.split("\n"):
for line in res.decode().split("\n"):
if "Name:" in line and found == True:
break
if name in line:
@ -72,7 +72,7 @@ class Module(bumblebee.module.Module):
self._left = m.group(1)
self._right = m.group(2)
result = ""
if self._mono > 0:
if int(self._mono) > 0:
result = "{}%".format(self._mono)
elif self._left == self._right:
result = "{}%".format(self._left)

View file

@ -26,7 +26,7 @@ class Module(bumblebee.module.Module):
module = self.__module__.split(".")[-1]
self._fmt = self._config.parameter("format", default_format(module_format(module)))
self._fmt = self._config.parameter("format", default_format(module))
def widgets(self):
return bumblebee.output.Widget(self, datetime.datetime.now().strftime(self._fmt))