diff -urb lizardfs-3.12.0/src/cgi/cgiserv.py.in lizardfs-3.12.0b/src/cgi/cgiserv.py.in --- lizardfs-3.12.0/src/cgi/cgiserv.py.in 2017-12-20 09:59:37.000000000 +0000 +++ lizardfs-3.12.0b/src/cgi/cgiserv.py.in 2019-08-24 16:25:11.915084539 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import fcntl import errno import posix @@ -10,9 +10,9 @@ import traceback import datetime import mimetypes -import urlparse -import urllib -import cStringIO +import urllib.parse +import urllib.request, urllib.parse, urllib.error +import io import socket import select @@ -142,7 +142,7 @@ # ============================================================================ def loop(server,handler,timeout=30): while True: - k = client_handlers.keys() + k = list(client_handlers.keys()) # w = sockets to which there is something to send # we must test if we can send data w = [ cl for cl in client_handlers if client_handlers[cl].writable ] @@ -209,7 +209,7 @@ if (self.protocol == "HTTP/1.1" and close_conn.lower() == "keep-alive"): self.close_when_done = False # parse the url - scheme,netloc,path,params,query,fragment = urlparse.urlparse(self.url) + scheme,netloc,path,params,query,fragment = urllib.parse.urlparse(self.url) self.path,self.rest = path,(params,query,fragment) if self.method == 'POST': @@ -220,7 +220,7 @@ # request is incomplete if not all message body received if len(body)0: - print "about %u seconds passed and lock still exists" % i + print("about %u seconds passed and lock still exists" % i) time.sleep(1) - print "about %u seconds passed and lockfile is still locked - giving up" % timeout + print("about %u seconds passed and lockfile is still locked - giving up" % timeout) return -1 if __name__=="__main__": @@ -440,20 +440,20 @@ rootpath="@CGI_PATH@" datapath="@DATA_PATH@" - print - print " ######################## ! DEPRECATION WARNING ! #########################" - print " # #" - print " # mfscgiserv service is deprecated, please use lizardfs-cgiserv instead. #" - print " # See manual entry lizardfs-cgiserver(8) for details. #" - print " # #" - print " ######################## ! DEPRECATION WARNING ! #########################" - print + print() + print(" ######################## ! DEPRECATION WARNING ! #########################") + print(" # #") + print(" # mfscgiserv service is deprecated, please use lizardfs-cgiserv instead. #") + print(" # See manual entry lizardfs-cgiserver(8) for details. #") + print(" # #") + print(" ######################## ! DEPRECATION WARNING ! #########################") + print() opts,args = getopt.getopt(sys.argv[1:],"hH:P:R:D:t:fv") for opt,val in opts: if opt=='-h': - print "usage: %s [-H bind_host] [-P bind_port] [-R rootpath] [-D datapath] [-t locktimeout] [-f [-v]] [start|stop|restart|test]\n" % sys.argv[0] - print "-H bind_host : local address to listen on (default: any)\n-P bind_port : port to listen on (default: 9425)\n-R rootpath : local path to use as HTTP document root (default: @CGI_PATH@)\n-D datapath : local path to store data eg. lockfile (default: @DATA_PATH@)\n-t locktimeout : how long to wait for lockfile (default: 60s)\n-f : run in foreground\n-v : log requests on stderr" + print("usage: %s [-H bind_host] [-P bind_port] [-R rootpath] [-D datapath] [-t locktimeout] [-f [-v]] [start|stop|restart|test]\n" % sys.argv[0]) + print("-H bind_host : local address to listen on (default: any)\n-P bind_port : port to listen on (default: 9425)\n-R rootpath : local path to use as HTTP document root (default: @CGI_PATH@)\n-D datapath : local path to store data eg. lockfile (default: @DATA_PATH@)\n-t locktimeout : how long to wait for lockfile (default: 60s)\n-f : run in foreground\n-v : log requests on stderr") sys.exit(0) elif opt=='-H': host = val @@ -493,30 +493,30 @@ # daemonize try: pid = os.fork() - except OSError, e: - raise Exception, "fork error: %s [%d]" % (e.strerror, e.errno) + except OSError as e: + raise Exception("fork error: %s [%d]" % (e.strerror, e.errno)) if pid>0: posix.read(pipefd[0],1) os._exit(0) os.setsid() try: pid = os.fork() - except OSError, e: - raise Exception, "fork error: %s [%d]" % (e.strerror, e.errno) + except OSError as e: + raise Exception("fork error: %s [%d]" % (e.strerror, e.errno)) posix.write(pipefd[1],'0') if pid>0: os._exit(0) if wdlock(lockfname,mode,locktimeout)==1: - print "starting simple cgi server (host: %s , port: %u , rootpath: %s)" % (host,port,rootpath) + print("starting simple cgi server (host: %s , port: %u , rootpath: %s)" % (host,port,rootpath)) if daemonize: os.close(0) os.close(1) os.close(2) if os.open("/dev/null",os.O_RDWR)!=0: - raise Exception, "can't open /dev/null as 0 descriptor" + raise Exception("can't open /dev/null as 0 descriptor") os.dup2(0,1) os.dup2(0,2) @@ -530,9 +530,9 @@ # launch the server on the specified port if not daemonize: if host!='any': - print "Asynchronous HTTP server running on %s:%s" % (host,port) + print("Asynchronous HTTP server running on %s:%s" % (host,port)) else: - print "Asynchronous HTTP server running on port %s" % port + print("Asynchronous HTTP server running on port %s" % port) if not daemonize and verbose: HTTP.logging = True else: diff -urb lizardfs-3.12.0/src/cgi/chart.cgi.in lizardfs-3.12.0b/src/cgi/chart.cgi.in --- lizardfs-3.12.0/src/cgi/chart.cgi.in 2017-12-20 09:59:37.000000000 +0000 +++ lizardfs-3.12.0b/src/cgi/chart.cgi.in 2019-08-24 16:26:28.862416629 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import socket import struct @@ -12,18 +12,18 @@ fields = cgi.FieldStorage() -if fields.has_key("host"): +if "host" in fields: host = fields.getvalue("host") else: host = '' -if fields.has_key("port"): +if "port" in fields: try: port = int(fields.getvalue("port")) except ValueError: port = 0 else: port = 0 -if fields.has_key("id"): +if "id" in fields: try: chartid = int(fields.getvalue("id")) except ValueError: @@ -36,7 +36,7 @@ while totalsent < len(msg): sent = socket.send(msg[totalsent:]) if sent == 0: - raise RuntimeError, "socket connection broken" + raise RuntimeError("socket connection broken") totalsent = totalsent + sent def myrecv(socket,leng): @@ -44,15 +44,15 @@ while len(msg) < leng: chunk = socket.recv(leng-len(msg)) if chunk == '': - raise RuntimeError, "socket connection broken" + raise RuntimeError("socket connection broken") msg = msg + chunk return msg if host=='' or port==0 or chartid<0: - print "Content-Type: image/gif" - print + print("Content-Type: image/gif") + print() f = open('err.gif') - print f.read(), + print(f.read(), end=' ') f.close() else: try: @@ -66,32 +66,32 @@ # data = s.recv(length) # print len(data),length if data[:3]=="GIF": - print "Content-Type: image/gif" - print - print data, + print("Content-Type: image/gif") + print() + print(data, end=' ') elif data[:8]=="\x89PNG\x0d\x0a\x1a\x0a": - print "Content-Type: image/png" - print - print data, + print("Content-Type: image/png") + print() + print(data, end=' ') elif data[:9]=="timestamp": - print "Content-Type: text" - print - print data, + print("Content-Type: text") + print() + print(data, end=' ') else: - print "Content-Type: image/gif" + print("Content-Type: image/gif") f = open('err.gif') - print f.read(), + print(f.read(), end=' ') f.close() else: - print "Content-Type: image/gif" - print + print("Content-Type: image/gif") + print() f = open('err.gif') - print f.read(), + print(f.read(), end=' ') f.close() s.close() except Exception: - print "Content-Type: image/gif" - print + print("Content-Type: image/gif") + print() f = open('err.gif') - print f.read(), + print(f.read(), end=' ') f.close() Only in lizardfs-3.12.0b/src/cgi: chart.cgi.in.bak diff -urb lizardfs-3.12.0/src/cgi/lizardfs-cgiserver.py.in lizardfs-3.12.0b/src/cgi/lizardfs-cgiserver.py.in --- lizardfs-3.12.0/src/cgi/lizardfs-cgiserver.py.in 2017-12-20 09:59:37.000000000 +0000 +++ lizardfs-3.12.0b/src/cgi/lizardfs-cgiserver.py.in 2019-08-24 16:25:32.778174579 +0100 @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # vim: noexpandtab shiftwidth=4 softtabstop=4 tabstop=4 import fcntl @@ -13,9 +13,9 @@ import traceback import datetime import mimetypes -import urlparse -import urllib -import cStringIO +import urllib.parse +import urllib.request, urllib.parse, urllib.error +import io import socket import select import pwd @@ -140,7 +140,7 @@ # ============================================================================ def loop(server,handler,timeout=30): while True: - k = client_handlers.keys() + k = list(client_handlers.keys()) # w = sockets to which there is something to send # we must test if we can send data w = [ cl for cl in client_handlers if client_handlers[cl].writable ] @@ -207,7 +207,7 @@ if (self.protocol == "HTTP/1.1" and close_conn.lower() == "keep-alive"): self.close_when_done = False # parse the url - scheme,netloc,path,params,query,fragment = urlparse.urlparse(self.url) + scheme,netloc,path,params,query,fragment = urllib.parse.urlparse(self.url) self.path,self.rest = path,(params,query,fragment) if self.method == 'POST': @@ -218,7 +218,7 @@ # request is incomplete if not all message body received if len(body) head_len): tail = deserialize(buffer, tree[head_len:], True) return (head,) + tail @@ -147,7 +147,7 @@ """ Deserialize a std::string and remove it from buffer """ length = deserialize_primitive(buffer, "L") if len(buffer) < length or buffer[length - 1] != 0: - raise RuntimeError, "malformed message; cannot deserialize" + raise RuntimeError("malformed message; cannot deserialize") ret = str(buffer[0:length-1]) del buffer[0:length] return ret @@ -155,13 +155,13 @@ def deserialize_list(buffer, element_tree): """ Deserialize a list of elements and remove it from buffer """ length = deserialize_primitive(buffer, "L") - return [deserialize(buffer, element_tree) for i in xrange(length)] + return [deserialize(buffer, element_tree) for i in range(length)] def deserialize_dict(buffer, key_tree, value_tree): """ Deserialize a dict and remove it from buffer """ length = deserialize_primitive(buffer, "L") ret = {} - for i in xrange(length): + for i in range(length): key = deserialize(buffer, key_tree) val = deserialize(buffer, value_tree) ret[key] = val @@ -180,14 +180,14 @@ def cltoma_list_goals(): if masterversion < LIZARDFS_VERSION_WITH_CUSTOM_GOALS: # For old servers just return the default 10 goals - return [(i, str(i), str(i) + "*_") for i in xrange(1, 10)] + return [(i, str(i), str(i) + "*_") for i in range(1, 10)] else: # For new servers, use LIZ_CLTOMA_LIST_GOALS to fetch the list of goal definitions request = make_liz_message(LIZ_CLTOMA_LIST_GOALS, 0, "\1") response = send_and_receive(masterhost, masterport, request, LIZ_MATOCL_LIST_GOALS, 0) goals = deserialize(response, List(Primitive("H") + 2 * String)) if response: - raise RuntimeError, "malformed LIZ_MATOCL_LIST_GOALS response (too long by {0} bytes)".format(len(response)) + raise RuntimeError("malformed LIZ_MATOCL_LIST_GOALS response (too long by {0} bytes)".format(len(response))) return goals def cltoma_chunks_health(only_regular): @@ -198,7 +198,7 @@ safe, endangered, lost = deserialize(response, 3 * Dict(Primitive("B"), Primitive("Q"))) raw_replication, raw_deletion = deserialize(response, 2 * Dict(Primitive("B"), Tuple(11 * "Q"))) if response: - raise RuntimeError, "malformed LIZ_MATOCL_CHUNKS_HEALTH response (too long by {0} bytes)".format(len(response)) + raise RuntimeError("malformed LIZ_MATOCL_CHUNKS_HEALTH response (too long by {0} bytes)".format(len(response))) availability, replication, deletion = [], [], [] for (id, name, _) in goals: availability.append((name, safe.setdefault(id, 0), endangered.setdefault(id, 0), lost.setdefault(id, 0))) @@ -236,7 +236,7 @@ for (addr, port, v1, v2, v3) in servers: # for shadow masters, addr is int (4 bytes) -- convert it to string. # for the active master we use "masterhost" to connect with it and we don't know the real IP - ip = addr_to_host(addr) if isinstance(addr, (int, long)) else "-" + ip = addr_to_host(addr) if isinstance(addr, int) else "-" version = "%u.%u.%u" % (v1, v2, v3) if port == 0: # shadow didn't register its port yet @@ -267,14 +267,14 @@ return str.replace('&','&').replace('<','<').replace('>','>').replace("'",''').replace('"','"') def urlescape(str): - return urllib.quote_plus(str) + return urllib.parse.quote_plus(str) def mysend(socket,msg): totalsent = 0 while totalsent < len(msg): sent = socket.send(msg[totalsent:]) if sent == 0: - raise RuntimeError, "socket connection broken" + raise RuntimeError("socket connection broken") totalsent = totalsent + sent def myrecv(socket,leng): @@ -282,18 +282,18 @@ while len(msg) < leng: chunk = socket.recv(leng-len(msg)) if chunk == '': - raise RuntimeError, "socket connection broken" + raise RuntimeError("socket connection broken") msg = msg + chunk return msg def addr_to_host(addr): """ Convert IP address ('xxx.xxx.xxx.xxx' or 'hostname' or a 4-byte integer) to string """ - if isinstance(addr, (int, long)): + if isinstance(addr, int): return socket.inet_ntoa(struct.pack(">L", addr)) elif isinstance(addr, str): return addr else: - raise RuntimeError, "unknown format of server address" + raise RuntimeError("unknown format of server address") def send_and_receive(host, port, request, response_type, response_version = None): @@ -305,7 +305,7 @@ header = myrecv(s, 8) cmd, length = struct.unpack(">LL", header) if cmd != response_type: - raise RuntimeError, "received wrong response (%x instead of %x)" % (cmd, response_type) + raise RuntimeError("received wrong response (%x instead of %x)" % (cmd, response_type)) data = bytearray(myrecv(s, length)) except: s.close() @@ -314,7 +314,7 @@ if response_version is not None: version = deserialize_primitive(data, "L") if version != response_version: - raise RuntimeError, "received wrong response version (%u instead of %u)" % (version, response_version) + raise RuntimeError("received wrong response version (%u instead of %u)" % (version, response_version)) return data def decimal_number(number,sep=' '): @@ -382,43 +382,43 @@ elif length==68 or length==76: masterversion = struct.unpack(">HBB",data[:4]) except Exception: - print "Content-Type: text/html; charset=UTF-8" - print - print """""" - print """""" - print """""" - print """""" - print """LizardFS Info (%s)""" % (htmlentities(mastername)) - print """""" - print """""" - print """""" - print """""" - print """""" - print """

