mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 06:23:19 -07:00
* usr/bin/byobu-select-session:
- update python code for python3 compatibility
This commit is contained in:
parent
66a11162da
commit
dad18f8164
2 changed files with 18 additions and 15 deletions
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -5,6 +5,8 @@ byobu (5.25) unreleased; urgency=low
|
||||||
* usr/bin/byobu-config, usr/bin/byobu-ctrl-a,
|
* usr/bin/byobu-config, usr/bin/byobu-ctrl-a,
|
||||||
usr/share/doc/byobu/help.screen.txt:
|
usr/share/doc/byobu/help.screen.txt:
|
||||||
- update python code for python3 compatibility
|
- update python code for python3 compatibility
|
||||||
|
* usr/bin/byobu-select-session:
|
||||||
|
- 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
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
import commands
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -42,23 +41,25 @@ def get_sessions():
|
||||||
sessions = []
|
sessions = []
|
||||||
i = 0
|
i = 0
|
||||||
if BYOBU_BACKEND == "screen":
|
if BYOBU_BACKEND == "screen":
|
||||||
output = commands.getstatusoutput("screen -ls")
|
output = subprocess.check_output(["screen", "-ls"])
|
||||||
if output[0] >= 0:
|
output = output.decode(sys.stdout.encoding)
|
||||||
for s in output[1].split("\n"):
|
if output:
|
||||||
|
for s in output.splitlines():
|
||||||
s = re.sub(r'\s+', ' ', s)
|
s = re.sub(r'\s+', ' ', s)
|
||||||
# Ignore hidden sessions (named sessions that start with a ".")
|
# Ignore hidden sessions (named sessions that start with a ".")
|
||||||
if (s.find(" ") == 0 and len(s) > 1 and s.count("..") == 0):
|
if s and (s.find(" ") == 0 and len(s) > 1 and s.count("..") == 0):
|
||||||
text.append("screen: %s" % s.strip())
|
text.append("screen: %s" % s.strip())
|
||||||
items = s.split(" ")
|
items = s.split(" ")
|
||||||
sessions.append("screen____%s" % items[1])
|
sessions.append("screen____%s" % items[1])
|
||||||
i += 1
|
i += 1
|
||||||
if BYOBU_BACKEND == "tmux":
|
if BYOBU_BACKEND == "tmux":
|
||||||
output = commands.getstatusoutput("tmux list-sessions")
|
output = subprocess.check_output(["tmux", "list-sessions"])
|
||||||
if output[0] == 0:
|
output = output.decode(sys.stdout.encoding)
|
||||||
for s in output[1].split("\n"):
|
if output:
|
||||||
|
for s in output.splitlines():
|
||||||
|
if s:
|
||||||
text.append("tmux: %s" % s.strip())
|
text.append("tmux: %s" % s.strip())
|
||||||
items = s.split(":")
|
sessions.append("tmux____%s" % s.split(":")[0])
|
||||||
sessions.append("tmux____%s" % items[0])
|
|
||||||
i += 1
|
i += 1
|
||||||
return sessions
|
return sessions
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ def update_environment(session):
|
||||||
cmd = ["tmux", "setenv", "-t", session_name, var, value]
|
cmd = ["tmux", "setenv", "-t", session_name, var, value]
|
||||||
else:
|
else:
|
||||||
cmd = ["screen", "-S", session_name, "-X", "setenv", var, value]
|
cmd = ["screen", "-S", session_name, "-X", "setenv", var, value]
|
||||||
print "Sending variable: %s" % (cmd, )
|
print("Sending variable: %s" % (cmd, ))
|
||||||
subprocess.call(cmd, stdout=open(os.devnull, "w"))
|
subprocess.call(cmd, stdout=open(os.devnull, "w"))
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ if len(sessions) > 1:
|
||||||
sys.stdout.write(" %d. %s\n" % (i, s))
|
sys.stdout.write(" %d. %s\n" % (i, s))
|
||||||
i += 1
|
i += 1
|
||||||
try:
|
try:
|
||||||
choice = int(raw_input("\nChoose 1-%d [1]: " % (i - 1)))
|
choice = int(input("\nChoose 1-%d [1]: " % (i - 1)))
|
||||||
if choice >= 1 and choice < i:
|
if choice >= 1 and choice < i:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -112,7 +113,7 @@ if len(sessions) > 1:
|
||||||
choice = ""
|
choice = ""
|
||||||
sys.stderr.write("\nERROR: Invalid input\n")
|
sys.stderr.write("\nERROR: Invalid input\n")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print
|
print()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except:
|
except:
|
||||||
if choice == "":
|
if choice == "":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue