Commit 06ba44ec authored by Jérome Perrin's avatar Jérome Perrin

standalone-shared/erp5-show: use python3

This script had #!/opt/slapos/parts/python2.7/bin/python2.7 which we
no longer ship.

This might be the reason why the test fail with an error like this in the log

    TASK [standalone-shared : Check ERP5 state] ************************************
    fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": "/usr/local/bin/erp5-show -s", "delta": "0:00:00.003072", "end": "2022-09-01 22:49:43.877821", "failed": true, "rc": 127, "start": "2022-09-01 22:49:43.874749", "stderr": "/bin/sh: 1: /usr/local/bin/erp5-show: not found", "stdout": "", "stdout_lines": [], "warnings": []}
parent 459e7225
#!/opt/slapos/parts/python2.7/bin/python2.7 #!/opt/slapos/parts/python3/bin/python3
import os import os
import sys import sys
...@@ -7,7 +7,7 @@ import time ...@@ -7,7 +7,7 @@ import time
import getopt import getopt
import sqlite3 import sqlite3
import ssl import ssl
import urllib2 import urllib.request, urllib.error, urllib.parse
from xml.dom import minidom from xml.dom import minidom
import json import json
import hashlib import hashlib
...@@ -79,7 +79,7 @@ def get_connection_information(software_release): ...@@ -79,7 +79,7 @@ def get_connection_information(software_release):
def check_tables(): def check_tables():
if 'partition' not in proxy_table_name_dict: if 'partition' not in proxy_table_name_dict:
print "tables aren't ready yet, your build may have failed, check logs in /opt/slapos/log/" print("tables aren't ready yet, your build may have failed, check logs in /opt/slapos/log/")
sys.exit(0) sys.exit(0)
def get_build_status(software_release): def get_build_status(software_release):
...@@ -146,30 +146,30 @@ def status(): ...@@ -146,30 +146,30 @@ def status():
ctx.verify_mode = ssl.CERT_NONE ctx.verify_mode = ssl.CERT_NONE
try: try:
r1 = urllib2.urlopen(frontend, context=ctx) r1 = urllib.request.urlopen(frontend, context=ctx)
if 'Zope Management Interface' in r1.read(): if 'Zope Management Interface' in r1.read():
connected = True connected = True
else: else:
print 'URL %s ready, but does not reply with Zope' % frontend print('URL %s ready, but does not reply with Zope' % frontend)
except urllib2.URLError, e: except urllib.error.URLError as e:
print "Zope not available yet: %s" % e print("Zope not available yet: %s" % e)
if zope_ip is None or frontend is None or frontend_ip is None or not connected: if zope_ip is None or frontend is None or frontend_ip is None or not connected:
print "Build successful, please wait for instantiation" print("Build successful, please wait for instantiation")
sys.exit(2) sys.exit(2)
print ("Build successful, connect to:\n" print(("Build successful, connect to:\n"
" " + frontend) " " + frontend))
if pw is not None: if pw is not None:
print (" with\n" print((" with\n"
" username: zope password: " + pw) " username: zope password: " + pw))
elif not build: elif not build:
if 'error' in [software_release_list_status]: if 'error' in [software_release_list_status]:
print "An error occurred while building, check /opt/slapos/log/slapos-node-software-" + \ print("An error occurred while building, check /opt/slapos/log/slapos-node-software-" + \
fmt_date() + ".log for details" fmt_date() + ".log for details")
sys.exit(2) sys.exit(2)
else: else:
print "Your software is still building, be patient it can take a while" print("Your software is still building, be patient it can take a while")
sys.exit(2) sys.exit(2)
ipv6 = None ipv6 = None
...@@ -190,39 +190,39 @@ def status(): ...@@ -190,39 +190,39 @@ def status():
ctx.verify_mode = ssl.CERT_NONE ctx.verify_mode = ssl.CERT_NONE
try: try:
r1 = urllib2.urlopen(zope_ip, context=ctx) r1 = urllib.request.urlopen(zope_ip, context=ctx)
except urllib2.URLError, e: except urllib.error.URLError as e:
print "At least one of your services isn't running! Check with slapos node" print("At least one of your services isn't running! Check with slapos node")
print "restart a service with slapos node restart slappart:service" print("restart a service with slapos node restart slappart:service")
print "" print("")
print "DEBUG information: %s" % e print("DEBUG information: %s" % e)
sys.exit(2) sys.exit(2)
if r1.getcode() != 200: if r1.getcode() != 200:
print "At least one of your services isn't running! Check with slapos node" print("At least one of your services isn't running! Check with slapos node")
print "restart a service with slapos node restart slappart:service" print("restart a service with slapos node restart slappart:service")
sys.exit(2) sys.exit(2)
if ipv6: if ipv6:
print "" print("")
print "The URL above may require extra configuration if you want to access it" print("The URL above may require extra configuration if you want to access it")
print "from another machine. You can install an apache locally and include the" print("from another machine. You can install an apache locally and include the")
print "the follow rewrite rule (http version):" print("the follow rewrite rule (http version):")
print """ print("""
RewriteRule ^/(.*) %s/VirtualHostBase/http/%%{HTTP_HOST}/VirtualHostRoot/$1 [L,P] RewriteRule ^/(.*) %s/VirtualHostBase/http/%%{HTTP_HOST}/VirtualHostRoot/$1 [L,P]
or (https version): or (https version):
RewriteRule ^/(.*) %s/VirtualHostBase/https/%%{HTTP_HOST}/VirtualHostRoot/$1 [L,P] RewriteRule ^/(.*) %s/VirtualHostBase/https/%%{HTTP_HOST}/VirtualHostRoot/$1 [L,P]
""" % (original_zope_ip, original_zope_ip) """ % (original_zope_ip, original_zope_ip))
def info(software_release): def info(software_release):
if get_build_status(software_release): if get_build_status(software_release):
print get_connection_information(software_release) print(get_connection_information(software_release))
else: else:
print "Information unavailable at this time, run " + sys.argv[0] + " -s for details" print("Information unavailable at this time, run " + sys.argv[0] + " -s for details")
def usage(): def usage():
print ("Get the status and information of your ERP5 build\n" print ("Get the status and information of your ERP5 build\n"
...@@ -239,7 +239,7 @@ def main(argv): ...@@ -239,7 +239,7 @@ def main(argv):
# parse command line options # parse command line options
try: try:
opts, args = getopt.getopt(argv, "sihd", ["status", "info", "help", "dump"]) opts, args = getopt.getopt(argv, "sihd", ["status", "info", "help", "dump"])
except getopt.error, msg: except getopt.error as msg:
usage() usage()
sys.exit(2) sys.exit(2)
if len(opts) == 0: if len(opts) == 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment