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/share/doc/byobu/help.screen.txt:
|
||||
- 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
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import commands
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
@ -42,23 +41,25 @@ def get_sessions():
|
|||
sessions = []
|
||||
i = 0
|
||||
if BYOBU_BACKEND == "screen":
|
||||
output = commands.getstatusoutput("screen -ls")
|
||||
if output[0] >= 0:
|
||||
for s in output[1].split("\n"):
|
||||
output = subprocess.check_output(["screen", "-ls"])
|
||||
output = output.decode(sys.stdout.encoding)
|
||||
if output:
|
||||
for s in output.splitlines():
|
||||
s = re.sub(r'\s+', ' ', s)
|
||||
# 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())
|
||||
items = s.split(" ")
|
||||
sessions.append("screen____%s" % items[1])
|
||||
i += 1
|
||||
if BYOBU_BACKEND == "tmux":
|
||||
output = commands.getstatusoutput("tmux list-sessions")
|
||||
if output[0] == 0:
|
||||
for s in output[1].split("\n"):
|
||||
output = subprocess.check_output(["tmux", "list-sessions"])
|
||||
output = output.decode(sys.stdout.encoding)
|
||||
if output:
|
||||
for s in output.splitlines():
|
||||
if s:
|
||||
text.append("tmux: %s" % s.strip())
|
||||
items = s.split(":")
|
||||
sessions.append("tmux____%s" % items[0])
|
||||
sessions.append("tmux____%s" % s.split(":")[0])
|
||||
i += 1
|
||||
return sessions
|
||||
|
||||
|
@ -72,7 +73,7 @@ def update_environment(session):
|
|||
cmd = ["tmux", "setenv", "-t", session_name, var, value]
|
||||
else:
|
||||
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"))
|
||||
|
||||
|
||||
|
@ -104,7 +105,7 @@ if len(sessions) > 1:
|
|||
sys.stdout.write(" %d. %s\n" % (i, s))
|
||||
i += 1
|
||||
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:
|
||||
break
|
||||
else:
|
||||
|
@ -112,7 +113,7 @@ if len(sessions) > 1:
|
|||
choice = ""
|
||||
sys.stderr.write("\nERROR: Invalid input\n")
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
print()
|
||||
sys.exit(0)
|
||||
except:
|
||||
if choice == "":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue