This commit is contained in:
enkore 2014-04-30 14:51:08 +02:00
parent 14d9427ac8
commit f06a76ad52
40 changed files with 56 additions and 75 deletions

View File

@ -1,4 +1,3 @@
from pkgutil import extend_path
from i3pystatus.core import Status

View File

@ -4,7 +4,6 @@ from i3pystatus import IntervalModule
class ALSA(IntervalModule):
"""
Shows volume of ALSA mixer. You can also use this for inputs, btw.

View File

@ -2,7 +2,6 @@ from i3pystatus.file import File
class Backlight(File):
"""
Screen backlight info

View File

@ -73,7 +73,8 @@ class BatteryCharge(Battery):
else:
return -1
else:
return (self.battery_info["CHARGE_FULL"] - self.battery_info["CHARGE_NOW"]) / self.battery_info["CURRENT_NOW"] * 60
return (self.battery_info["CHARGE_FULL"] - self.battery_info["CHARGE_NOW"]) / self.battery_info[
"CURRENT_NOW"] * 60
class BatteryEnergy(Battery):
@ -88,7 +89,8 @@ class BatteryEnergy(Battery):
# Wh / W = h * 60 min = min
return self.battery_info["ENERGY_NOW"] / self.battery_info["POWER_NOW"] * 60
else:
return (self.battery_info["ENERGY_FULL"] - self.battery_info["ENERGY_NOW"]) / self.battery_info["POWER_NOW"] * 60
return (self.battery_info["ENERGY_FULL"] - self.battery_info["ENERGY_NOW"]) / self.battery_info[
"POWER_NOW"] * 60
class BatteryChecker(IntervalModule):

View File

@ -9,7 +9,6 @@ from i3pystatus import IntervalModule
class Clock(IntervalModule):
"""
This class shows a clock
"""

View File

@ -1,4 +1,3 @@
import sys
import os
from threading import Thread
@ -75,8 +74,8 @@ class Status:
raise import_error
except ConfigError as configuration_error:
return self.modules.append(Text(
color="#FF0000",
text=configuration_error.message))
color="#FF0000",
text=configuration_error.message))
def run(self):
self.command_endpoint.start()

View File

@ -1,4 +1,3 @@
class BaseDesktopNotification:
"""
Class to display a desktop notification
@ -25,9 +24,11 @@ class BaseDesktopNotification:
"""
return False
class DesktopNotification(BaseDesktopNotification):
pass
try:
from gi.repository import Notify
except ImportError:

View File

@ -1,4 +1,3 @@
class ConfigError(Exception):
"""ABC for configuration exceptions"""

View File

@ -17,6 +17,7 @@ class ClassFinder:
issubclass(obj, self.baseclass) and
obj.__module__ == module.__name__
)
return predicate
def get_matching_classes(self, module):

View File

@ -1,4 +1,3 @@
import time
import json
import sys
@ -6,7 +5,6 @@ from contextlib import contextmanager
class IOHandler:
def __init__(self, inp=sys.stdin, out=sys.stdout):
self.inp = inp
self.out = out
@ -45,7 +43,6 @@ class IOHandler:
class StandaloneIO(IOHandler):
"""
I/O handler for standalone usage of i3pystatus (w/o i3status)
@ -76,7 +73,6 @@ class StandaloneIO(IOHandler):
class JSONIO:
def __init__(self, io, skiplines=2):
self.io = io
for i in range(skiplines):

View File

@ -1,4 +1,3 @@
from i3pystatus.core.settings import SettingsBase
from i3pystatus.core.threading import Manager
from i3pystatus.core.util import convert_position
@ -45,7 +44,7 @@ class IntervalModuleMeta(type):
super(IntervalModuleMeta, cls).__init__(name, bases, namespace)
if not hasattr(cls, 'settings'):
cls.settings = tuple()
if not 'interval' in SettingsBase.flatten_settings(cls.settings):
if 'interval' not in SettingsBase.flatten_settings(cls.settings):
cls.settings += ('interval', )

View File

@ -3,7 +3,6 @@ from i3pystatus.core.exceptions import ConfigKeyError, ConfigMissingError
class SettingsBase:
"""
Support class for providing a nice and flexible settings interface
@ -64,4 +63,5 @@ class SettingsBase:
def flatten_settings(settings):
def flatten_setting(setting):
return setting[0] if isinstance(setting, tuple) else setting
return tuple(flatten_setting(setting) for setting in settings)

View File