Can't connect to LizardFS master (IP:%s ; PORT:%u)

""" % (htmlentities(masterhost),masterport) - print """

Please enter alternative master address:""" - print """""" - print """

""" - print """""" - print """""" + """) + print("""""") + print("""""") + print("""

Can't connect to LizardFS master (IP:%s ; PORT:%u)

""" % (htmlentities(masterhost),masterport)) + print("""

Please enter alternative master address:""") + print("""""") + print("""

""") + print("""""") + print("""""") exit() if masterversion==(0,0,0): - print "Content-Type: text/html; charset=UTF-8" - print - print """""" - print """""" - print """""" - print """""" - print """LizardFS Info (%s)""" % (htmlentities(mastername)) - print """""" - print """""" - print """""" - print """""" - print """

Can't detect LizardFS master version

""" - print """""" - print """""" + print("Content-Type: text/html; charset=UTF-8") + print() + print("""""") + print("""""") + print("""""") + print("""""") + print("""LizardFS Info (%s)""" % (htmlentities(mastername))) + print("""""") + print("""""") + print("""""") + print("""""") + print("""

Can't detect LizardFS master version

""") + print("""""") + print("""""") exit() @@ -427,7 +427,7 @@ for k in fields: if k not in update: c.append("%s=%s" % (k,urlescape(fields.getvalue(k)))) - for k,v in update.iteritems(): + for k,v in update.items(): if v!="": c.append("%s=%s" % (k,urlescape(v))) return "mfs.cgi?%s" % ("&".join(c)) @@ -446,13 +446,13 @@ return createlink({revname:"1"}) if orderval==columnid and revval==0 else createlink({ordername:str(columnid),revname:"0"}) # commands -if fields.has_key("CSremove"): +if "CSremove" in fields: cmd_success = 0 tracedata = "" try: serverdata = fields.getvalue("CSremove").split(":") if len(serverdata)==2: - csip = map(int,serverdata[0].split(".")) + csip = list(map(int,serverdata[0].split("."))) csport = int(serverdata[1]) if len(csip)==4: s = socket.socket() @@ -466,45 +466,45 @@ tracedata = traceback.format_exc() url = createlink({"CSremove":""}) if cmd_success: - print "Status: 302 Found" - print "Location: %s" % url.replace("&","&") - print "Content-Type: text/html; charset=UTF-8" - print - print """""" - print """""" - print """""" - print """""" - print """""" % url - print """LizardFS Info (%s)""" % (htmlentities(mastername)) - print """""" - print """""" - print """""" - print """""" - print """

If you see this then it means that redirection didn't work, so click here

""" - print """""" - print """""" - else: - print "Content-Type: text/html; charset=UTF-8" - print - print """""" - print """""" - print """""" - print """""" - print """""" % url - print """LizardFS Info (%s)""" % (htmlentities(mastername)) - print """""" - print """""" - print """""" - print """""" - print """

Can't remove server (%s) from list - wait 5 seconds for refresh

""" % fields.getvalue("CSremove") + print("Status: 302 Found") + print("Location: %s" % url.replace("&","&")) + print("Content-Type: text/html; charset=UTF-8") + print() + print("""""") + print("""""") + print("""""") + print("""""") + print("""""" % url) + print("""LizardFS Info (%s)""" % (htmlentities(mastername))) + print("""""") + print("""""") + print("""""") + print("""""") + print("""

If you see this then it means that redirection didn't work, so click here

""") + print("""""") + print("""""") + else: + print("Content-Type: text/html; charset=UTF-8") + print() + print("""""") + print("""""") + print("""""") + print("""""") + print("""""" % url) + print("""LizardFS Info (%s)""" % (htmlentities(mastername))) + print("""""") + print("""""") + print("""""") + print("""""") + print("""

Can't remove server (%s) from list - wait 5 seconds for refresh

""" % fields.getvalue("CSremove")) if tracedata: - print """
""" - print """
%s
""" % tracedata - print """""" - print """""" + print("""
""") + print("""
%s
""" % tracedata) + print("""""") + print("""""") exit() -if fields.has_key("sections"): +if "sections" in fields: sectionstr = fields.getvalue("sections") sectionset = set(sectionstr.split("|")) else: @@ -550,53 +550,53 @@ sectionorder=["IN","CH","CS","HD","EX","MS","MO","MC","CC","HELP"]; -print "Content-Type: text/html; charset=UTF-8" -print +print("Content-Type: text/html; charset=UTF-8") +print() # print """ -print """""" -print """""" -print """""" -print """""" -print """LizardFS Info (%s)""" % (htmlentities(mastername)) -print """""" -print """""" -print """""" -print """""" +print("""""") +print("""""") +print("""""") +print("""""") +print("""LizardFS Info (%s)""" % (htmlentities(mastername))) +print("""""") +print("""""") +print("""""") +print("""""") #MENUBAR -print """""") #print """ #""" -print """
""" +print("""
""") if "IN" in sectionset: try: @@ -752,15 +752,15 @@ out.append(""" unrecognized answer from LizardFS master""") out.append("""""") s.close() - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") if masterversion>=(1,5,13): try: @@ -775,7 +775,7 @@ cmd,length = struct.unpack(">LL",header) if cmd==MATOCL_CHUNKS_MATRIX and length==484: matrix = [] - for i in xrange(11): + for i in range(11): data = myrecv(s,44) matrix.append(list(struct.unpack(">LLLLLLLLLLL",data))) out.append("""""") @@ -803,13 +803,13 @@ out.append(""" """) classsum = 7*[0] sumlist = 11*[0] - for neededCopies in xrange(11): + for neededCopies in range(11): out.append(""" """) if neededCopies==10: out.append(""" """) else: out.append(""" """ % neededCopies) - for vc in xrange(11): + for vc in range(11): if neededCopies==0: if vc==0: cl = "DELETEREADY" @@ -847,22 +847,22 @@ sumlist = [ a + b for (a,b) in zip(sumlist,matrix[neededCopies])] out.append(""" """) out.append(""" """) - for vc in xrange(11): + for vc in range(11): out.append(""" """ % sumlist[vc]) out.append(""" """ % sum(sumlist)) out.append(""" """) out.append(""" """) out.append("""
10+%u
all 1+%u%u
""" + " / ".join([""" - %s (%u)""" % (cl,desc,cl,classsum[clidx]) for clidx,cl,desc in [(0,"MISSING","missing"),(1,"ENDANGERED","endangered"),(2,"UNDERGOAL","undergoal"),(3,"NORMAL","stable"),(4,"OVERGOAL","overgoal"),(5,"DELETEPENDING","pending deletion"),(6,"DELETEREADY","ready to be removed")]]) + """
""") s.close() - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+			print("""""")
+			print(""""""
-			print """
""")
 			traceback.print_exc(file=sys.stdout)
-			print """
""" + print("""
""") - print """
""" + print("""
""") try: out = [] @@ -908,15 +908,15 @@ out.append(""" """) out.append("""""") s.close() - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") try: out = [] @@ -957,7 +957,7 @@ else: out.append(""" Important messages:""") out.append(""" """) - out.append("""
%s
""" % (urllib.unquote(data[36:]).replace("&","&").replace(">",">").replace("<","<"))) + out.append("""
%s
""" % (urllib.parse.unquote(data[36:]).replace("&","&").replace(">",">").replace("<","<"))) out.append(""" """) else: out.append(""" """) @@ -965,15 +965,15 @@ out.append(""" """) out.append("""""") s.close() - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") if "CH" in sectionset: try: @@ -998,7 +998,7 @@ out.append(make_table_row('', '', headers)) sums = 3 * [0] i = 0 - for goal, safe, endangered, lost in filter(lambda row: sum(row[1:]) > 0, availability): + for goal, safe, endangered, lost in [row for row in availability if sum(row[1:]) > 0]: out.append(""" """ % ("C1" if i % 2 == 0 else "C2")) i += 1 out.append((""" %s""" + 4 * """%s""") % @@ -1009,7 +1009,7 @@ make_cell(lost, "MISSING")) ) out.append(""" """) - sums = map(sum, zip(sums, [safe, endangered, lost])) # add row to the summary + sums = list(map(sum, list(zip(sums, [safe, endangered, lost])))) # add row to the summary # Add summary and end the table out.append(""" """) out.append((""" all""" + 4 * """%s""") % @@ -1029,14 +1029,14 @@ ) i = 0 sums = 11 * [0] - for row in filter(lambda row: sum(row[1:]) > 0, table): + for row in [row for row in table if sum(row[1:]) > 0]: out.append(""" """ % ("C1" if i % 2 == 0 else "C2")) i += 1 out.append((""" %s""" + 11 * """%s""") % ((row[0], make_cell(row[1], "NORMAL")) + tuple(map(make_cell, row[2:]))) ) out.append(""" """) - sums = map(sum, zip(sums, row[1:])) # add row to the summary + sums = list(map(sum, list(zip(sums, row[1:])))) # add row to the summary # Add summary and end the table out.append(""" """) out.append((""" all""" + 11 * """%s""") % tuple(map(make_cell, sums))) @@ -1047,14 +1047,14 @@ add_repl_del_state(out, "replicat", replication) out.append("""
""") add_repl_del_state(out, "delet", deletion) - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" - print """
""" + print("""
""") + print("""
""") if "CS" in sectionset: if masterversion >= LIZARDFS_VERSION_WITH_LIST_OF_SHADOWS: @@ -1091,14 +1091,14 @@ out.append(make_table_row('', '', (i,) + row)) i += 1 out.append("""""") - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+			print("""""")
+			print(""""""
-			print """
""")
 			traceback.print_exc(file=sys.stdout)
-			print """
""" - print """
""" + print("""
""") + print("""
""") out = [] @@ -1157,7 +1157,7 @@ else: vector_size = length / 54 pos = 0 - for i in xrange(vector_size): + for i in range(vector_size): if cmd==LIZ_MATOCL_CSERV_LIST: disconnected,v1,v2,v3,ip1,ip2,ip3,ip4,port,used,total,chunks,tdused,tdtotal,tdchunks,errcnt,label_length = struct.unpack(">BBBBBBBBHQQLQQLLL",data[pos:pos + 58]) label = data[pos+58:pos+58+label_length-1] @@ -1233,15 +1233,15 @@ out.append("""""") s.close() - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") if masterversion>=(1,6,5): out = [] @@ -1274,7 +1274,7 @@ data = myrecv(s,length) n = length/8 servers = [] - for i in xrange(n): + for i in range(n): d = data[i*8:(i+1)*8] v1,v2,v3,ip1,ip2,ip3,ip4 = struct.unpack(">HBBBBBB",d) strip = "%u.%u.%u.%u" % (ip1,ip2,ip3,ip4) @@ -1300,15 +1300,15 @@ i+=1 out.append("""""") s.close() - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+			print("""""")
+			print(""""""
-			print """
""")
 			traceback.print_exc(file=sys.stdout)
-			print """
""" + print("""
""") - print """
""" + print("""
""") if "HD" in sectionset: out = [] @@ -1346,7 +1346,7 @@ data = myrecv(s,length) n = length/54 servers = [] - for i in xrange(n): + for i in range(n): d = data[i*54:(i+1)*54] disconnected,v1,v2,v3,ip1,ip2,ip3,ip4,port,used,total,chunks,tdused,tdtotal,tdchunks,errcnt = struct.unpack(">BBBBBBBBHQQLQQLL",d) if disconnected==0: @@ -1355,7 +1355,7 @@ data = myrecv(s,length) n = length/50 servers = [] - for i in xrange(n): + for i in range(n): d = data[i*50:(i+1)*50] ip1,ip2,ip3,ip4,port,used,total,chunks,tdused,tdtotal,tdchunks,errcnt = struct.unpack(">BBBBHQQLQQLL",d) hostlist.append((1,5,0,ip1,ip2,ip3,ip4,port)) @@ -1602,15 +1602,15 @@ i+=1 out.append("""""") - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") if "EX" in sectionset: out = [] @@ -1816,11 +1816,11 @@ out.append("""""") out.append("""
""") except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") try: goals = cltoma_list_goals() @@ -1839,15 +1839,15 @@ definition = re.sub(r'([0-9]+)\*([A-Za-z0-9_]+)(,?)', r'\1 × \2\3 ', definition) out.append(""" %s%s%s""" % (row_class, id, name, definition)) out.append("""""") - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") if "ML" in sectionset: out = [] @@ -1899,7 +1899,7 @@ data = myrecv(s,length) n = length/136 servers = [] - for i in xrange(n): + for i in range(n): d = data[i*136:(i+1)*136] addrdata = d[0:8] stats_c = [] @@ -1915,7 +1915,7 @@ ver = "unknown" else: ver = "%d.%d.%d" % (v1,v2,v3) - for i in xrange(16): + for i in range(16): stats_c.append(struct.unpack(">L",d[i*4+8:i*4+12])) stats_l.append(struct.unpack(">L",d[i*4+72:i*4+76])) try: @@ -1943,25 +1943,25 @@ out.append(""" %s""" % host) out.append(""" %s""" % ipnum) out.append(""" %s""" % ver) - for st in xrange(16): + for st in range(16): out.append(""" %u""" % (stats_c[st])) out.append(""" """) out.append(""" """ % (((i-1)%2)*2+2)) - for st in xrange(16): + for st in range(16): out.append(""" %u""" % (stats_l[st])) out.append(""" """) i+=1 out.append("""""") s.close() - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") if "MS" in sectionset: out = [] @@ -2199,15 +2199,15 @@ i+=1 out.append("""""") s.close() - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") if "MO" in sectionset: out = [] @@ -2322,27 +2322,27 @@ out.append(""" %s""" % host) out.append(""" %s""" % ipnum) out.append(""" %s""" % info) - for st in xrange(16): + for st in range(16): out.append(""" %u""" % (stats_c[st])) out.append(""" %u""" % (sum(stats_c))) out.append(""" """) out.append(""" """ % (((i-1)%2)*2+2)) - for st in xrange(16): + for st in range(16): out.append(""" %u""" % (stats_l[st])) out.append(""" %u""" % (sum(stats_l))) out.append(""" """) i+=1 out.append("""""") s.close() - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") if "MC" in sectionset: out = [] @@ -2471,7 +2471,7 @@ out.append(""" """) out.append("""""") out.append("""""") - for i in xrange(2): + for i in range(2): out.append(""" """) out.append(""" """) out.append(""" """) out.append("""
""") out.append("""
%s
""" % (i,charts[0][2])) @@ -2489,21 +2489,21 @@ out.append("""
""") - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") if "CC" in sectionset: out = [] try: - if fields.has_key("CCdata"): + if "CCdata" in fields: CCdata = fields.getvalue("CCdata") else: CCdata = "" @@ -2521,7 +2521,7 @@ if cmd==MATOCL_CSERV_LIST and (length%54)==0: data = myrecv(s,length) n = length/54 - for i in xrange(n): + for i in range(n): d = data[i*54:(i+1)*54] disconnected,v1,v2,v3,ip1,ip2,ip3,ip4,port,used,total,chunks,tdused,tdtotal,tdchunks,errcnt = struct.unpack(">BBBBBBBBHQQLQQLL",d) if disconnected==0: @@ -2529,7 +2529,7 @@ elif cmd==MATOCL_CSERV_LIST and (length%50)==0: data = myrecv(s,length) n = length/50 - for i in xrange(n): + for i in range(n): d = data[i*50:(i+1)*50] ip1,ip2,ip3,ip4,port,used,total,chunks,tdused,tdtotal,tdchunks,errcnt = struct.unpack(">BBBBHQQLQQLL",d) hostlist.append((ip1,ip2,ip3,ip4,port)) @@ -2685,7 +2685,7 @@ out.append(""" """) out.append("""""") out.append("""""") - for i in xrange(2): + for i in range(2): out.append(""" """) out.append(""" """) out.append(""" """) out.append("""
""") out.append("""
%s
""" % (i,charts[0][2])) @@ -2755,30 +2755,30 @@ out.append("""
""") - print "\n".join(out) + print("\n".join(out)) except Exception: - print """""" - print """""") + print("""
"""
+		print("""""")
+		print(""""""
-		print """
""")
 		traceback.print_exc(file=sys.stdout)
-		print """
""" + print("""
""") - print """
""" + print("""
""") def print_file(name): f=open(name) for line in f: - print line + print(line) if "HELP" in sectionset: # FIXME(kulek@lizardfs.org) - it should be in separate file help.html however we are waiting for CMAKE to make it happen. #print_file("@CGI_PATH@/help.html") - print """please contact with help@lizardfs.com""" - print """
""" + print("""please contact with help@lizardfs.com""") + print("""
""") -print """
""" +print("""
""") -print """""" -print """""" +print("""""") +print("""""")