31 Commits

Author SHA1 Message Date
BK Bolisetty
f9937ab922 Fix #2027 - Use command -v instead of which 2019-10-09 23:40:13 -05:00
Andreas Schneider
29ff2b99c4 Avoid a strlen() call 2017-07-13 22:58:07 +03:00
Andreas Schneider
924bbbe92b Make inline function also static
After compiling with GCC 7.1.0 it otherwise fails linking for some
reason, complaining about that non-static inline function being not
found.
2017-07-13 22:56:51 +03:00
Andreas Schneider
73244eb976 Make sure any positive integer fits into the buffer
Avoids GCC 7.1.0 -Wformat-truncation.
2017-07-13 22:55:27 +03:00
ZyX
8524ee35e7 Ignore stderr from printf and env
socat may close pipe before they succeed to write something which results in

    env: write error: Broken pipe

(according to my experience leading printf’s always succeeds to write before
socat closes pipe).
2015-02-21 13:56:58 +03:00
Sean Fisk
17e0f74eb0 Fix socket address size on non-Linux platforms. 2015-02-04 15:35:56 -05:00
ZyX
aaf52c92c5 Use sockets in abstract namespace only if running on linux
Also adds fallback to shell client which uses `uname -o` in place of `ostype`.

Closes #1215
2014-12-06 00:05:25 +03:00
ZyX
7f5c0d660d Pop first path from sys.path
According to the `sys.path` documentation “As initialized upon program startup,
the first item of this list, path[0], is the directory containing the script
that was used to invoke the Python interpreter.” Since client is named
`powerline.py` it tries to use the client itself as powerline module and
obviously fails to import `lib` submodule.
2014-09-17 00:05:10 +04:00
ZyX
849fef9b5a Use powerline.lib.encoding* in place of sys.get*encoding/locale.get*
Fixes #1078
2014-09-17 00:05:10 +04:00
ZyX
06211cbe63 Unify imports
Now imports follow the following structure:

1. __future__ line: exactly one line allowed:

        from __future__ import (unicode_literals, division, absolute_import, print_function)

   (powerline.shell is the only exception due to problems with argparse).
2. Standard python library imports in a form `import X`.
3. Standard python library imports in a form `from X import Y`.
4. and 5. 2. and 3. for third-party (non-python and non-powerline imports).
6. 3. for powerline non-test imports.
7. and 8. 2. and 3. for powerline testing module imports.

Each list entry is separated by exactly one newline from another import. If
there is module docstring it goes between `# vim:` comment and `__future__`
import. So the structure containing all items is the following:

    #!/usr/bin/env python
    # vim:fileencoding=utf-8:noet

    '''Powerline super module'''

    import sys

    from argparse import ArgumentParser

    import psutil

    from colormath.color_diff import delta_e_cie2000

    from powerline.lib.unicode import u

    import tests.vim as vim_module

    from tests import TestCase

.
2014-09-01 00:25:24 +04:00
ZyX
484b9af6ed Use the same function for getting encoding in Python client and daemon 2014-08-27 22:38:52 +04:00
ZyX
7871cfcda4 Use posix.environ in Python client if available
This way there will be no need in converting keys and values to bytes objects on
\*nix systems.
2014-08-27 22:38:52 +04:00
ZyX
5434852977 A few style improvements in Python client 2014-08-27 22:38:52 +04:00
ZyX
70e7088b04 Do not replace ascii with UTF-8 in powerline-daemon and python client
Assuming ascii was expected to be used when LANG=C it did not work in any case:
in this case preferred encoding is “ANSI_X3.4-1968”. Same for
`sys.getfilesystemencoding()`.
2014-08-27 22:34:13 +04:00
Pierre Carru
c4aa72fc1f Make shell client work in OS X:
- use gnu env for `env -0`,
- use filesystem socket.
2014-08-26 10:37:32 +01:00
ZyX
0232d3215b Add --socket argument to all clients
Makes it not needed to kill daemon for testing, but disables implicit
`powerline-config shell command` testing.
2014-08-23 15:19:00 +04:00
ZyX
dc76396912 Solve encoding issues in powerline python client 2014-08-23 15:18:59 +04:00
ZyX
6f550fce8b Write zero after writing current working directory in powerline.c 2014-08-10 16:13:33 +04:00
ZyX
660925f0c2 Use do_write function in place of self-written replacement 2014-08-06 22:39:50 +04:00
ZyX
0a6bb9ce08 Some style fixes 2014-08-06 22:39:50 +04:00
ZyX
ae2ac05ced Handle errors from write()
Fixes #964
2014-08-06 22:11:35 +04:00
ZyX
203a374b54 Do not use argparge for parsing --env and --cwd
It took 2/3 of do_render call according to profiler. New variant takes only 1/6.

WARNING: This commit will break all powerline installations with running daemon
because it changes communication protocol. You must kill and restart all your
powerline daemons for powerline to function properly.

Highlight @kovidgoyal
2014-08-04 03:02:05 +04:00
ZyX
da45adb9e6 Make it compile without warnings with -Wconversion 2014-08-04 03:02:05 +04:00
ZyX
a5037a817b Fix powerline.c styling
Also makes it compile with -std=c89 (except for snprintf) or just -std=c99,
-Wall, -pedantic.
2014-08-04 03:02:05 +04:00
ZyX
f3d972849e Fall back to powerline-render when using powerline.sh 2014-08-02 21:31:01 +04:00
ZyX
95dcef8bf8 Some style fixes 2014-08-02 21:30:51 +04:00
ZyX
3b060562e2 Fix UnicodeDecodeError in Python version of powerline client 2014-08-02 19:46:04 +04:00
ZyX
e37b13cc44 Remove compiled binary from repository 2014-08-02 18:56:44 +04:00
ZyX
e613beb8df Add shell version of powerline-client
Note: this shell script is still faster then client/powerline.py. `time` reports 
      0.00, 0.01, 0.02÷0.03 for powerline, powerline.sh and powerline.py 
      respectively (run with `./client/powerline* tmux right`).

Note: does not work in busybox as env there does not support -0 argument. 
      Requires sed, id (for dash as $UID is not available there), env, printf 
      and socat. Is not currently handled by setup.py.
2014-08-02 18:53:25 +04:00
ZyX
7db428667c Get rid of modeline E518 error 2014-08-02 18:53:25 +04:00
Kim Silkebækken
a122e73b9b Add files from @kovidgoyal's powerline-daemon repo
Minor changes have been applied:

- Removed copyright info and GPL 3 license since Powerline is MIT (needs
  confirmation from kovidgoyal before merge)
- The `powerline-client` script is renamed to `powerline`, and calls the
  daemon or `powerline-render` (the previous `powerline`) to render
  a statusline
- Minor coding style corrections to match the rest of the project
- Python 3 support is removed for now due to setuptools failing with
  binary scripts

Todo:

- Automatically attempt to launch powerline-daemon the first time
  powerline is run if the daemon isn't already running?
- pip install -e fails with binary files (it appears that pip recodes
  the powerline binary to ASCII, the compiled powerline script must be
  copied manually to ~/.local/bin after pip install -e has been run)
2014-08-02 18:45:18 +04:00