@ -8,7 +8,6 @@ timer = time.perf_counter if hasattr(time, "perf_counter") else time.clock
class Thread(threading.Thread):
def __init__(self, target_interval, workloads=None, start_barrier=1):
super().__init__()
self.workloads = workloads or []
@ -56,7 +55,6 @@ class Thread(threading.Thread):
class Wrapper:
def __init__(self, workload):
self.workload = workload
@ -65,7 +63,6 @@ class Wrapper:
class ExceptionWrapper(Wrapper):
def __call__(self):
try:
self.workload()
@ -88,7 +85,6 @@ class WorkloadWrapper(Wrapper):
class Manager:
def __init__(self, target_interval):
self.target_interval = target_interval
self.upper_bound = target_interval * 1.1

View File

@ -1,4 +1,3 @@
import collections
import functools
import re
@ -177,6 +176,7 @@ def formatp(string, **kwargs):
They also have a string property containing associated text (empty for
all tokens but String tokens).
"""
class Token:
string = ""
@ -333,13 +333,16 @@ def require(predicate):
:py:func:`internet`
"""
def decorator(method):
@functools.wraps(method)
def wrapper(*args, **kwargs):
if predicate():
return method(*args, **kwargs)
return None
return wrapper
return decorator

View File

@ -15,19 +15,16 @@ class CpuUsage(IntervalModule):
"""
format = "{usage:02}%"
settings = (
("format", "format string"),
)
def init(self):
self.prev_idle = 0
self.prev_busy = 0
self.interval = 1
def get_usage(self):
"""
parses /proc/stat and calcualtes total and busy time
@ -43,7 +40,6 @@ class CpuUsage(IntervalModule):
return cpu_total, cpu_busy
def run(self):
cpu_total, cpu_busy = self.get_usage()
@ -58,7 +54,5 @@ class CpuUsage(IntervalModule):
self.output = {
"full_text": self.format.format(
usage=cpu_busy_percentage
)
)
}

View File

@ -5,7 +5,6 @@ from .core.util import round_dict
class Disk(IntervalModule):
"""
Gets ``{used}``, ``{free}``, ``{available}`` and ``{total}`` amount of bytes on the given mounted filesystem.

View File

@ -4,12 +4,11 @@ from i3pystatus import IntervalModule
class File(IntervalModule):
"""
Rip information from text files
components is a dict of pairs of the form:
::
name => (callable, file)

View File

@ -2,7 +2,6 @@ from i3pystatus import IntervalModule
class Load(IntervalModule):
"""
Shows system load
"""

View File

@ -1,11 +1,9 @@
import subprocess
from i3pystatus import SettingsBase, IntervalModule
class Backend(SettingsBase):
"""Handles the details of checking for mail"""
unread = 0
@ -15,7 +13,6 @@ class Backend(SettingsBase):
class Mail(IntervalModule):
"""
Generic mail checker

View File

@ -8,7 +8,6 @@ from i3pystatus.mail import Backend
class IMAP(Backend):
"""
Checks for mail on a IMAP server
"""
@ -56,4 +55,5 @@ class IMAP(Backend):
else:
sys.stderr.write("no connection")
Backend = IMAP

View File

@ -5,23 +5,25 @@ import sys
from i3pystatus.mail import Backend
import subprocess
class MaildirMail(Backend):
"""
Checks for local mail in Maildir
"""
settings = (
"directory",
)
"directory",
)
required = ("directory",)
directory=""
directory = ""
@property
def unread(self):
p = subprocess.Popen(['ls','-l',self.directory+'/new'], stdout=subprocess.PIPE)
p = subprocess.Popen(['ls', '-l', self.directory + '/new'], stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
stdout=stdout.decode('utf8')
return len(stdout.split('\n'))-2
stdout = stdout.decode('utf8')
return len(stdout.split('\n')) - 2
Backend = MaildirMail

View File

@ -5,6 +5,7 @@ import sys
from i3pystatus.mail import Backend
import subprocess
class MboxMail(Backend):
"""
Checks for local mail in mbox
@ -22,4 +23,5 @@ class MboxMail(Backend):
s_stuff, message_number = stdout.strip().rsplit(':', 1)
return int(message_number.strip())
Backend = MboxMail

View File

