From 1f4b7a6a94afda1be39e601f43f8305a96dd3a7e Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> Date: Thu, 30 Sep 2021 10:43:00 +0200 Subject: [PATCH] These are Python 3 scripts Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> --- test-f5-login.py | 13 +++---------- test-fortinet-login.py | 12 +++--------- www/html.py | 6 +++--- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/test-f5-login.py b/test-f5-login.py index fe82ed52..21273d89 100755 --- a/test-f5-login.py +++ b/test-f5-login.py @@ -1,15 +1,8 @@ #!/usr/bin/python3 -from __future__ import print_function from sys import stderr, version_info -if (version_info >= (3, 0)): - from urllib.parse import urlparse, urlencode - raw_input = input - import http.client as httplib -else: - from urlparse import urlparse - from urllib import urlencode - import httplib +from urllib.parse import urlparse, urlencode +import http.client as httplib import requests import argparse import getpass @@ -58,7 +51,7 @@ assert any(c.value for c in s.cookies if c.name == 'MRHSession') and any(c.value # Send login credentials if args.username is None: - args.username = raw_input('Username: ') + args.username = input('Username: ') if args.password is None: args.password = getpass.getpass('Password: ') data = dict(username=args.username, password=args.password, diff --git a/test-fortinet-login.py b/test-fortinet-login.py index 0819a560..91875234 100755 --- a/test-fortinet-login.py +++ b/test-fortinet-login.py @@ -1,18 +1,12 @@ #!/usr/bin/python3 -from __future__ import print_function from sys import stderr, version_info import requests import argparse import getpass from shlex import quote -if (version_info >= (3, 0)): - from urllib.parse import urlparse, urlencode - raw_input = input - import http.client as httplib -else: - from urlparse import urlparse - import httplib +from urllib.parse import urlparse, urlencode +import http.client as httplib p = argparse.ArgumentParser() p.add_argument('-v', '--verbose', default=0, action='count') @@ -53,7 +47,7 @@ res = s.get(endpoint.geturl(), allow_redirects=False) # Send login credentials if args.username is None: - args.username = raw_input('Username: ') + args.username = input('Username: ') if args.password is None: args.password = getpass.getpass('Password: ') data = dict(username=args.username, credential=args.password, realm=args.realm, diff --git a/www/html.py b/www/html.py index f3278175..0facd819 100755 --- a/www/html.py +++ b/www/html.py @@ -46,7 +46,7 @@ def replaceVars(line): while cnt < len(replace): if line.find(replace[cnt]) >= 0: line = line.replace(replace[cnt], replace[cnt+1]) - cnt = cnt + 2 + cnt += 2 return line @@ -137,7 +137,7 @@ class docHandler(xml.sax.ContentHandler): writeHtml(">") def characters(self, ch): - self.content = self.content + ch + self.content += ch def endElement(self, name): @@ -235,7 +235,7 @@ if not arguments: if writefile > 0: fname = arguments[0].split('.')[0] - fname = fname + ".html" + fname += ".html" fdout = codecs.open(fname, 'w', 'utf-8') parseConfig(arguments[0]) -- 2.50.1