Merge branch 'fix-788' into develop
This commit is contained in:
commit
173159aea4
|
@ -0,0 +1,13 @@
|
|||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str # NOQA
|
||||
|
||||
|
||||
def u(s):
|
||||
if type(s) is unicode:
|
||||
return s
|
||||
else:
|
||||
return unicode(s, 'utf-8')
|
|
@ -17,6 +17,7 @@ from powerline.lib.vcs import guess, tree_status
|
|||
from powerline.lib.threaded import ThreadedSegment, KwThreadedSegment, with_docstring
|
||||
from powerline.lib.monotonic import monotonic
|
||||
from powerline.lib.humanize_bytes import humanize_bytes
|
||||
from powerline.lib.unicode import u
|
||||
from powerline.theme import requires_segment_info
|
||||
from collections import namedtuple
|
||||
|
||||
|
@ -91,7 +92,7 @@ def cwd(pl, segment_info, dir_shorten_len=None, dir_limit_depth=None, use_path_s
|
|||
Highlight groups used: ``cwd:current_folder`` or ``cwd``. It is recommended to define all highlight groups.
|
||||
'''
|
||||
try:
|
||||
cwd = segment_info['getcwd']()
|
||||
cwd = u(segment_info['getcwd']())
|
||||
except OSError as e:
|
||||
if e.errno == 2:
|
||||
# user most probably deleted the directory
|
||||
|
@ -100,7 +101,7 @@ def cwd(pl, segment_info, dir_shorten_len=None, dir_limit_depth=None, use_path_s
|
|||
cwd = "[not found]"
|
||||
else:
|
||||
raise
|
||||
home = segment_info['home']
|
||||
home = u(segment_info['home'])
|
||||
if home:
|
||||
cwd = re.sub('^' + re.escape(home), '~', cwd, 1)
|
||||
cwd_split = cwd.split(os.sep)
|
||||
|
@ -335,7 +336,7 @@ class WeatherSegment(ThreadedSegment):
|
|||
import json
|
||||
|
||||
if not self.url:
|
||||
# Do not lock attribute assignments in this branch: they are used
|
||||
# Do not lock attribute assignments in this branch: they are used
|
||||
# only in .update()
|
||||
if not self.location:
|
||||
location_data = json.loads(urllib_read('http://freegeoip.net/json/'))
|
||||
|
@ -428,12 +429,12 @@ weather conditions.
|
|||
:param str temp_format:
|
||||
format string, receives ``temp`` as an argument. Should also hold unit.
|
||||
:param float temp_coldest:
|
||||
coldest temperature. Any temperature below it will have gradient level equal
|
||||
coldest temperature. Any temperature below it will have gradient level equal
|
||||
to zero.
|
||||
:param float temp_hottest:
|
||||
hottest temperature. Any temperature above it will have gradient level equal
|
||||
to 100. Temperatures between ``temp_coldest`` and ``temp_hottest`` receive
|
||||
gradient level that indicates relative position in this interval
|
||||
hottest temperature. Any temperature above it will have gradient level equal
|
||||
to 100. Temperatures between ``temp_coldest`` and ``temp_hottest`` receive
|
||||
gradient level that indicates relative position in this interval
|
||||
(``100 * (cur-coldest) / (hottest-coldest)``).
|
||||
|
||||
Divider highlight group used: ``background:divider``.
|
||||
|
@ -453,17 +454,17 @@ def system_load(pl, format='{avg:.1f}', threshold_good=1, threshold_bad=2, track
|
|||
:param str format:
|
||||
format string, receives ``avg`` as an argument
|
||||
:param float threshold_good:
|
||||
threshold for gradient level 0: any normalized load average below this
|
||||
threshold for gradient level 0: any normalized load average below this
|
||||
value will have this gradient level.
|
||||
:param float threshold_bad:
|
||||
threshold for gradient level 100: any normalized load average above this
|
||||
value will have this gradient level. Load averages between
|
||||
``threshold_good`` and ``threshold_bad`` receive gradient level that
|
||||
threshold for gradient level 100: any normalized load average above this
|
||||
value will have this gradient level. Load averages between
|
||||
``threshold_good`` and ``threshold_bad`` receive gradient level that
|
||||
indicates relative position in this interval:
|
||||
(``100 * (cur-good) / (bad-good)``).
|
||||
Note: both parameters are checked against normalized load averages.
|
||||
:param bool track_cpu_count:
|
||||
if True powerline will continuously poll the system to detect changes
|
||||
if True powerline will continuously poll the system to detect changes
|
||||
in the number of CPUs.
|
||||
|
||||
Divider highlight group used: ``background:divider``.
|
||||
|
@ -629,7 +630,7 @@ elif 'psutil' in globals():
|
|||
from time import time
|
||||
|
||||
def _get_uptime(): # NOQA
|
||||
# psutil.BOOT_TIME is not subject to clock adjustments, but time() is.
|
||||
# psutil.BOOT_TIME is not subject to clock adjustments, but time() is.
|
||||
# Thus it is a fallback to /proc/uptime reading and not the reverse.
|
||||
return int(time() - psutil.BOOT_TIME)
|
||||
else:
|
||||
|
@ -780,10 +781,10 @@ falls back to reading
|
|||
:param str sent_format:
|
||||
format string, receives ``value`` as argument
|
||||
:param float recv_max:
|
||||
maximum number of received bytes per second. Is only used to compute
|
||||
maximum number of received bytes per second. Is only used to compute
|
||||
gradient level
|
||||
:param float sent_max:
|
||||
maximum number of sent bytes per second. Is only used to compute gradient
|
||||
maximum number of sent bytes per second. Is only used to compute gradient
|
||||
level
|
||||
|
||||
Divider highlight group used: ``background:divider``.
|
||||
|
@ -855,8 +856,8 @@ email_imap_alert = with_docstring(EmailIMAPSegment(),
|
|||
:param str folder:
|
||||
folder to check for e-mails
|
||||
:param int max_msgs:
|
||||
Maximum number of messages. If there are more messages then max_msgs then it
|
||||
will use gradient level equal to 100, otherwise gradient level is equal to
|
||||
Maximum number of messages. If there are more messages then max_msgs then it
|
||||
will use gradient level equal to 100, otherwise gradient level is equal to
|
||||
``100 * msgs_num / max_msgs``. If not present gradient is not computed.
|
||||
|
||||
Highlight groups used: ``email_alert_gradient`` (gradient), ``email_alert``.
|
||||
|
|
|
@ -1,19 +1,7 @@
|
|||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from .segment import gen_segment_getter
|
||||
|
||||
|
||||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str # NOQA
|
||||
|
||||
|
||||
def u(s):
|
||||
if type(s) is unicode:
|
||||
return s
|
||||
else:
|
||||
return unicode(s, 'utf-8')
|
||||
from powerline.segment import gen_segment_getter
|
||||
from powerline.lib.unicode import u, unicode
|
||||
|
||||
|
||||
def requires_segment_info(func):
|
||||
|
|
Loading…
Reference in New Issue