@ -9,7 +9,6 @@ from i3pystatus.mail import Backend
class Notmuch(Backend):
"""
This class uses the notmuch python bindings to check for the
number of messages in the notmuch database with the tags "inbox"
@ -25,4 +24,5 @@ class Notmuch(Backend):
def unread(self):
return notmuch.Query(self.db, "tag:unread and tag:inbox").count_messages()
Backend = Notmuch

View File

@ -17,7 +17,6 @@ from i3pystatus.mail import Backend
class Thunderbird(Backend):
"""
This class listens for dbus signals emitted by
the dbus-sender extension for thunderbird.
@ -55,4 +54,5 @@ class Thunderbird(Backend):
self.run()
return len(self._unread)
Backend = Thunderbird

View File

@ -27,14 +27,14 @@ class Mem(IntervalModule):
settings = (
("format", "format string used for output."),
("divisor",
"divide all byte values by this value, default 1024**2(mebibytes"),
"divide all byte values by this value, default 1024**2(mebibytes"),
("warn_percentage", "minimal percentage for warn state"),
("alert_percentage", "minimal percentage for alert state"),
("color", "standard color"),
("warn_color",
"defines the color used wann warn percentage ist exceeded"),
"defines the color used wann warn percentage ist exceeded"),
("alert_color",
"defines the color used when alert percentage is exceeded"),
"defines the color used when alert percentage is exceeded"),
)
def run(self):
@ -55,5 +55,5 @@ class Mem(IntervalModule):
avail_mem=memory_usage.available / self.divisor,
total_mem=memory_usage.total / self.divisor,
percent_used_mem=memory_usage.percent),
"color":color
"color": color
}

View File

@ -126,6 +126,7 @@ def get_all(module_path, heading, finder=None, ignore=None):
def generate_doc_for_module(module_path, heading="+", finder=None, ignore=None):
return "".join(map(str, get_all(module_path, heading, finder, ignore or [])))
with open("README.tpl.rst", "r") as template:
tpl = template.read()
tpl = tpl.replace(

View File

@ -12,7 +12,6 @@ from i3pystatus import IntervalModule
class ModsDeChecker(IntervalModule):
"""
This class returns i3status parsable output of the number of
unread posts in any bookmark in the mods.de forums.

View File

@ -1,4 +1,3 @@
import socket
from i3pystatus import IntervalModule, formatp
@ -10,7 +9,6 @@ def format_time(seconds):
class MPD(IntervalModule):
"""
Displays various information from MPD (the music player daemon)
@ -101,7 +99,7 @@ class MPD(IntervalModule):
def on_leftclick(self):
try:
self._mpd_command(self.s, "pause %i" %
(0 if self._mpd_command(self.s, "status")["state"] == "pause" else 1))
(0 if self._mpd_command(self.s, "status")["state"] == "pause" else 1))
except Exception as e:
pass

View File

@ -11,7 +11,7 @@ from i3pystatus import IntervalModule
def count_bits(integer):
bits = 0
while(integer):
while (integer):
integer &= integer - 1
bits += 1
return bits
@ -47,7 +47,6 @@ def cidr4(addr, mask):
class Network(IntervalModule):
"""
Display network information about a interface.
@ -122,7 +121,7 @@ class Network(IntervalModule):
fdict["v6"] = v6["addr"]
fdict["v6mask"] = v6["netmask"]
fdict["v6cidr"] = cidr6(v6["addr"], v6["netmask"])
if not v6["addr"].startswith("fe80::"): # prefer non link-local addresses
if not v6["addr"].startswith("fe80::"): # prefer non link-local addresses
break
else:
format = self.format_down

View File

@ -1,4 +1,3 @@
from urllib.request import urlopen
import webbrowser
@ -10,7 +9,6 @@ from i3pystatus.core.util import internet, require
class TrackerAPI:
def __init__(self, idcode):
pass
@ -41,7 +39,7 @@ class DHL(TrackerAPI):
if 'active' in picture_link:
status = ''.join(element.xpath('./img/@alt'))
progress = '%i' % (i/len(elements)*100)
progress = '%i' % (i / len(elements) * 100)
elif 'default' in picture_link:
break
@ -51,7 +49,6 @@ class DHL(TrackerAPI):
def status(self):
ret = {}
with urlopen(self.url) as page:
#with open('/home/marcel/ownCloud/dhl_site/paketzentrum/DHL Sendungsverfolgung.htm', 'r') as page:
page = lxml.html.fromstring(page.read())
if not self.error(page):

View File

@ -4,7 +4,6 @@ from i3pystatus import Module
class PulseAudio(Module):
"""
Shows volume of default PulseAudio sink (output).
@ -107,4 +106,5 @@ class PulseAudio(Module):
def on_leftclick(self):
import subprocess
subprocess.Popen(["pavucontrol"])

View File

