Commit a956fb03 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

playbook: erp5-show doesn't depend on slapproxy version

See merge request nexedi/slapos.package!146
parent 08c210ba
...@@ -11,6 +11,11 @@ import urllib2 ...@@ -11,6 +11,11 @@ import urllib2
from xml.dom import minidom from xml.dom import minidom
import json import json
import hashlib import hashlib
import string
conn = sqlite3.connect("/opt/slapos/slapproxy.db")
proxy_table_name_dict = {t.rstrip(string.digits): t for t, in conn.execute(
"SELECT name FROM sqlite_master WHERE type='table'")}
def fmt_date(): def fmt_date():
return time.strftime("%Y%m%d") return time.strftime("%Y%m%d")
...@@ -18,15 +23,10 @@ def fmt_date(): ...@@ -18,15 +23,10 @@ def fmt_date():
# get all of the installed software types by checking the SR urls # get all of the installed software types by checking the SR urls
# return a list, and run routine on all of them # return a list, and run routine on all of them
def discover_software(): def discover_software():
conn = sqlite3.connect("/opt/slapos/slapproxy.db") qry = conn.execute("SELECT DISTINCT url FROM %(software)s" % proxy_table_name_dict)
cur = conn.cursor()
qry = cur.execute("SELECT DISTINCT url FROM software14")
return [row[0] for row in qry if row[0]] return [row[0] for row in qry if row[0]]
def get_connection_information(software_release): def get_connection_information(software_release):
conn = sqlite3.connect("/opt/slapos/slapproxy.db")
cur = conn.cursor()
if 'software/apache-frontend' not in software_release: if 'software/apache-frontend' not in software_release:
partition_reference = 'instance-of-%' partition_reference = 'instance-of-%'
elif 'software/apache-frontend' in software_release: elif 'software/apache-frontend' in software_release:
...@@ -34,7 +34,7 @@ def get_connection_information(software_release): ...@@ -34,7 +34,7 @@ def get_connection_information(software_release):
else: else:
raise ValueError raise ValueError
qry = cur.execute("SELECT connection_xml FROM partition14 WHERE connection_xml IS NOT NULL AND software_release=? AND partition_reference LIKE ?", (software_release, partition_reference) ) qry = conn.execute("SELECT connection_xml FROM %(partition)s WHERE connection_xml IS NOT NULL AND software_release=? AND partition_reference LIKE ?" % proxy_table_name_dict, (software_release, partition_reference) )
xml = None xml = None
for row in qry: for row in qry:
xml = str(row[0]) xml = str(row[0])
...@@ -78,11 +78,7 @@ def get_connection_information(software_release): ...@@ -78,11 +78,7 @@ def get_connection_information(software_release):
raise ValueError raise ValueError
def check_tables(): def check_tables():
conn = sqlite3.connect("/opt/slapos/slapproxy.db") if 'partition' not in proxy_table_name_dict:
cur = conn.cursor()
qry = cur.execute("SELECT CASE WHEN tbl_name = 'partition14' THEN 1 ELSE 0 END FROM sqlite_master WHERE tbl_name = 'partition14' AND type = 'table'")
if qry is None:
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)
......
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