mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 22:13:19 -07:00
* 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:
parent
bfbec44a5d
commit
66a11162da
4 changed files with 45 additions and 41 deletions
3
debian/changelog
vendored
3
debian/changelog
vendored
|
@ -2,6 +2,9 @@ byobu (5.25) unreleased; urgency=low
|
|||
|
||||
* usr/bin/byobu-status:
|
||||
- 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
|
||||
|
||||
|
|
|
@ -26,11 +26,10 @@ import os
|
|||
import os.path
|
||||
import time
|
||||
import string
|
||||
import commands
|
||||
import subprocess
|
||||
import gettext
|
||||
import glob
|
||||
import snack
|
||||
from ConfigParser import SafeConfigParser
|
||||
from snack import *
|
||||
|
||||
PKG = "byobu"
|
||||
|
@ -49,14 +48,9 @@ if not os.path.exists(DOC):
|
|||
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_FLAG = "%s/reload-required" % (BYOBU_CONFIG_DIR)
|
||||
RELOAD_CMD = "%s -X at 0 source %s/profile" % (BYOBU_BACKEND, BYOBU_CONFIG_DIR)
|
||||
ESC = ''
|
||||
snack.hotkeys[ESC] = ord(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.textdomain(PKG)
|
||||
_ = gettext.gettext
|
||||
|
@ -78,10 +72,11 @@ def ioctl_GWINSZ(fd):
|
|||
def reload_required():
|
||||
try:
|
||||
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.close()
|
||||
commands.getoutput(RELOAD_CMD)
|
||||
if BYOBU_BACKEND == "screen":
|
||||
subprocess.call([BYOBU_BACKEND, "-X", "at", "0", "source", "%s/profile" % BYOBU_CONFIG_DIR])
|
||||
except:
|
||||
True
|
||||
|
||||
|
@ -137,12 +132,11 @@ def messagebox(snackScreen, width, height, title, text, scroll=0, buttons=((_("O
|
|||
return bb.buttonPressed(g.runOnce())
|
||||
|
||||
|
||||
def help(snackScreen, size, config):
|
||||
f = file(DOC + '/help.' + BYOBU_BACKEND + '.txt')
|
||||
def help(snackScreen, size):
|
||||
f = open(DOC + '/help.' + BYOBU_BACKEND + '.txt')
|
||||
text = f.read()
|
||||
f.close()
|
||||
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)
|
||||
bb = ButtonBar(snackScreen, ((_("Menu"), "menu", ESC),), compact=1)
|
||||
g = GridForm(snackScreen, _("Byobu Help"), 2, 4)
|
||||
|
@ -159,7 +153,7 @@ def readstatus():
|
|||
for f in [SHARE + '/status/status', BYOBU_CONFIG_DIR + '/status']:
|
||||
if os.path.exists(f):
|
||||
try:
|
||||
execfile(f, glo, loc)
|
||||
exec(open(f).read(), glo, loc)
|
||||
except:
|
||||
error("Invalid configuration [%s]" % f)
|
||||
if BYOBU_BACKEND == "tmux":
|
||||
|
@ -174,8 +168,7 @@ def readstatus():
|
|||
status[i] = "1"
|
||||
li = []
|
||||
keys = status.keys()
|
||||
keys.sort()
|
||||
for i in keys:
|
||||
for i in sorted(keys):
|
||||
window = [int(status[i]), i]
|
||||
li.append(window)
|
||||
return li
|
||||
|
@ -185,7 +178,7 @@ def genstatusstring(s, status):
|
|||
new = ""
|
||||
glo = {}
|
||||
loc = {}
|
||||
execfile(SHARE + '/status/status', glo, loc)
|
||||
exec(open(SHARE + '/status/status').read(), glo, loc)
|
||||
for i in loc[s].split():
|
||||
if i.startswith("#"):
|
||||
i = i.replace("#", "")
|
||||
|
@ -201,17 +194,19 @@ def writestatus(items):
|
|||
path = BYOBU_CONFIG_DIR + '/status'
|
||||
for i in items:
|
||||
status[i[1]] = i[0]
|
||||
# BYOBU_SED is hacky here, but effective
|
||||
if BYOBU_BACKEND == "tmux":
|
||||
for key in ["tmux_left", "tmux_right"]:
|
||||
for key in ["tmux_left", "tmux_right", "screen_upper_left", "screen_upper_right", "screen_lower_left", "screen_lower_right"]:
|
||||
if key.startswith(BYOBU_BACKEND):
|
||||
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)
|
||||
commands.getoutput("%s -i -e '/^%s=/d' %s" % (BYOBU_SED, key, path))
|
||||
commands.getoutput("echo '%s=\"%s\"' >> %s" % (key, val, path))
|
||||
f.write("%s=\"%s\"\n" % (key, val))
|
||||
else:
|
||||
for key in ["screen_upper_left", "screen_upper_right", "screen_lower_left", "screen_lower_right"]:
|
||||
val = genstatusstring(key, status)
|
||||
commands.getoutput("%s -i -e '/^%s=/d' %s" % (BYOBU_SED, key, path))
|
||||
commands.getoutput("echo '%s=\"%s\"' >> %s" % (key, val, path))
|
||||
f.write(l)
|
||||
f.close
|
||||
|
||||
|
||||
def togglestatus(snackScreen, size):
|
||||
|
@ -240,15 +235,14 @@ def togglestatus(snackScreen, size):
|
|||
|
||||
|
||||
def install(snackScreen, size, isInstalled):
|
||||
out = ""
|
||||
if isInstalled:
|
||||
out = commands.getoutput("byobu-launcher-uninstall")
|
||||
if out == "":
|
||||
if subprocess.call(["byobu-launcher-uninstall"]) == 0:
|
||||
out = _("Byobu will not be launched next time you login.")
|
||||
button = messagebox(snackScreen, 60, 2, _("Message"), out, buttons=((_("Menu"), )))
|
||||
return 101
|
||||
else:
|
||||
out = commands.getoutput("byobu-launcher-install")
|
||||
if out == "":
|
||||
if subprocess.call(["byobu-launcher-install"]) == 0:
|
||||
out = _("Byobu will be launched automatically next time you login.")
|
||||
button = messagebox(snackScreen, 60, 2, "Message", out, buttons=((_("Menu"), )))
|
||||
return 100
|
||||
|
@ -266,12 +260,17 @@ def appendtofile(p, s):
|
|||
|
||||
|
||||
def getesckey():
|
||||
line = ""
|
||||
if BYOBU_BACKEND == "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:
|
||||
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):
|
||||
return DEF_ESC
|
||||
if line == "":
|
||||
|
@ -284,7 +283,7 @@ def getesckey():
|
|||
|
||||
def setesckey(key):
|
||||
if key.isalpha():
|
||||
out = commands.getoutput("byobu-ctrl-a screen %s" % key)
|
||||
subprocess.call(["byobu-ctrl-a", "screen", key])
|
||||
|
||||
|
||||
def chgesc(snackScreen, size):
|
||||
|
@ -328,7 +327,8 @@ def chgesc(snackScreen, size):
|
|||
def autolaunch():
|
||||
if os.path.exists(BYOBU_CONFIG_DIR + "/disable-autolaunch"):
|
||||
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
|
||||
if os.path.exists("/etc/profile.d/Z98-%s.sh" % PKG):
|
||||
return 1
|
||||
|
@ -341,13 +341,12 @@ def main():
|
|||
snackScreen = SnackScreen()
|
||||
snackScreen.drawRootText(1, 0, _('Byobu Configuration Menu'))
|
||||
snackScreen.pushHelpLine(_('<Tab> between elements | <Enter> selects | <Esc> exits'))
|
||||
config = SafeConfigParser()
|
||||
isInstalled = autolaunch()
|
||||
tag = 100
|
||||
while tag > 0:
|
||||
tag = menu(snackScreen, size, isInstalled)
|
||||
if tag == 1:
|
||||
tag = help(snackScreen, size, config)
|
||||
tag = help(snackScreen, size)
|
||||
elif tag == 2:
|
||||
tag = togglestatus(snackScreen, size)
|
||||
elif tag == 3:
|
||||
|
|
|
@ -125,7 +125,9 @@ case "$bind_to" in
|
|||
;;
|
||||
esac
|
||||
|
||||
echo "To modify this behavior again later, run 'byobu-ctrl-a'"
|
||||
echo
|
||||
if [ -z "${2}" ]; then
|
||||
echo "To modify this behavior again later, run 'byobu-ctrl-a'"
|
||||
echo
|
||||
fi
|
||||
|
||||
# vi: syntax=sh ts=4 noexpandtab
|
||||
|
|
|
@ -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,
|
||||
and some convenient keybindings:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue