Tristan Van Berkom pushed to branch tristan/notifications at BuildStream / buildstream
Commits:
-
ab1caac1
by Chandan Singh at 2018-08-21T23:47:32Z
-
81278f84
by Tristan Van Berkom at 2018-08-22T05:23:33Z
-
3d4e649d
by Tristan Van Berkom at 2018-08-22T05:24:42Z
2 changed files:
Changes:
| ... | ... | @@ -22,12 +22,43 @@ import click |
| 22 | 22 |
from .app import App
|
| 23 | 23 |
|
| 24 | 24 |
|
| 25 |
+# This trick is currently only supported on some terminals,
|
|
| 26 |
+# avoid using it where it can cause garbage to be printed
|
|
| 27 |
+# to the terminal.
|
|
| 28 |
+#
|
|
| 29 |
+def _osc_777_supported():
|
|
| 30 |
+ |
|
| 31 |
+ term = os.environ['TERM']
|
|
| 32 |
+ |
|
| 33 |
+ if term.startswith('xterm') or term.startswith('vte'):
|
|
| 34 |
+ |
|
| 35 |
+ # Since vte version 4600, upstream silently ignores
|
|
| 36 |
+ # the OSC 777 without printing garbage to the terminal.
|
|
| 37 |
+ #
|
|
| 38 |
+ # For distros like Fedora who have patched vte, this
|
|
| 39 |
+ # will trigger a desktop notification and bring attention
|
|
| 40 |
+ # to the terminal.
|
|
| 41 |
+ #
|
|
| 42 |
+ vte_version = os.environ['VTE_VERSION']
|
|
| 43 |
+ try:
|
|
| 44 |
+ vte_version_int = int(vte_version)
|
|
| 45 |
+ except ValueError:
|
|
| 46 |
+ return False
|
|
| 47 |
+ |
|
| 48 |
+ if vte_version_int >= 4600:
|
|
| 49 |
+ return True
|
|
| 50 |
+ |
|
| 51 |
+ return False
|
|
| 52 |
+ |
|
| 53 |
+ |
|
| 25 | 54 |
# A linux specific App implementation
|
| 26 | 55 |
#
|
| 27 | 56 |
class LinuxApp(App):
|
| 28 | 57 |
|
| 29 | 58 |
def notify(self, title, text):
|
| 30 | 59 |
|
| 31 |
- term = os.environ['TERM']
|
|
| 32 |
- if term in ('xterm', 'vte'):
|
|
| 33 |
- click.echo("\033]777;notify;{};{}\007".format(title, text))
|
|
| 60 |
+ # Currently we only try this notification method
|
|
| 61 |
+ # of sending an escape sequence to the terminal
|
|
| 62 |
+ #
|
|
| 63 |
+ if _osc_777_supported():
|
|
| 64 |
+ click.echo("\033]777;notify;{};{}\007".format(title, text), err=True)
|
| ... | ... | @@ -224,6 +224,13 @@ def get_cmdclass(): |
| 224 | 224 |
with open('dev-requirements.txt') as dev_reqs:
|
| 225 | 225 |
dev_requires = dev_reqs.read().splitlines()
|
| 226 | 226 |
|
| 227 |
+#####################################################
|
|
| 228 |
+# Prepare package description from README #
|
|
| 229 |
+#####################################################
|
|
| 230 |
+with open(os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
|
| 231 |
+ 'README.rst')) as readme:
|
|
| 232 |
+ long_description = readme.read()
|
|
| 233 |
+ |
|
| 227 | 234 |
|
| 228 | 235 |
#####################################################
|
| 229 | 236 |
# Main setup() Invocation #
|
| ... | ... | @@ -233,8 +240,13 @@ setup(name='BuildStream', |
| 233 | 240 |
version=versioneer.get_version(),
|
| 234 | 241 |
cmdclass=get_cmdclass(),
|
| 235 | 242 |
|
| 243 |
+ author='BuildStream Developers',
|
|
| 244 |
+ author_email='buildstream-list gnome org',
|
|
| 236 | 245 |
description='A framework for modelling build pipelines in YAML',
|
| 237 | 246 |
license='LGPL',
|
| 247 |
+ long_description=long_description,
|
|
| 248 |
+ long_description_content_type='text/x-rst; charset=UTF-8',
|
|
| 249 |
+ url='https://gitlab.com/BuildStream/buildstream',
|
|
| 238 | 250 |
packages=find_packages(exclude=('tests', 'tests.*')),
|
| 239 | 251 |
package_data={'buildstream': ['plugins/*/*.py', 'plugins/*/*.yaml',
|
| 240 | 252 |
'data/*.yaml', 'data/*.sh.in']},
|
