本文整理汇总了Python中py3status.module_test.module_test函数的典型用法代码示例。如果您正苦于以下问题:Python module_test函数的具体用法?Python module_test怎么用?Python module_test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了module_test函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dict
vnstat_data = self.py3.command_output("vnstat --oneline b")
values = vnstat_data.splitlines()[0].split(";")[self.slice]
stat = dict(zip(["down", "up", "total"], map(int, values)))
response = {"cached_until": self.py3.time_in(self.cache_timeout)}
if self.coloring:
response["color"] = self.py3.threshold_get_color(stat["total"])
for x in self.thresholds_init:
if x in stat:
self.py3.threshold_get_color(stat[x], x)
response["full_text"] = self.py3.safe_format(
self.format,
dict(
total=self._divide_and_format(stat["total"]),
up=self._divide_and_format(stat["up"]),
down=self._divide_and_format(stat["down"]),
),
)
return response
if __name__ == "__main__":
"""
Run module in test mode.
"""
from py3status.module_test import module_test
module_test(Py3status)
示例2: window_title
conn.on('workspace::focus', clear_title)
# clears the title when the last window on ws was closed
conn.on("window::close", clear_title)
# listens for events which can trigger the title update
conn.on("window::title", update_title)
conn.on("window::focus", update_title)
conn.on("binding", update_title)
conn.main() # run the event loop
def window_title(self):
resp = {
'cached_until': self.py3.CACHE_FOREVER,
'full_text': self.title,
}
return resp
if __name__ == "__main__":
"""
Run module in test mode.
"""
config = {
'always_show': True,
}
from py3status.module_test import module_test
module_test(Py3status, config=config)
示例3: module_test
]
)
module_test(
Py3status,
config={
"api_key": os.getenv("OWM_API_KEY"),
# Select icons
"icons": {"200": "☔", "230_232": "🌧"},
# Complete configuration
"format_clouds": "{icon} {coverage}%",
"format_humidity": "{icon} {humidity}%",
"format_pressure": "{icon} {pressure} Pa, sea: {sea_level} Pa",
"format_rain": "{icon} {amount:.0f} in",
"format_snow": "{icon} {amount:.0f} in",
"format_temperature": (
"{icon}: max: [\?color=max {max:.0f}°F], "
"min: [\?color=min {min:.0f}°F], "
"current: [\?color=current {current:.0f}°F]"
),
"format_wind": (
"{icon} {degree}°, gust: {gust:.0f} mph, " "speed: {speed:.0f} mph"
),
"format": ("{city}, {country}: {icon} " + all_string + "//{forecast}"),
"format_forecast": ("{icon} " + all_string),
# Miscellaneous
"forecast_days": 1,
"forecast_text_separator": "//",
},
)
示例4: _command_start
)
return response
def _command_start(self):
try:
command = Popen(shlex.split(self.script_path), stdout=PIPE)
while True:
if command.poll() is not None: # script has exited/died; restart it
command = Popen(shlex.split(self.script_path), stdout=PIPE)
output = command.stdout.readline().decode().strip()
if re.search(r"^#[0-9a-fA-F]{6}$", output) and not self.force_nocolor:
self.command_color = output
else:
if output != self.command_output:
self.command_output = output
self.py3.update()
except Exception as e:
self.command_error = str(e)
self.py3.update()
if __name__ == "__main__":
"""
Run module in test mode.
"""
from py3status.module_test import module_test
module_test(Py3status, config={"script_path": "ping 127.0.0.1"})
示例5: module_test
'{wind}'
])
module_test(Py3status, config={
'api_key': os.getenv('OWM_API_KEY'),
# Select icons
'icons': {
'200': "☔",
'230_232': "🌧",
},
# Complete configuration
'format_clouds': '{icon} {coverage}%',
'format_humidity': '{icon} {humidity}%',
'format_pressure': '{icon} {pressure} Pa, sea: {sea_level} Pa',
'format_rain': '{icon} {amount:.0f} in',
'format_snow': '{icon} {amount:.0f} in',
'format_temperature': ('{icon}: max: [\?color=max {max:.0f}°F], '
'min: [\?color=min {min:.0f}°F], '
'current: [\?color=current {current:.0f}°F]'),
'format_wind': ('{icon} {degree}°, gust: {gust:.0f} mph, '
'speed: {speed:.0f} mph'),
'format': ('{city}, {country}: {icon} ' + all_string + '//{forecast}'),
'format_forecast': ('{icon} ' + all_string),
# Miscellaneous
'forecast_days': 1,
'forecast_text_separator': '//',
})