From d9f15faaf6a61380a51c99349932718a181513f4 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Sat, 3 May 2014 19:36:39 +0200 Subject: rename examples folder to the modules and prepare for installation --- MANIFEST.in | 2 +- examples/dpms.py | 44 ------------- examples/empty_class.py | 41 ------------ examples/glpi.py | 52 ---------------- examples/i3bar_click_events.py | 127 -------------------------------------- examples/netdata.py | 132 --------------------------------------- examples/ns_checker.py | 57 ----------------- examples/pingdom.py | 59 ------------------ examples/pomodoro.py | 123 ------------------------------------ examples/sysdata.py | 137 ----------------------------------------- examples/weather_yahoo.py | 106 ------------------------------- examples/whoami.py | 26 -------- modules/__init__.py | 0 modules/dpms.py | 44 +++++++++++++ modules/empty_class.py | 41 ++++++++++++ modules/glpi.py | 52 ++++++++++++++++ modules/i3bar_click_events.py | 127 ++++++++++++++++++++++++++++++++++++++ modules/netdata.py | 132 +++++++++++++++++++++++++++++++++++++++ modules/ns_checker.py | 57 +++++++++++++++++ modules/pingdom.py | 59 ++++++++++++++++++ modules/pomodoro.py | 123 ++++++++++++++++++++++++++++++++++++ modules/sysdata.py | 137 +++++++++++++++++++++++++++++++++++++++++ modules/weather_yahoo.py | 106 +++++++++++++++++++++++++++++++ modules/whoami.py | 26 ++++++++ 24 files changed, 905 insertions(+), 905 deletions(-) delete mode 100644 examples/dpms.py delete mode 100644 examples/empty_class.py delete mode 100644 examples/glpi.py delete mode 100644 examples/i3bar_click_events.py delete mode 100644 examples/netdata.py delete mode 100644 examples/ns_checker.py delete mode 100644 examples/pingdom.py delete mode 100644 examples/pomodoro.py delete mode 100644 examples/sysdata.py delete mode 100644 examples/weather_yahoo.py delete mode 100644 examples/whoami.py create mode 100644 modules/__init__.py create mode 100644 modules/dpms.py create mode 100644 modules/empty_class.py create mode 100644 modules/glpi.py create mode 100644 modules/i3bar_click_events.py create mode 100644 modules/netdata.py create mode 100644 modules/ns_checker.py create mode 100644 modules/pingdom.py create mode 100644 modules/pomodoro.py create mode 100644 modules/sysdata.py create mode 100644 modules/weather_yahoo.py create mode 100644 modules/whoami.py diff --git a/MANIFEST.in b/MANIFEST.in index 191f6ec..4bb9bbc 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ include *.rst -recursive-include examples *.py +recursive-include modules *.py diff --git a/examples/dpms.py b/examples/dpms.py deleted file mode 100644 index 783c53c..0000000 --- a/examples/dpms.py +++ /dev/null @@ -1,44 +0,0 @@ -from os import system - - -class Py3status: - """ - This module allows activation and deactivation - of DPMS (Display Power Management Signaling) - by clicking on 'DPMS' in the status bar. - - Written and contributed by @tasse: - Andre Doser - """ - def __init__(self): - """ - Detect current state on start. - """ - self.run = system('xset -q | grep -iq "DPMS is enabled"') == 0 - - def dpms(self, i3status_output_json, i3status_config): - """ - Display a colorful state of DPMS. - """ - result = { - 'full_text': 'DPMS', - 'name': 'dpms' - } - if self.run: - result['color'] = i3status_config['color_good'] - else: - result['color'] = i3status_config['color_bad'] - return (0, result) - - def on_click(self, json, i3status_config, event): - """ - Enable/Disable DPMS on left click. - """ - if event['button'] == 1: - if self.run: - self.run = False - system("xset -dpms") - else: - self.run = True - system("xset +dpms") - system("killall -USR1 py3status") diff --git a/examples/empty_class.py b/examples/empty_class.py deleted file mode 100644 index 077269c..0000000 --- a/examples/empty_class.py +++ /dev/null @@ -1,41 +0,0 @@ -class Py3status: - """ - Empty and basic py3status class. - - NOTE: py3status will NOT execute: - - methods starting with '_' - - methods decorated by @property and @staticmethod - - NOTE: reserved method names: - - 'kill' method for py3status exit notification - - 'on_click' method for click events from i3bar - """ - def kill(self, i3status_output_json, i3status_config): - """ - This method will be called upon py3status exit. - """ - pass - - def on_click(self, i3status_output_json, i3status_config, event): - """ - This method will be called when a click event occurs on this module's - output on the i3bar. - - Example 'event' json object: - {'y': 13, 'x': 1737, 'button': 1, 'name': 'empty', 'instance': 'first'} - """ - pass - - def empty(self, i3status_output_json, i3status_config): - """ - This method will return an empty text message - so it will NOT be displayed on your i3bar. - - If you want something displayed you should write something - in the 'full_text' key of your response. - - See the i3bar protocol spec for more information: - http://i3wm.org/docs/i3bar-protocol.html - """ - response = {'full_text': '', 'name': 'empty', 'instance': 'first'} - return (0, response) diff --git a/examples/glpi.py b/examples/glpi.py deleted file mode 100644 index 929749d..0000000 --- a/examples/glpi.py +++ /dev/null @@ -1,52 +0,0 @@ -# You need MySQL-python from http://pypi.python.org/pypi/MySQL-python -import MySQLdb - - -class Py3status: - """ - This example class demonstrates how to display the current total number of - open tickets from GLPI in your i3bar. - - It features thresholds to colorize the output and forces a low timeout to - limit the impact of a server connectivity problem on your i3bar freshness. - - Note that we don't have to implement a cache layer as it is handled by - py3status automagically. - """ - def count_glpi_open_tickets(self, json, i3status_config): - response = {'full_text': '', 'name': 'glpi_tickets'} - - # user-defined variables - CRIT_THRESHOLD = 20 - WARN_THRESHOLD = 15 - MYSQL_DB = '' - MYSQL_HOST = '' - MYSQL_PASSWD = '' - MYSQL_USER = '' - POSITION = 0 - - mydb = MySQLdb.connect( - host=MYSQL_HOST, - user=MYSQL_USER, - passwd=MYSQL_PASSWD, - db=MYSQL_DB, - connect_timeout=5, - ) - mycr = mydb.cursor() - mycr.execute('''select count(*) - from glpi_tickets - where closedate is NULL and solvedate is NULL;''') - row = mycr.fetchone() - if row: - open_tickets = int(row[0]) - if i3status_config['colors']: - if open_tickets > CRIT_THRESHOLD: - response.update({'color': i3status_config['color_bad']}) - elif open_tickets > WARN_THRESHOLD: - response.update( - {'color': i3status_config['color_degraded']} - ) - response['full_text'] = '%s tickets' % open_tickets - mydb.close() - - return (POSITION, response) diff --git a/examples/i3bar_click_events.py b/examples/i3bar_click_events.py deleted file mode 100644 index 792965c..0000000 --- a/examples/i3bar_click_events.py +++ /dev/null @@ -1,127 +0,0 @@ -from subprocess import Popen -from time import time - - -class Py3status: - """ - This module allows you to take actions based on click events made on - the i3status modules. For example, thanks to this module you could - launch the wicd GUI when clicking on the ethernet or wireless module - of your i3status output ! - - IMPORTANT: - This module file name is reserved and should NOT be changed if you - want py3status to handle your i3status modules click events ! - - The behavior described above will only work if this file is named - 'i3bar_click_events.py' ! - """ - def __init__(self): - """ - This is where you setup your actions based on your i3status config. - - Configuration: - -------------- - self.actions = { - "": { -