Fix python 2.6 in client/server mode

This commit is contained in:
Alessio Sergi 2014-04-17 18:32:59 +02:00
parent b7bbd69a65
commit 2a2c893836
2 changed files with 7 additions and 7 deletions

View File

@ -114,7 +114,7 @@ def main():
server = GlancesServer(cached_time=core.cached_time, server = GlancesServer(cached_time=core.cached_time,
config=core.get_config(), config=core.get_config(),
args=args) args=args)
print("{} {}:{}".format(_("Glances server is running on"), args.bind, args.port)) print(_("Glances server is running on {0}:{1}").format(args.bind, args.port))
# Set the server login/password (if -P/--password tag) # Set the server login/password (if -P/--password tag)
if (args.password != ""): if (args.password != ""):

View File

@ -56,8 +56,8 @@ class GlancesClient():
# Try to connect to the URI # Try to connect to the URI
try: try:
self.client = ServerProxy(uri) self.client = ServerProxy(uri)
except Exception as e: except Exception as err:
print("{} {} ({})".format(_("Error: creating client socket"), uri, e)) print(_("Error: Couldn't create socket {0}: {1}").format(uri, err))
sys.exit(2) sys.exit(2)
def login(self): def login(self):
@ -67,13 +67,13 @@ class GlancesClient():
try: try:
client_version = self.client.init() client_version = self.client.init()
except socket.error as err: except socket.error as err:
print("{} ({})".format(_("Error: Connection to server failed"), err)) print(_("Error: Connection to server failed: {0}").format(err))
sys.exit(2) sys.exit(2)
except ProtocolError as err: except ProtocolError as err:
if (str(err).find(" 401 ") > 0): if (str(err).find(" 401 ") > 0):
print("{} ({})".format(_("Error: Connection to server failed"), _("Bad password"))) print(_("Error: Connection to server failed: Bad password"))
else: else:
print("{} ({})".format(_("Error: Connection to server failed"), err)) print(_("Error: Connection to server failed: {0}").format(err))
sys.exit(2) sys.exit(2)
# Test if client and server are "compatible" # Test if client and server are "compatible"
@ -90,7 +90,7 @@ class GlancesClient():
self.screen = glancesCurses(args=self.args) self.screen = glancesCurses(args=self.args)
# Debug # Debug
# print "Server version: {}\nClient version: {}\n".format(__version__, client_version) # print "Server version: {0}\nClient version: {1}\n".format(__version__, client_version)
return True return True
else: else:
return False return False