Merge lp:~cosmos-door/byobu/lp1843729 into lp:byobu
- lp1843729
- Merge into trunk
Proposed by
Mitsuya Shibata
Status: | Needs review | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~cosmos-door/byobu/lp1843729 | ||||
Merge into: | lp:byobu | ||||
Diff against target: |
984 lines (+428/-419) 4 files modified
debian/changelog (+9/-0) debian/rules (+1/-1) usr/lib/byobu/include/config.py.in (+280/-280) usr/lib/byobu/include/select-session.py (+138/-138) |
||||
To merge this branch: | bzr merge lp:~cosmos-door/byobu/lp1843729 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dustin Kirkland | Pending | ||
Review via email: mp+373372@code.launchpad.net |
Commit message
* debian/rules
- use autoreconf addon to make call dh_auto_configure.
* usr/lib/
usr/lib/
- fix ftbfs: LP: #1843729
- during pep8 verification due to the newly
introduced E117 - ie. hard tab as over-indented spaces.
Description of the change
Fix FTBFS for LP: #1843729
- make call dh_auto_configure
- replace hard-tab to soft-tab to fix PEP8 E117 (over-indented)
To post a comment you must log in.
Unmerged revisions
- 2624. By Mitsuya Shibata
-
* debian/rules
- use autoreconf addon to make call dh_auto_configure.
* usr/lib/byobu/include/ config. py.in,
usr/lib/byobu/include/ select- session. py:
- fix ftbfs: LP: #1843729
- during pep8 verification due to the newly
introduced E117 - ie. hard tab as over-indented spaces.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2019-06-12 23:41:10 +0000 |
3 | +++ debian/changelog 2019-10-06 07:04:52 +0000 |
4 | @@ -2,6 +2,15 @@ |
5 | |
6 | * UNRELEASED |
7 | |
8 | + [ Mitsuya Shibata ] |
9 | + * debian/rules |
10 | + - use autoreconf addon to make call dh_auto_configure. |
11 | + * usr/lib/byobu/include/config.py.in, |
12 | + usr/lib/byobu/include/select-session.py: |
13 | + - fix ftbfs: LP: #1843729 |
14 | + - during pep8 verification due to the newly |
15 | + introduced E117 - ie. hard tab as over-indented spaces. |
16 | + |
17 | -- Dustin Kirkland <kirkland@ubuntu.com> Wed, 12 Jun 2019 18:41:09 -0500 |
18 | |
19 | byobu (5.129-0ubuntu1) eoan; urgency=medium |
20 | |
21 | === modified file 'debian/rules' |
22 | --- debian/rules 2017-12-04 13:44:47 +0000 |
23 | +++ debian/rules 2019-10-06 07:04:52 +0000 |
24 | @@ -1,6 +1,6 @@ |
25 | #!/usr/bin/make -f |
26 | %: |
27 | - dh $@ --with python3 |
28 | + dh $@ --with autoreconf,python3 |
29 | |
30 | override_dh_auto_build: |
31 | # Check python syntax |
32 | |
33 | === modified file 'usr/lib/byobu/include/config.py.in' |
34 | --- usr/lib/byobu/include/config.py.in 2019-03-19 02:26:57 +0000 |
35 | +++ usr/lib/byobu/include/config.py.in 2019-10-06 07:04:52 +0000 |
36 | @@ -35,15 +35,15 @@ |
37 | |
38 | |
39 | def error(msg): |
40 | - print("ERROR: %s" % msg) |
41 | - sys.exit(1) |
42 | + print("ERROR: %s" % msg) |
43 | + sys.exit(1) |
44 | |
45 | |
46 | try: |
47 | - import snack |
48 | - from snack import * |
49 | + import snack |
50 | + from snack import * |
51 | except Exception: |
52 | - error("Could not import the python snack module") |
53 | + error("Could not import the python snack module") |
54 | |
55 | |
56 | PKG = "byobu" |
57 | @@ -57,11 +57,11 @@ |
58 | SHARE = BYOBU_PREFIX + '/share/' + PKG |
59 | DOC = BYOBU_PREFIX + '/share/doc/' + PKG |
60 | if not os.path.exists(SHARE): |
61 | - SHARE = BYOBU_CONFIG_DIR + "/" + SHARE |
62 | -if not os.path.exists(DOC): |
63 | - DOC = BYOBU_PREFIX + '/share/doc/packages/' + PKG |
64 | -if not os.path.exists(DOC): |
65 | - DOC = BYOBU_CONFIG_DIR + "/" + DOC |
66 | + SHARE = BYOBU_CONFIG_DIR + "/" + SHARE |
67 | +if not os.path.exists(DOC): |
68 | + DOC = BYOBU_PREFIX + '/share/doc/packages/' + PKG |
69 | +if not os.path.exists(DOC): |
70 | + DOC = BYOBU_CONFIG_DIR + "/" + DOC |
71 | DEF_ESC = "A" |
72 | RELOAD = "If you are using the default set of keybindings, press\n<F5> or <ctrl-a-R> to activate these changes.\n\nOtherwise, exit this session and start a new one." |
73 | RELOAD_FLAG = "%s/reload-required" % (BYOBU_RUN_DIR) |
74 | @@ -74,324 +74,324 @@ |
75 | |
76 | |
77 | def ioctl_GWINSZ(fd): |
78 | - # Discover terminal width |
79 | - try: |
80 | - import fcntl |
81 | - import termios |
82 | - import struct |
83 | - import os |
84 | - cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) |
85 | - except Exception: |
86 | - return None |
87 | - return cr |
88 | + # Discover terminal width |
89 | + try: |
90 | + import fcntl |
91 | + import termios |
92 | + import struct |
93 | + import os |
94 | + cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234')) |
95 | + except Exception: |
96 | + return None |
97 | + return cr |
98 | |
99 | |
100 | def reload_required(): |
101 | - try: |
102 | - if not os.path.exists(BYOBU_CONFIG_DIR): |
103 | - # 493 (decimal) is 0755 (octal) |
104 | - # Use decimal for portability across all python versions |
105 | - os.makedirs(BYOBU_CONFIG_DIR, 493) |
106 | - f = open(RELOAD_FLAG, 'w') |
107 | - f.close() |
108 | - if BYOBU_BACKEND == "screen": |
109 | - subprocess.call([BYOBU_BACKEND, "-X", "at", "0", "source", "%s/profile" % BYOBU_CONFIG_DIR]) |
110 | - except Exception: |
111 | - True |
112 | + try: |
113 | + if not os.path.exists(BYOBU_CONFIG_DIR): |
114 | + # 493 (decimal) is 0755 (octal) |
115 | + # Use decimal for portability across all python versions |
116 | + os.makedirs(BYOBU_CONFIG_DIR, 493) |
117 | + f = open(RELOAD_FLAG, 'w') |
118 | + f.close() |
119 | + if BYOBU_BACKEND == "screen": |
120 | + subprocess.call([BYOBU_BACKEND, "-X", "at", "0", "source", "%s/profile" % BYOBU_CONFIG_DIR]) |
121 | + except Exception: |
122 | + True |
123 | |
124 | |
125 | def terminal_size(): |
126 | - # decide on some terminal size |
127 | - cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) |
128 | - # try open fds |
129 | - if not cr: |
130 | - # ...then ctty |
131 | - try: |
132 | - fd = os.open(os.ctermid(), os.O_RDONLY) |
133 | - cr = ioctl_GWINSZ(fd) |
134 | - os.close(fd) |
135 | - except Exception: |
136 | - pass |
137 | - if not cr: |
138 | - # env vars or finally defaults |
139 | - try: |
140 | - cr = (env['LINES'], env['COLUMNS']) |
141 | - except Exception: |
142 | - cr = (25, 80) |
143 | - # reverse rows, cols |
144 | - return int(cr[1] - 5), int(cr[0] - 5) |
145 | + # decide on some terminal size |
146 | + cr = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2) |
147 | + # try open fds |
148 | + if not cr: |
149 | + # ...then ctty |
150 | + try: |
151 | + fd = os.open(os.ctermid(), os.O_RDONLY) |
152 | + cr = ioctl_GWINSZ(fd) |
153 | + os.close(fd) |
154 | + except Exception: |
155 | + pass |
156 | + if not cr: |
157 | + # env vars or finally defaults |
158 | + try: |
159 | + cr = (env['LINES'], env['COLUMNS']) |
160 | + except Exception: |
161 | + cr = (25, 80) |
162 | + # reverse rows, cols |
163 | + return int(cr[1] - 5), int(cr[0] - 5) |
164 | |
165 | |
166 | def menu(snackScreen, size, isInstalled): |
167 | - if isInstalled: |
168 | - installtext = _("Byobu currently launches at login (toggle off)") |
169 | - else: |
170 | - installtext = _("Byobu currently does not launch at login (toggle on)") |
171 | - li = Listbox(height=6, width=60, returnExit=1) |
172 | - li.append(_("Help -- Quick Start Guide"), 1) |
173 | - li.append(_("Toggle status notifications"), 2) |
174 | - li.append(_("Change escape sequence"), 3) |
175 | - li.append(installtext, 4) |
176 | - bb = ButtonBar(snackScreen, (("Exit", "exit", ESC),), compact=1) |
177 | - g = GridForm(snackScreen, _(" Byobu Configuration Menu"), 1, 2) |
178 | - g.add(li, 0, 0, padding=(4, 2, 4, 2)) |
179 | - g.add(bb, 0, 1, padding=(1, 1, 0, 0)) |
180 | - if bb.buttonPressed(g.runOnce()) == "exit": |
181 | - return 0 |
182 | - else: |
183 | - return li.current() |
184 | + if isInstalled: |
185 | + installtext = _("Byobu currently launches at login (toggle off)") |
186 | + else: |
187 | + installtext = _("Byobu currently does not launch at login (toggle on)") |
188 | + li = Listbox(height=6, width=60, returnExit=1) |
189 | + li.append(_("Help -- Quick Start Guide"), 1) |
190 | + li.append(_("Toggle status notifications"), 2) |
191 | + li.append(_("Change escape sequence"), 3) |
192 | + li.append(installtext, 4) |
193 | + bb = ButtonBar(snackScreen, (("Exit", "exit", ESC),), compact=1) |
194 | + g = GridForm(snackScreen, _(" Byobu Configuration Menu"), 1, 2) |
195 | + g.add(li, 0, 0, padding=(4, 2, 4, 2)) |
196 | + g.add(bb, 0, 1, padding=(1, 1, 0, 0)) |
197 | + if bb.buttonPressed(g.runOnce()) == "exit": |
198 | + return 0 |
199 | + else: |
200 | + return li.current() |
201 | |
202 | |
203 | def messagebox(snackScreen, width, height, title, text, scroll=0, buttons=((_("Okay"), "okay"), (_("Cancel"), "cancel", ESC))): |
204 | - t = Textbox(width, height, text, scroll=scroll) |
205 | - bb = ButtonBar(snackScreen, buttons, compact=1) |
206 | - g = GridForm(snackScreen, title, 1, 2) |
207 | - g.add(t, 0, 0, padding=(0, 0, 0, 0)) |
208 | - g.add(bb, 0, 1, padding=(1, 1, 0, 0)) |
209 | - return bb.buttonPressed(g.runOnce()) |
210 | + t = Textbox(width, height, text, scroll=scroll) |
211 | + bb = ButtonBar(snackScreen, buttons, compact=1) |
212 | + g = GridForm(snackScreen, title, 1, 2) |
213 | + g.add(t, 0, 0, padding=(0, 0, 0, 0)) |
214 | + g.add(bb, 0, 1, padding=(1, 1, 0, 0)) |
215 | + return bb.buttonPressed(g.runOnce()) |
216 | |
217 | |
218 | def help(snackScreen, size): |
219 | - f = open(DOC + '/help.' + BYOBU_BACKEND + '.txt') |
220 | - text = f.read() |
221 | - f.close() |
222 | - text = text.replace("<esckey>", getesckey(), 1) |
223 | - t = Textbox(67, 16, text, scroll=1, wrap=1) |
224 | - bb = ButtonBar(snackScreen, ((_("Menu"), "menu", ESC),), compact=1) |
225 | - g = GridForm(snackScreen, _("Byobu Help"), 2, 4) |
226 | - g.add(t, 1, 0) |
227 | - g.add(bb, 1, 1, padding=(1, 1, 0, 0)) |
228 | - button = bb.buttonPressed(g.runOnce()) |
229 | - return 100 |
230 | + f = open(DOC + '/help.' + BYOBU_BACKEND + '.txt') |
231 | + text = f.read() |
232 | + f.close() |
233 | + text = text.replace("<esckey>", getesckey(), 1) |
234 | + t = Textbox(67, 16, text, scroll=1, wrap=1) |
235 | + bb = ButtonBar(snackScreen, ((_("Menu"), "menu", ESC),), compact=1) |
236 | + g = GridForm(snackScreen, _("Byobu Help"), 2, 4) |
237 | + g.add(t, 1, 0) |
238 | + g.add(bb, 1, 1, padding=(1, 1, 0, 0)) |
239 | + button = bb.buttonPressed(g.runOnce()) |
240 | + return 100 |
241 | |
242 | |
243 | def readstatus(): |
244 | - status = {} |
245 | - glo = {} |
246 | - loc = {} |
247 | - for f in [SHARE + '/status/status', BYOBU_CONFIG_DIR + '/status']: |
248 | - if os.path.exists(f): |
249 | - try: |
250 | - exec(open(f).read(), glo, loc) |
251 | - except Exception: |
252 | - error("Invalid configuration [%s]" % f) |
253 | - if BYOBU_BACKEND == "tmux": |
254 | - items = "%s %s" % (loc["tmux_left"], loc["tmux_right"]) |
255 | - else: |
256 | - items = "%s %s %s %s" % (loc["screen_upper_left"], loc["screen_upper_right"], loc["screen_lower_left"], loc["screen_lower_right"]) |
257 | - for i in items.split(): |
258 | - if i.startswith("#"): |
259 | - i = i.replace("#", "") |
260 | - status[i] = "0" |
261 | - else: |
262 | - status[i] = "1" |
263 | - li = [] |
264 | - keys = list(status.keys()) |
265 | - for i in sorted(keys): |
266 | - window = [int(status[i]), i] |
267 | - li.append(window) |
268 | - return li |
269 | + status = {} |
270 | + glo = {} |
271 | + loc = {} |
272 | + for f in [SHARE + '/status/status', BYOBU_CONFIG_DIR + '/status']: |
273 | + if os.path.exists(f): |
274 | + try: |
275 | + exec(open(f).read(), glo, loc) |
276 | + except Exception: |
277 | + error("Invalid configuration [%s]" % f) |
278 | + if BYOBU_BACKEND == "tmux": |
279 | + items = "%s %s" % (loc["tmux_left"], loc["tmux_right"]) |
280 | + else: |
281 | + items = "%s %s %s %s" % (loc["screen_upper_left"], loc["screen_upper_right"], loc["screen_lower_left"], loc["screen_lower_right"]) |
282 | + for i in items.split(): |
283 | + if i.startswith("#"): |
284 | + i = i.replace("#", "") |
285 | + status[i] = "0" |
286 | + else: |
287 | + status[i] = "1" |
288 | + li = [] |
289 | + keys = list(status.keys()) |
290 | + for i in sorted(keys): |
291 | + window = [int(status[i]), i] |
292 | + li.append(window) |
293 | + return li |
294 | |
295 | |
296 | def genstatusstring(s, status): |
297 | - new = "" |
298 | - glo = {} |
299 | - loc = {} |
300 | - exec(open(SHARE + '/status/status').read(), glo, loc) |
301 | - for i in loc[s].split(): |
302 | - if i.startswith("#"): |
303 | - i = i.replace("#", "") |
304 | - if status[i] == 1: |
305 | - new += " " + i |
306 | - else: |
307 | - new += " #" + i |
308 | - return new |
309 | + new = "" |
310 | + glo = {} |
311 | + loc = {} |
312 | + exec(open(SHARE + '/status/status').read(), glo, loc) |
313 | + for i in loc[s].split(): |
314 | + if i.startswith("#"): |
315 | + i = i.replace("#", "") |
316 | + if status[i] == 1: |
317 | + new += " " + i |
318 | + else: |
319 | + new += " #" + i |
320 | + return new |
321 | |
322 | |
323 | def writestatus(items): |
324 | - status = {} |
325 | - path = BYOBU_CONFIG_DIR + '/status' |
326 | - for i in items: |
327 | - status[i[1]] = i[0] |
328 | - for key in ["tmux_left", "tmux_right", "screen_upper_left", "screen_upper_right", "screen_lower_left", "screen_lower_right"]: |
329 | - if key.startswith(BYOBU_BACKEND): |
330 | - try: |
331 | - f = open(path, "r") |
332 | - except Exception: |
333 | - f = open(SHARE + '/status/status', "r") |
334 | - lines = f.readlines() |
335 | - f.close() |
336 | - try: |
337 | - f = open(path, "w") |
338 | - except Exception: |
339 | - f = open(path, "a+") |
340 | - for l in lines: |
341 | - if l.startswith("%s=" % key): |
342 | - val = genstatusstring(key, status) |
343 | - f.write("%s=\"%s\"\n" % (key, val)) |
344 | - else: |
345 | - f.write(l) |
346 | - f.close |
347 | + status = {} |
348 | + path = BYOBU_CONFIG_DIR + '/status' |
349 | + for i in items: |
350 | + status[i[1]] = i[0] |
351 | + for key in ["tmux_left", "tmux_right", "screen_upper_left", "screen_upper_right", "screen_lower_left", "screen_lower_right"]: |
352 | + if key.startswith(BYOBU_BACKEND): |
353 | + try: |
354 | + f = open(path, "r") |
355 | + except Exception: |
356 | + f = open(SHARE + '/status/status', "r") |
357 | + lines = f.readlines() |
358 | + f.close() |
359 | + try: |
360 | + f = open(path, "w") |
361 | + except Exception: |
362 | + f = open(path, "a+") |
363 | + for l in lines: |
364 | + if l.startswith("%s=" % key): |
365 | + val = genstatusstring(key, status) |
366 | + f.write("%s=\"%s\"\n" % (key, val)) |
367 | + else: |
368 | + f.write(l) |
369 | + f.close |
370 | |
371 | |
372 | def togglestatus(snackScreen, size): |
373 | - itemlist = readstatus() |
374 | - rl = Label("") |
375 | - r = CheckboxTree(12, scroll=1) |
376 | - count = 0 |
377 | - for item in itemlist: |
378 | - if item[0] != -1: |
379 | - r.append(item[1], count, selected=item[0]) |
380 | - count = count + 1 |
381 | - bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact=1) |
382 | - g = GridForm(snackScreen, _("Toggle status notifications"), 2, 4) |
383 | - g.add(rl, 0, 0, anchorLeft=1, anchorTop=1, padding=(4, 0, 0, 1)) |
384 | - g.add(r, 1, 0) |
385 | - g.add(bb, 1, 1, padding=(4, 1, 0, 0)) |
386 | - if bb.buttonPressed(g.runOnce()) != "cancel": |
387 | - count = 0 |
388 | - for item in itemlist: |
389 | - if item[0] != -1: |
390 | - item[0] = r.getEntryValue(count)[1] |
391 | - count = count + 1 |
392 | - writestatus(itemlist) |
393 | - reload_required() |
394 | - return 100 |
395 | + itemlist = readstatus() |
396 | + rl = Label("") |
397 | + r = CheckboxTree(12, scroll=1) |
398 | + count = 0 |
399 | + for item in itemlist: |
400 | + if item[0] != -1: |
401 | + r.append(item[1], count, selected=item[0]) |
402 | + count = count + 1 |
403 | + bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact=1) |
404 | + g = GridForm(snackScreen, _("Toggle status notifications"), 2, 4) |
405 | + g.add(rl, 0, 0, anchorLeft=1, anchorTop=1, padding=(4, 0, 0, 1)) |
406 | + g.add(r, 1, 0) |
407 | + g.add(bb, 1, 1, padding=(4, 1, 0, 0)) |
408 | + if bb.buttonPressed(g.runOnce()) != "cancel": |
409 | + count = 0 |
410 | + for item in itemlist: |
411 | + if item[0] != -1: |
412 | + item[0] = r.getEntryValue(count)[1] |
413 | + count = count + 1 |
414 | + writestatus(itemlist) |
415 | + reload_required() |
416 | + return 100 |
417 | |
418 | |
419 | def install(snackScreen, size, isInstalled): |
420 | - out = "" |
421 | - if isInstalled: |
422 | - if subprocess.call(["byobu-launcher-uninstall"]) == 0: |
423 | - out = _("Byobu will not be launched next time you login.") |
424 | - button = messagebox(snackScreen, 60, 2, _("Message"), out, buttons=((_("Menu"), ))) |
425 | - return 101 |
426 | - else: |
427 | - if subprocess.call(["byobu-launcher-install"]) == 0: |
428 | - out = _("Byobu will be launched automatically next time you login.") |
429 | - button = messagebox(snackScreen, 60, 2, "Message", out, buttons=((_("Menu"), ))) |
430 | - return 100 |
431 | + out = "" |
432 | + if isInstalled: |
433 | + if subprocess.call(["byobu-launcher-uninstall"]) == 0: |
434 | + out = _("Byobu will not be launched next time you login.") |
435 | + button = messagebox(snackScreen, 60, 2, _("Message"), out, buttons=((_("Menu"), ))) |
436 | + return 101 |
437 | + else: |
438 | + if subprocess.call(["byobu-launcher-install"]) == 0: |
439 | + out = _("Byobu will be launched automatically next time you login.") |
440 | + button = messagebox(snackScreen, 60, 2, "Message", out, buttons=((_("Menu"), ))) |
441 | + return 100 |
442 | |
443 | |
444 | def appendtofile(p, s): |
445 | - f = open(p, 'a') |
446 | - try: |
447 | - f.write(s) |
448 | - except IOError: |
449 | - f.close() |
450 | - return |
451 | - f.close() |
452 | - return |
453 | + f = open(p, 'a') |
454 | + try: |
455 | + f.write(s) |
456 | + except IOError: |
457 | + f.close() |
458 | + return |
459 | + f.close() |
460 | + return |
461 | |
462 | |
463 | def getesckey(): |
464 | - line = "" |
465 | - if BYOBU_BACKEND == "tmux": |
466 | - path = BYOBU_CONFIG_DIR + '/keybindings.tmux' |
467 | - if os.path.exists(path): |
468 | - for l in open(path): |
469 | - if l.startswith("set -g prefix "): |
470 | - line = l |
471 | - else: |
472 | - return DEF_ESC |
473 | - else: |
474 | - path = BYOBU_CONFIG_DIR + '/keybindings' |
475 | - if os.path.exists(path): |
476 | - for l in open(path): |
477 | - if l.startswith("escape "): |
478 | - line = l |
479 | - else: |
480 | - return DEF_ESC |
481 | - if line == "": |
482 | - return DEF_ESC |
483 | - esc = line[line.find('^') + 1] |
484 | - if esc == "`": |
485 | - esc = " " |
486 | - return esc |
487 | + line = "" |
488 | + if BYOBU_BACKEND == "tmux": |
489 | + path = BYOBU_CONFIG_DIR + '/keybindings.tmux' |
490 | + if os.path.exists(path): |
491 | + for l in open(path): |
492 | + if l.startswith("set -g prefix "): |
493 | + line = l |
494 | + else: |
495 | + return DEF_ESC |
496 | + else: |
497 | + path = BYOBU_CONFIG_DIR + '/keybindings' |
498 | + if os.path.exists(path): |
499 | + for l in open(path): |
500 | + if l.startswith("escape "): |
501 | + line = l |
502 | + else: |
503 | + return DEF_ESC |
504 | + if line == "": |
505 | + return DEF_ESC |
506 | + esc = line[line.find('^') + 1] |
507 | + if esc == "`": |
508 | + esc = " " |
509 | + return esc |
510 | |
511 | |
512 | def setesckey(key): |
513 | - if key.isalpha(): |
514 | - # throw away outputs in order that the view isn't broken |
515 | - nullf = open(os.devnull, "w") |
516 | - subprocess.call(["byobu-ctrl-a", "screen", key], stdout=nullf) |
517 | - nullf.close() |
518 | + if key.isalpha(): |
519 | + # throw away outputs in order that the view isn't broken |
520 | + nullf = open(os.devnull, "w") |
521 | + subprocess.call(["byobu-ctrl-a", "screen", key], stdout=nullf) |
522 | + nullf.close() |
523 | |
524 | |
525 | def chgesc(snackScreen, size): |
526 | - esc = Entry(2, text=getesckey(), returnExit=1) |
527 | - escl = Label(_("Escape key: ctrl-")) |
528 | - bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact=1) |
529 | - g = GridForm(snackScreen, _("Change escape sequence"), 2, 4) |
530 | - g.add(escl, 0, 0, anchorLeft=1, padding=(1, 0, 0, 1)) |
531 | - g.add(esc, 1, 0, anchorLeft=1) |
532 | - g.add(bb, 1, 1) |
533 | - g.setTimer(100) |
534 | - loop = 1 |
535 | - while loop: |
536 | - which = g.run() |
537 | - if which == "TIMER": |
538 | - val = esc.value() |
539 | - if len(val) > 1: |
540 | - esc.set(val[1]) |
541 | - # Ensure that escape sequence is not \ or / |
542 | - if val == '/' or val == '\\': |
543 | - esc.set(DEF_ESC) |
544 | - # Ensure that the escape sequence is not set to a number |
545 | - try: |
546 | - dummy = int(esc.value()) |
547 | - esc.set(DEF_ESC) |
548 | - except Exception: |
549 | - # do nothing |
550 | - dummy = "foo" |
551 | - else: |
552 | - loop = 0 |
553 | - snackScreen.popWindow() |
554 | - button = bb.buttonPressed(which) |
555 | - if button != "cancel": |
556 | - setesckey(esc.value()) |
557 | - reload_required() |
558 | - if button == "exit": |
559 | - return 0 |
560 | - return 100 |
561 | + esc = Entry(2, text=getesckey(), returnExit=1) |
562 | + escl = Label(_("Escape key: ctrl-")) |
563 | + bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact=1) |
564 | + g = GridForm(snackScreen, _("Change escape sequence"), 2, 4) |
565 | + g.add(escl, 0, 0, anchorLeft=1, padding=(1, 0, 0, 1)) |
566 | + g.add(esc, 1, 0, anchorLeft=1) |
567 | + g.add(bb, 1, 1) |
568 | + g.setTimer(100) |
569 | + loop = 1 |
570 | + while loop: |
571 | + which = g.run() |
572 | + if which == "TIMER": |
573 | + val = esc.value() |
574 | + if len(val) > 1: |
575 | + esc.set(val[1]) |
576 | + # Ensure that escape sequence is not \ or / |
577 | + if val == '/' or val == '\\': |
578 | + esc.set(DEF_ESC) |
579 | + # Ensure that the escape sequence is not set to a number |
580 | + try: |
581 | + dummy = int(esc.value()) |
582 | + esc.set(DEF_ESC) |
583 | + except Exception: |
584 | + # do nothing |
585 | + dummy = "foo" |
586 | + else: |
587 | + loop = 0 |
588 | + snackScreen.popWindow() |
589 | + button = bb.buttonPressed(which) |
590 | + if button != "cancel": |
591 | + setesckey(esc.value()) |
592 | + reload_required() |
593 | + if button == "exit": |
594 | + return 0 |
595 | + return 100 |
596 | |
597 | |
598 | def autolaunch(): |
599 | - if os.path.exists(BYOBU_CONFIG_DIR + "/disable-autolaunch"): |
600 | - return 0 |
601 | - try: |
602 | - for line in open("%s/.profile" % HOME): |
603 | - if "byobu-launch" in line: |
604 | - return 1 |
605 | - except Exception: |
606 | - return 0 |
607 | - if os.path.exists("/etc/profile.d/Z97-%s.sh" % PKG): |
608 | - return 1 |
609 | - return 0 |
610 | + if os.path.exists(BYOBU_CONFIG_DIR + "/disable-autolaunch"): |
611 | + return 0 |
612 | + try: |
613 | + for line in open("%s/.profile" % HOME): |
614 | + if "byobu-launch" in line: |
615 | + return 1 |
616 | + except Exception: |
617 | + return 0 |
618 | + if os.path.exists("/etc/profile.d/Z97-%s.sh" % PKG): |
619 | + return 1 |
620 | + return 0 |
621 | |
622 | |
623 | def main(): |
624 | - """This is the main loop of our utility""" |
625 | - size = terminal_size() |
626 | - snackScreen = SnackScreen() |
627 | - snackScreen.drawRootText(1, 0, _('Byobu Configuration Menu')) |
628 | - snackScreen.pushHelpLine(_('<Tab> between elements | <Enter> selects | <Esc> exits')) |
629 | - isInstalled = autolaunch() |
630 | - tag = 100 |
631 | - while tag > 0: |
632 | - tag = menu(snackScreen, size, isInstalled) |
633 | - if tag == 1: |
634 | - tag = help(snackScreen, size) |
635 | - elif tag == 2: |
636 | - tag = togglestatus(snackScreen, size) |
637 | - elif tag == 3: |
638 | - tag = chgesc(snackScreen, size) |
639 | - elif tag == 4: |
640 | - tag = install(snackScreen, size, isInstalled) |
641 | - isInstalled = autolaunch() |
642 | - snackScreen.finish() |
643 | - sys.exit(0) |
644 | + """This is the main loop of our utility""" |
645 | + size = terminal_size() |
646 | + snackScreen = SnackScreen() |
647 | + snackScreen.drawRootText(1, 0, _('Byobu Configuration Menu')) |
648 | + snackScreen.pushHelpLine(_('<Tab> between elements | <Enter> selects | <Esc> exits')) |
649 | + isInstalled = autolaunch() |
650 | + tag = 100 |
651 | + while tag > 0: |
652 | + tag = menu(snackScreen, size, isInstalled) |
653 | + if tag == 1: |
654 | + tag = help(snackScreen, size) |
655 | + elif tag == 2: |
656 | + tag = togglestatus(snackScreen, size) |
657 | + elif tag == 3: |
658 | + tag = chgesc(snackScreen, size) |
659 | + elif tag == 4: |
660 | + tag = install(snackScreen, size, isInstalled) |
661 | + isInstalled = autolaunch() |
662 | + snackScreen.finish() |
663 | + sys.exit(0) |
664 | |
665 | |
666 | if __name__ == "__main__": |
667 | - main() |
668 | + main() |
669 | |
670 | === modified file 'usr/lib/byobu/include/select-session.py' |
671 | --- usr/lib/byobu/include/select-session.py 2019-06-12 00:31:00 +0000 |
672 | +++ usr/lib/byobu/include/select-session.py 2019-10-06 07:04:52 +0000 |
673 | @@ -25,11 +25,11 @@ |
674 | import sys |
675 | import subprocess |
676 | try: |
677 | - # For Python3, try and import input from builtins |
678 | - from builtins import input |
679 | + # For Python3, try and import input from builtins |
680 | + from builtins import input |
681 | except Exception: |
682 | - # But fall back to using the default input |
683 | - True |
684 | + # But fall back to using the default input |
685 | + True |
686 | |
687 | |
688 | PKG = "byobu" |
689 | @@ -46,161 +46,161 @@ |
690 | |
691 | |
692 | def get_sessions(): |
693 | - sessions = [] |
694 | - i = 0 |
695 | - output = False |
696 | - if BYOBU_BACKEND == "screen": |
697 | - try: |
698 | - output = subprocess.Popen(["screen", "-ls"], stdout=subprocess.PIPE).communicate()[0] |
699 | - except subprocess.CalledProcessError as cpe: |
700 | - # screen -ls seems to always return 1 |
701 | - if cpe.returncode != 1: |
702 | - raise |
703 | - else: |
704 | - output = cpe.output |
705 | - if sys.stdout.encoding is None: |
706 | - output = output.decode("UTF-8") |
707 | - else: |
708 | - output = output.decode(sys.stdout.encoding) |
709 | - if output: |
710 | - for s in output.splitlines(): |
711 | - s = re.sub(r'\s+', ' ', s) |
712 | - # Ignore hidden sessions (named sessions that start with a "." or a "_") |
713 | - if s and s != " " and (s.find(" ") == 0 and len(s) > 1 and s.count("..") == 0 and s.count("._") == 0): |
714 | - text.append("screen: %s" % s.strip()) |
715 | - items = s.split(" ") |
716 | - sessions.append("screen____%s" % items[1]) |
717 | - i += 1 |
718 | - if BYOBU_BACKEND == "tmux": |
719 | - output = subprocess.Popen(["tmux", "list-sessions"], stdout=subprocess.PIPE).communicate()[0] |
720 | - if sys.stdout.encoding is None: |
721 | - output = output.decode("UTF-8") |
722 | - else: |
723 | - output = output.decode(sys.stdout.encoding) |
724 | - if output: |
725 | - for s in output.splitlines(): |
726 | - # Ignore hidden sessions (named sessions that start with a "_") |
727 | - if s and not s.startswith("_"): |
728 | - text.append("tmux: %s" % s.strip()) |
729 | - sessions.append("tmux____%s" % s.split(":")[0]) |
730 | - i += 1 |
731 | - return sessions |
732 | + sessions = [] |
733 | + i = 0 |
734 | + output = False |
735 | + if BYOBU_BACKEND == "screen": |
736 | + try: |
737 | + output = subprocess.Popen(["screen", "-ls"], stdout=subprocess.PIPE).communicate()[0] |
738 | + except subprocess.CalledProcessError as cpe: |
739 | + # screen -ls seems to always return 1 |
740 | + if cpe.returncode != 1: |
741 | + raise |
742 | + else: |
743 | + output = cpe.output |
744 | + if sys.stdout.encoding is None: |
745 | + output = output.decode("UTF-8") |
746 | + else: |
747 | + output = output.decode(sys.stdout.encoding) |
748 | + if output: |
749 | + for s in output.splitlines(): |
750 | + s = re.sub(r'\s+', ' ', s) |
751 | + # Ignore hidden sessions (named sessions that start with a "." or a "_") |
752 | + if s and s != " " and (s.find(" ") == 0 and len(s) > 1 and s.count("..") == 0 and s.count("._") == 0): |
753 | + text.append("screen: %s" % s.strip()) |
754 | + items = s.split(" ") |
755 | + sessions.append("screen____%s" % items[1]) |
756 | + i += 1 |
757 | + if BYOBU_BACKEND == "tmux": |
758 | + output = subprocess.Popen(["tmux", "list-sessions"], stdout=subprocess.PIPE).communicate()[0] |
759 | + if sys.stdout.encoding is None: |
760 | + output = output.decode("UTF-8") |
761 | + else: |
762 | + output = output.decode(sys.stdout.encoding) |
763 | + if output: |
764 | + for s in output.splitlines(): |
765 | + # Ignore hidden sessions (named sessions that start with a "_") |
766 | + if s and not s.startswith("_"): |
767 | + text.append("tmux: %s" % s.strip()) |
768 | + sessions.append("tmux____%s" % s.split(":")[0]) |
769 | + i += 1 |
770 | + return sessions |
771 | |
772 | |
773 | def cull_zombies(session_name): |
774 | - # When using tmux session groups, closing a client will leave |
775 | - # unattached "zombie" sessions that will never be reattached. |
776 | - # Search for and kill any unattached hidden sessions in the same group |
777 | - if BYOBU_BACKEND == "tmux": |
778 | - output = subprocess.Popen(["tmux", "list-sessions"], stdout=subprocess.PIPE).communicate()[0] |
779 | - if sys.stdout.encoding is None: |
780 | - output = output.decode("UTF-8") |
781 | - else: |
782 | - output = output.decode(sys.stdout.encoding) |
783 | - if not output: |
784 | - return |
785 | - |
786 | - # Find the master session to extract the group name. We use |
787 | - # the group number to be extra sure the right session is getting |
788 | - # killed. We don't want to accidentally kill the wrong one |
789 | - pattern = "^%s:.+\\((group [^\\)]+)\\).*$" % session_name |
790 | - master = re.search(pattern, output, re.MULTILINE) |
791 | - if not master: |
792 | - return |
793 | - |
794 | - # Kill all the matching hidden & unattached sessions |
795 | - pattern = "^_%s-\\d+:.+\\(%s\\)$" % (session_name, master.group(1)) |
796 | - for s in re.findall(pattern, output, re.MULTILINE): |
797 | - subprocess.Popen(["tmux", "kill-session", "-t", s.split(":")[0]]) |
798 | + # When using tmux session groups, closing a client will leave |
799 | + # unattached "zombie" sessions that will never be reattached. |
800 | + # Search for and kill any unattached hidden sessions in the same group |
801 | + if BYOBU_BACKEND == "tmux": |
802 | + output = subprocess.Popen(["tmux", "list-sessions"], stdout=subprocess.PIPE).communicate()[0] |
803 | + if sys.stdout.encoding is None: |
804 | + output = output.decode("UTF-8") |
805 | + else: |
806 | + output = output.decode(sys.stdout.encoding) |
807 | + if not output: |
808 | + return |
809 | + |
810 | + # Find the master session to extract the group name. We use |
811 | + # the group number to be extra sure the right session is getting |
812 | + # killed. We don't want to accidentally kill the wrong one |
813 | + pattern = "^%s:.+\\((group [^\\)]+)\\).*$" % session_name |
814 | + master = re.search(pattern, output, re.MULTILINE) |
815 | + if not master: |
816 | + return |
817 | + |
818 | + # Kill all the matching hidden & unattached sessions |
819 | + pattern = "^_%s-\\d+:.+\\(%s\\)$" % (session_name, master.group(1)) |
820 | + for s in re.findall(pattern, output, re.MULTILINE): |
821 | + subprocess.Popen(["tmux", "kill-session", "-t", s.split(":")[0]]) |
822 | |
823 | |
824 | def update_environment(session): |
825 | - backend, session_name = session.split("____", 2) |
826 | - for var in BYOBU_UPDATE_ENVVARS: |
827 | - value = os.getenv(var) |
828 | - if value: |
829 | - if backend == "tmux": |
830 | - cmd = ["tmux", "setenv", "-t", session_name, var, value] |
831 | - else: |
832 | - cmd = ["screen", "-S", session_name, "-X", "setenv", var, value] |
833 | - subprocess.call(cmd, stdout=open(os.devnull, "w")) |
834 | + backend, session_name = session.split("____", 2) |
835 | + for var in BYOBU_UPDATE_ENVVARS: |
836 | + value = os.getenv(var) |
837 | + if value: |
838 | + if backend == "tmux": |
839 | + cmd = ["tmux", "setenv", "-t", session_name, var, value] |
840 | + else: |
841 | + cmd = ["screen", "-S", session_name, "-X", "setenv", var, value] |
842 | + subprocess.call(cmd, stdout=open(os.devnull, "w")) |
843 | |
844 | |
845 | def attach_session(session): |
846 | - update_environment(session) |
847 | - backend, session_name = session.split("____", 2) |
848 | - cull_zombies(session_name) |
849 | - # must use the binary, not the wrapper! |
850 | - if backend == "tmux": |
851 | - os.execvp("tmux", ["tmux", "attach", "-t", session_name]) |
852 | - else: |
853 | - os.execvp("screen", ["screen", "-AOxRR", session_name]) |
854 | + update_environment(session) |
855 | + backend, session_name = session.split("____", 2) |
856 | + cull_zombies(session_name) |
857 | + # must use the binary, not the wrapper! |
858 | + if backend == "tmux": |
859 | + os.execvp("tmux", ["tmux", "attach", "-t", session_name]) |
860 | + else: |
861 | + os.execvp("screen", ["screen", "-AOxRR", session_name]) |
862 | |
863 | |
864 | sessions = get_sessions() |
865 | |
866 | show_shell = os.path.exists("%s/.always-select" % (BYOBU_CONFIG_DIR)) |
867 | if len(sessions) > 1 or show_shell: |
868 | - sessions.append("NEW") |
869 | - text.append("Create a new Byobu session (%s)" % BYOBU_BACKEND) |
870 | - sessions.append("SHELL") |
871 | - text.append("Run a shell without Byobu (%s)" % SHELL) |
872 | + sessions.append("NEW") |
873 | + text.append("Create a new Byobu session (%s)" % BYOBU_BACKEND) |
874 | + sessions.append("SHELL") |
875 | + text.append("Run a shell without Byobu (%s)" % SHELL) |
876 | |
877 | if len(sessions) > 1: |
878 | - sys.stdout.write("\nByobu sessions...\n\n") |
879 | - tries = 0 |
880 | - while tries < 3: |
881 | - i = 1 |
882 | - for s in text: |
883 | - sys.stdout.write(" %d. %s\n" % (i, s)) |
884 | - i += 1 |
885 | - try: |
886 | - try: |
887 | - user_input = input("\nChoose 1-%d [1]: " % (i - 1)) |
888 | - except Exception: |
889 | - user_input = "" |
890 | - if not user_input or user_input == "": |
891 | - choice = 1 |
892 | - break |
893 | - try: |
894 | - choice = int(user_input) |
895 | - except Exception: |
896 | - choice = int(eval(user_input)) |
897 | - if choice >= 1 and choice < i: |
898 | - break |
899 | - else: |
900 | - tries += 1 |
901 | - choice = -1 |
902 | - sys.stderr.write("\nERROR: Invalid input\n") |
903 | - except KeyboardInterrupt: |
904 | - sys.stdout.write("\n") |
905 | - sys.exit(0) |
906 | - except Exception: |
907 | - if choice == "" or choice == -1: |
908 | - choice = 1 |
909 | - break |
910 | - tries += 1 |
911 | - choice = -1 |
912 | - sys.stderr.write("\nERROR: Invalid input\n") |
913 | + sys.stdout.write("\nByobu sessions...\n\n") |
914 | + tries = 0 |
915 | + while tries < 3: |
916 | + i = 1 |
917 | + for s in text: |
918 | + sys.stdout.write(" %d. %s\n" % (i, s)) |
919 | + i += 1 |
920 | + try: |
921 | + try: |
922 | + user_input = input("\nChoose 1-%d [1]: " % (i - 1)) |
923 | + except Exception: |
924 | + user_input = "" |
925 | + if not user_input or user_input == "": |
926 | + choice = 1 |
927 | + break |
928 | + try: |
929 | + choice = int(user_input) |
930 | + except Exception: |
931 | + choice = int(eval(user_input)) |
932 | + if choice >= 1 and choice < i: |
933 | + break |
934 | + else: |
935 | + tries += 1 |
936 | + choice = -1 |
937 | + sys.stderr.write("\nERROR: Invalid input\n") |
938 | + except KeyboardInterrupt: |
939 | + sys.stdout.write("\n") |
940 | + sys.exit(0) |
941 | + except Exception: |
942 | + if choice == "" or choice == -1: |
943 | + choice = 1 |
944 | + break |
945 | + tries += 1 |
946 | + choice = -1 |
947 | + sys.stderr.write("\nERROR: Invalid input\n") |
948 | elif len(sessions) == 1: |
949 | - # Auto-select the only session |
950 | - choice = 1 |
951 | + # Auto-select the only session |
952 | + choice = 1 |
953 | |
954 | if choice >= 1: |
955 | - if sessions[choice - 1] == "NEW": |
956 | - # Create a new session |
957 | - if BYOBU_BACKEND == "tmux": |
958 | - os.execvp("byobu", ["byobu", "new-session", SHELL]) |
959 | - else: |
960 | - os.execvp("byobu", ["byobu", SHELL]) |
961 | - elif sessions[choice - 1] == "SHELL": |
962 | - os.execvp(SHELL, [SHELL]) |
963 | - else: |
964 | - # Attach to the chosen session; must use the binary, not the wrapper! |
965 | - attach_session(sessions[choice - 1]) |
966 | + if sessions[choice - 1] == "NEW": |
967 | + # Create a new session |
968 | + if BYOBU_BACKEND == "tmux": |
969 | + os.execvp("byobu", ["byobu", "new-session", SHELL]) |
970 | + else: |
971 | + os.execvp("byobu", ["byobu", SHELL]) |
972 | + elif sessions[choice - 1] == "SHELL": |
973 | + os.execvp(SHELL, [SHELL]) |
974 | + else: |
975 | + # Attach to the chosen session; must use the binary, not the wrapper! |
976 | + attach_session(sessions[choice - 1]) |
977 | |
978 | # No valid selection, default to the youngest session, create if necessary |
979 | if BYOBU_BACKEND == "tmux": |
980 | - os.execvp("tmux", ["tmux"]) |
981 | + os.execvp("tmux", ["tmux"]) |
982 | else: |
983 | - os.execvp("screen", ["screen", "-AOxRR"]) |
984 | + os.execvp("screen", ["screen", "-AOxRR"]) |
Nack on the hardtab to whitespace changes. That's not my style. Add E117 to pep8 ignore. Thanks.