@ -31,6 +31,8 @@ class pa_format_info(Structure):
class pa_context(Structure):
pass
pa_context._fields_ = [
]
pa_context_notify_cb_t = CFUNCTYPE(None, POINTER(pa_context), c_void_p)
@ -39,12 +41,16 @@ pa_context_success_cb_t = CFUNCTYPE(None, POINTER(pa_context), c_int, c_void_p)
class pa_proplist(Structure):
pass
pa_context_event_cb_t = CFUNCTYPE(
None, POINTER(pa_context), STRING, POINTER(pa_proplist), c_void_p)
class pa_mainloop_api(Structure):
pass
pa_context_new = _libraries['libpulse.so.0'].pa_context_new
pa_context_new.restype = POINTER(pa_context)
pa_context_new.argtypes = [POINTER(pa_mainloop_api), STRING]
@ -85,6 +91,7 @@ class pa_spawn_api(Structure):
('atfork', CFUNCTYPE(None)),
]
pa_context_connect = _libraries['libpulse.so.0'].pa_context_connect
pa_context_connect.restype = c_int
pa_context_connect.argtypes = [
@ -155,6 +162,8 @@ class pa_channel_map(Structure):
('channels', c_uint8),
('map', pa_channel_position_t * 32),
]
pa_sink_info._fields_ = [
('name', STRING),
('index', c_uint32),
@ -202,6 +211,8 @@ pa_context_get_sink_info_list.argtypes = [
class pa_server_info(Structure):
pass
pa_server_info._fields_ = [
('user_name', STRING),
('host_name', STRING),
@ -224,6 +235,8 @@ pa_context_get_server_info.argtypes = [
class pa_threaded_mainloop(Structure):
pass
pa_threaded_mainloop._fields_ = [
]
pa_threaded_mainloop_new = _libraries['libpulse.so.0'].pa_threaded_mainloop_new
@ -278,7 +291,6 @@ pa_sw_volume_to_dB = _libraries['libpulse.so.0'].pa_sw_volume_to_dB
pa_sw_volume_to_dB.restype = c_double
pa_sw_volume_to_dB.argtypes = [pa_volume_t]
pa_operation_unref = _libraries['libpulse.so.0'].pa_operation_unref
pa_operation_unref.restype = None
pa_operation_unref.argtypes = [POINTER(pa_operation)]

View File

@ -1,4 +1,3 @@
import urllib.request
import urllib.parse
import urllib.error
@ -10,7 +9,6 @@ from i3pystatus import IntervalModule
class pyLoad(IntervalModule):
"""
Shows pyLoad status
@ -46,7 +44,8 @@ class pyLoad(IntervalModule):
if not data:
data = {}
urlencoded = urllib.parse.urlencode(data).encode("ascii")
return json.loads(self.opener.open("{address}/api/{method}/".format(address=self.address, method=method), urlencoded).read().decode("utf-8"))
return json.loads(self.opener.open("{address}/api/{method}/".format(address=self.address, method=method),
urlencoded).read().decode("utf-8"))
def init(self):
self.cj = http.cookiejar.CookieJar()

View File

@ -4,7 +4,6 @@ from i3pystatus import IntervalModule
class Regex(IntervalModule):
"""
Simple regex file watcher

View File

@ -5,7 +5,6 @@ from i3pystatus import IntervalModule
class RunWatch(IntervalModule):
"""
Expands the given path using glob to a pidfile and checks
if the process ID found inside is valid

View File

@ -6,7 +6,6 @@ from gi.repository import Playerctl, GLib
class Spotify(Module):
"""
This class shows information from Spotify.
@ -39,7 +38,7 @@ class Spotify(Module):
except Exception as e:
self.output = {
"full_text": "Error creating new thread!",
"color" : "#FF0000"
"color": "#FF0000"
}
def on_track_change(self, player, e):

View File

@ -5,7 +5,6 @@ from i3pystatus import IntervalModule
class Temperature(IntervalModule):
"""
Shows CPU temperature of Intel processors

View File

@ -2,7 +2,6 @@ from i3pystatus import Module
class Text(Module):
"""
Display static, colored text.
"""

View File

@ -4,7 +4,6 @@ from i3pystatus.core.util import internet, require
class Weather(IntervalModule):
"""
This module gets the weather from weather.com using pywapi module
First, you need to get the code for the location from the www.weather.com

View File

@ -1,11 +1,9 @@
import basiciw
from i3pystatus.network import Network
class Wireless(Network):
"""
Display network information about a interface.