* usr/bin/byobu-config, usr/bin/byobu-ctrl-a,

usr/share/doc/byobu/help.screen.txt:
  - update python code for python3 compatibility
This commit is contained in:
Dustin Kirkland 2013-01-09 14:11:56 -06:00
commit 66a11162da
4 changed files with 45 additions and 41 deletions

3
debian/changelog vendored
View file

@ -2,6 +2,9 @@ byobu (5.25) unreleased; urgency=low
* usr/bin/byobu-status: * usr/bin/byobu-status:
- move tmux-specific width code into tmux case block - move tmux-specific width code into tmux case block
* usr/bin/byobu-config, usr/bin/byobu-ctrl-a,
usr/share/doc/byobu/help.screen.txt:
- update python code for python3 compatibility
-- Dustin Kirkland <kirkland@ubuntu.com> Wed, 09 Jan 2013 09:49:47 -0600 -- Dustin Kirkland <kirkland@ubuntu.com> Wed, 09 Jan 2013 09:49:47 -0600

View file

@ -26,11 +26,10 @@ import os
import os.path import os.path
import time import time
import string import string
import commands import subprocess
import gettext import gettext
import glob import glob
import snack import snack
from ConfigParser import SafeConfigParser
from snack import * from snack import *
PKG = "byobu" PKG = "byobu"
@ -49,14 +48,9 @@ if not os.path.exists(DOC):
DEF_ESC = "A" DEF_ESC = "A"
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." 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."
RELOAD_FLAG = "%s/reload-required" % (BYOBU_CONFIG_DIR) RELOAD_FLAG = "%s/reload-required" % (BYOBU_CONFIG_DIR)
RELOAD_CMD = "%s -X at 0 source %s/profile" % (BYOBU_BACKEND, BYOBU_CONFIG_DIR)
ESC = '' ESC = ''
snack.hotkeys[ESC] = ord(ESC) snack.hotkeys[ESC] = ord(ESC)
snack.hotkeys[ord(ESC)] = ESC snack.hotkeys[ord(ESC)] = ESC
if commands.getstatusoutput('which gsed')[0] == 0:
BYOBU_SED = "gsed"
else:
BYOBU_SED = "sed"
gettext.bindtextdomain(PKG, SHARE + '/po') gettext.bindtextdomain(PKG, SHARE + '/po')
gettext.textdomain(PKG) gettext.textdomain(PKG)
_ = gettext.gettext _ = gettext.gettext
@ -78,10 +72,11 @@ def ioctl_GWINSZ(fd):
def reload_required(): def reload_required():
try: try:
if not os.path.exists(BYOBU_CONFIG_DIR): if not os.path.exists(BYOBU_CONFIG_DIR):
os.makedirs(BYOBU_CONFIG_DIR, 0755) os.makedirs(BYOBU_CONFIG_DIR, 0o755)
f = open(RELOAD_FLAG, 'w') f = open(RELOAD_FLAG, 'w')
f.close() f.close()
commands.getoutput(RELOAD_CMD) if BYOBU_BACKEND == "screen":
subprocess.call([BYOBU_BACKEND, "-X", "at", "0", "source", "%s/profile" % BYOBU_CONFIG_DIR])
except: except:
True True
@ -137,12 +132,11 @@ def messagebox(snackScreen, width, height, title, text, scroll=0, buttons=((_("O
return bb.buttonPressed(g.runOnce()) return bb.buttonPressed(g.runOnce())
def help(snackScreen, size, config): def help(snackScreen, size):
f = file(DOC + '/help.' + BYOBU_BACKEND + '.txt') f = open(DOC + '/help.' + BYOBU_BACKEND + '.txt')
text = f.read() text = f.read()
f.close() f.close()
text = text.replace("<esckey>", getesckey(), 1) text = text.replace("<esckey>", getesckey(), 1)
text = text.replace("_VER_", commands.getoutput("byobu -v | head -n1 | " + BYOBU_SED + " 's/.* //'"), 1)
t = Textbox(67, 16, text, scroll=1, wrap=1) t = Textbox(67, 16, text, scroll=1, wrap=1)
bb = ButtonBar(snackScreen, ((_("Menu"), "menu", ESC),), compact=1) bb = ButtonBar(snackScreen, ((_("Menu"), "menu", ESC),), compact=1)
g = GridForm(snackScreen, _("Byobu Help"), 2, 4) g = GridForm(snackScreen, _("Byobu Help"), 2, 4)
@ -159,7 +153,7 @@ def readstatus():
for f in [SHARE + '/status/status', BYOBU_CONFIG_DIR + '/status']: for f in [SHARE + '/status/status', BYOBU_CONFIG_DIR + '/status']:
if os.path.exists(f): if os.path.exists(f):
try: try:
execfile(f, glo, loc) exec(open(f).read(), glo, loc)
except: except:
error("Invalid configuration [%s]" % f) error("Invalid configuration [%s]" % f)
if BYOBU_BACKEND == "tmux": if BYOBU_BACKEND == "tmux":
@ -174,8 +168,7 @@ def readstatus():
status[i] = "1" status[i] = "1"
li = [] li = []
keys = status.keys() keys = status.keys()
keys.sort() for i in sorted(keys):
for i in keys:
window = [int(status[i]), i] window = [int(status[i]), i]
li.append(window) li.append(window)
return li return li
@ -185,7 +178,7 @@ def genstatusstring(s, status):
new = "" new = ""
glo = {} glo = {}
loc = {} loc = {}
execfile(SHARE + '/status/status', glo, loc) exec(open(SHARE + '/status/status').read(), glo, loc)
for i in loc[s].split(): for i in loc[s].split():
if i.startswith("#"): if i.startswith("#"):
i = i.replace("#", "") i = i.replace("#", "")
@ -201,17 +194,19 @@ def writestatus(items):
path = BYOBU_CONFIG_DIR + '/status' path = BYOBU_CONFIG_DIR + '/status'
for i in items: for i in items:
status[i[1]] = i[0] status[i[1]] = i[0]
# BYOBU_SED is hacky here, but effective for key in ["tmux_left", "tmux_right", "screen_upper_left", "screen_upper_right", "screen_lower_left", "screen_lower_right"]:
if BYOBU_BACKEND == "tmux": if key.startswith(BYOBU_BACKEND):
for key in ["tmux_left", "tmux_right"]: f = open(path, "r")
lines = f.readlines()
f.close()
f = open(path, "w")
for l in lines:
if l.startswith("%s=" % key):
val = genstatusstring(key, status) val = genstatusstring(key, status)
commands.getoutput("%s -i -e '/^%s=/d' %s" % (BYOBU_SED, key, path)) f.write("%s=\"%s\"\n" % (key, val))
commands.getoutput("echo '%s=\"%s\"' >> %s" % (key, val, path))
else: else:
for key in ["screen_upper_left", "screen_upper_right", "screen_lower_left", "screen_lower_right"]: f.write(l)
val = genstatusstring(key, status) f.close
commands.getoutput("%s -i -e '/^%s=/d' %s" % (BYOBU_SED, key, path))
commands.getoutput("echo '%s=\"%s\"' >> %s" % (key, val, path))
def togglestatus(snackScreen, size): def togglestatus(snackScreen, size):
@ -240,15 +235,14 @@ def togglestatus(snackScreen, size):
def install(snackScreen, size, isInstalled): def install(snackScreen, size, isInstalled):
out = ""
if isInstalled: if isInstalled:
out = commands.getoutput("byobu-launcher-uninstall") if subprocess.call(["byobu-launcher-uninstall"]) == 0:
if out == "":
out = _("Byobu will not be launched next time you login.") out = _("Byobu will not be launched next time you login.")
button = messagebox(snackScreen, 60, 2, _("Message"), out, buttons=((_("Menu"), ))) button = messagebox(snackScreen, 60, 2, _("Message"), out, buttons=((_("Menu"), )))
return 101 return 101
else: else:
out = commands.getoutput("byobu-launcher-install") if subprocess.call(["byobu-launcher-install"]) == 0:
if out == "":
out = _("Byobu will be launched automatically next time you login.") out = _("Byobu will be launched automatically next time you login.")
button = messagebox(snackScreen, 60, 2, "Message", out, buttons=((_("Menu"), ))) button = messagebox(snackScreen, 60, 2, "Message", out, buttons=((_("Menu"), )))
return 100 return 100
@ -266,12 +260,17 @@ def appendtofile(p, s):
def getesckey(): def getesckey():
line = ""
if BYOBU_BACKEND == "tmux": if BYOBU_BACKEND == "tmux":
path = BYOBU_CONFIG_DIR + '/keybindings.tmux' path = BYOBU_CONFIG_DIR + '/keybindings.tmux'
line = commands.getoutput("grep '^set -g prefix ' " + path) for l in open(path):
if l.startswith("set -g prefix "):
line = l
else: else:
path = BYOBU_CONFIG_DIR + '/keybindings' path = BYOBU_CONFIG_DIR + '/keybindings'
line = commands.getoutput("grep ^escape " + path) for l in open(path):
if l.startswith("escape "):
line = l
if not os.path.exists(path): if not os.path.exists(path):
return DEF_ESC return DEF_ESC
if line == "": if line == "":
@ -284,7 +283,7 @@ def getesckey():
def setesckey(key): def setesckey(key):
if key.isalpha(): if key.isalpha():
out = commands.getoutput("byobu-ctrl-a screen %s" % key) subprocess.call(["byobu-ctrl-a", "screen", key])
def chgesc(snackScreen, size): def chgesc(snackScreen, size):
@ -328,7 +327,8 @@ def chgesc(snackScreen, size):
def autolaunch(): def autolaunch():
if os.path.exists(BYOBU_CONFIG_DIR + "/disable-autolaunch"): if os.path.exists(BYOBU_CONFIG_DIR + "/disable-autolaunch"):
return 0 return 0
if commands.getstatusoutput('grep -qs byobu-launch %s/.profile' % HOME)[0] == 0: for line in open("%s/.profile" % HOME):
if "byobu-launch" in line:
return 1 return 1
if os.path.exists("/etc/profile.d/Z98-%s.sh" % PKG): if os.path.exists("/etc/profile.d/Z98-%s.sh" % PKG):
return 1 return 1
@ -341,13 +341,12 @@ def main():
snackScreen = SnackScreen() snackScreen = SnackScreen()
snackScreen.drawRootText(1, 0, _('Byobu Configuration Menu')) snackScreen.drawRootText(1, 0, _('Byobu Configuration Menu'))
snackScreen.pushHelpLine(_('<Tab> between elements | <Enter> selects | <Esc> exits')) snackScreen.pushHelpLine(_('<Tab> between elements | <Enter> selects | <Esc> exits'))
config = SafeConfigParser()
isInstalled = autolaunch() isInstalled = autolaunch()
tag = 100 tag = 100
while tag > 0: while tag > 0:
tag = menu(snackScreen, size, isInstalled) tag = menu(snackScreen, size, isInstalled)
if tag == 1: if tag == 1:
tag = help(snackScreen, size, config) tag = help(snackScreen, size)
elif tag == 2: elif tag == 2:
tag = togglestatus(snackScreen, size) tag = togglestatus(snackScreen, size)
elif tag == 3: elif tag == 3:

View file

@ -125,7 +125,9 @@ case "$bind_to" in
;; ;;
esac esac
echo "To modify this behavior again later, run 'byobu-ctrl-a'" if [ -z "${2}" ]; then
echo echo "To modify this behavior again later, run 'byobu-ctrl-a'"
echo
fi
# vi: syntax=sh ts=4 noexpandtab # vi: syntax=sh ts=4 noexpandtab

View file

@ -1,4 +1,4 @@
Byobu _VER_ is an enhancement to GNU Screen, a command line Byobu is an enhancement to GNU Screen, a command line
tool providing live system status, dynamic window management, tool providing live system status, dynamic window management,
and some convenient keybindings: and some convenient keybindings: