summaryrefslogtreecommitdiffstatshomepage
path: root/scripts/minimaws
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-08-04 19:23:18 +1000
committer Vas Crabb <vas@vastheman.com>2017-08-04 19:23:18 +1000
commitb97e374cdbc7988e193f6377f2604f1d4b6264ea (patch)
tree24d9b899f6c086a4f0135e3ef96ffa3867da2799 /scripts/minimaws
parent3eb9ddfa1691ce147861a2648e34dc7478f8f3b8 (diff)
minimaws: expose system BIOS, better way of dropping tables
Diffstat (limited to 'scripts/minimaws')
-rw-r--r--scripts/minimaws/lib/assets/machine.js27
-rw-r--r--scripts/minimaws/lib/dbaccess.py11
-rw-r--r--scripts/minimaws/lib/htmltmpl.py13
-rw-r--r--scripts/minimaws/lib/wsgiserve.py18
-rwxr-xr-xscripts/minimaws/minimaws.py5
5 files changed, 65 insertions, 9 deletions
diff --git a/scripts/minimaws/lib/assets/machine.js b/scripts/minimaws/lib/assets/machine.js
index 223289c7811..30818e643bf 100644
--- a/scripts/minimaws/lib/assets/machine.js
+++ b/scripts/minimaws/lib/assets/machine.js
@@ -10,6 +10,17 @@ function update_cmd_preview()
{
var result = '';
var first = true;
+
+ var sysbios = document.getElementById('select-system-bios');
+ if (sysbios && (sysbios.selectedOptions[0].getAttribute('data-isdefault') != 'yes'))
+ {
+ if (first)
+ first = false;
+ else
+ result += ' ';
+ result += '-bios ' + sysbios.value;
+ }
+
var slotslist = document.getElementById('list-slot-options');
if (slotslist)
{
@@ -41,6 +52,22 @@ function update_cmd_preview()
}
+function set_default_system_bios()
+{
+ var sysbios = document.getElementById('select-system-bios');
+ var len = sysbios.options.length;
+ for (var i = 0; i < len; i++)
+ {
+ if (sysbios.options[i].getAttribute('data-isdefault') == 'yes')
+ {
+ sysbios.selectedIndex = i;
+ break;
+ }
+ }
+ update_cmd_preview();
+}
+
+
var fetch_bios_sets = (function ()
{
var pending = Object.create(null);
diff --git a/scripts/minimaws/lib/dbaccess.py b/scripts/minimaws/lib/dbaccess.py
index d453fe3d941..3366d6f7eb5 100644
--- a/scripts/minimaws/lib/dbaccess.py
+++ b/scripts/minimaws/lib/dbaccess.py
@@ -542,9 +542,14 @@ class UpdateConnection(object):
def prepare_for_load(self):
# here be dragons - this is a poor man's DROP ALL TABLES etc.
- self.dbconn.execute('PRAGMA writable_schema = 1')
- self.dbconn.execute('delete from sqlite_master where type in (\'table\', \'index\', \'trigger\')')
- self.dbconn.execute('PRAGMA writable_schema = 0')
+ self.dbconn.execute('PRAGMA foreign_keys = OFF')
+ for query in self.dbconn.execute('SELECT \'DROP INDEX \' || name FROM sqlite_master WHERE type = \'index\' AND NOT name GLOB \'sqlite_autoindex_*\'').fetchall():
+ self.dbconn.execute(query[0])
+ for query in self.dbconn.execute('SELECT \'DROP TABLE \' || name FROM sqlite_master WHERE type = \'table\'').fetchall():
+ self.dbconn.execute(query[0])
+ self.dbconn.execute('PRAGMA foreign_keys = ON')
+
+ # this is where the sanity starts
for query in SchemaQueries.DROP_INDEXES:
self.dbconn.execute(query)
for query in SchemaQueries.CREATE_TABLES:
diff --git a/scripts/minimaws/lib/htmltmpl.py b/scripts/minimaws/lib/htmltmpl.py
index 815905a59bb..8dd219f0681 100644
--- a/scripts/minimaws/lib/htmltmpl.py
+++ b/scripts/minimaws/lib/htmltmpl.py
@@ -48,9 +48,18 @@ MACHINE_PROLOGUE = string.Template(
' <tr><th>Runnable:</th><td>${runnable}</td></tr>\n' \
' <tr><th>Source file:</th><td><a href="${sourcehref}">${sourcefile}</a></td></tr>\n')
-MACHINE_SLOTS_PLACEHOLDER = string.Template(
+MACHINE_OPTIONS_HEADING = string.Template(
'<h2>Options</h2>\n' \
- '<p id="para-cmd-preview"></p>\n' \
+ '<p id="para-cmd-preview"></p>\n')
+
+MACHINE_BIOS_PROLOGUE = string.Template(
+ '<h3>System BIOS</h3>' \
+ '<select id="select-system-bios" onchange="update_cmd_preview()">')
+
+MACHINE_BIOS_OPTION = string.Template(
+ ' <option value="${name}" data-isdefault="${isdefault}">${name} - ${description}</option>\n')
+
+MACHINE_SLOTS_PLACEHOLDER = string.Template(
'<h3>Slots</h3>\n' \
'<p id="para-slots-placeholder">Loading slot information&hellip;<p>\n' \
'<script>fetch_slots("${machine}");</script>\n')
diff --git a/scripts/minimaws/lib/wsgiserve.py b/scripts/minimaws/lib/wsgiserve.py
index 370ca811fa6..e8182f06077 100644
--- a/scripts/minimaws/lib/wsgiserve.py
+++ b/scripts/minimaws/lib/wsgiserve.py
@@ -207,7 +207,25 @@ class MachineHandler(QueryPageHandler):
tuple(imperfect)).encode('utf-8');
yield '</table>\n'.encode('utf-8')
+ # allow system BIOS selection
+ haveoptions = False
+ for name, desc, isdef in self.dbcurs.get_biossets(id):
+ if not haveoptions:
+ haveoptions = True;
+ yield htmltmpl.MACHINE_OPTIONS_HEADING.substitute().encode('utf-8')
+ yield htmltmpl.MACHINE_BIOS_PROLOGUE.substitute().encode('utf-8')
+ yield htmltmpl.MACHINE_BIOS_OPTION.substitute(
+ name=cgi.escape(name, True),
+ description=cgi.escape(desc),
+ isdefault=('yes' if isdef else 'no')).encode('utf-8')
+ if haveoptions:
+ yield '</select>\n<script>set_default_system_bios();</script>\n'.encode('utf-8')
+
+ # placeholder for machine slots - populated by client-side JavaScript
if self.dbcurs.count_slots(id):
+ if not haveoptions:
+ haveoptions = True
+ yield htmltmpl.MACHINE_OPTIONS_HEADING.substitute().encode('utf-8')
yield htmltmpl.MACHINE_SLOTS_PLACEHOLDER.substitute(
machine=self.js_escape(self.shortname)).encode('utf=8')
diff --git a/scripts/minimaws/minimaws.py b/scripts/minimaws/minimaws.py
index 6f9fc938123..ecd0959d3ed 100755
--- a/scripts/minimaws/minimaws.py
+++ b/scripts/minimaws/minimaws.py
@@ -10,11 +10,8 @@
## -h or --help).
##
## Before you can use the scripts, you need to load MAME system
-## information into a database. This currently requires a few manual
-## steps, and you need to start with a completely clean database:
+## information into a database:
##
-## $ rm minimaws.sqlite3
-## $ sqlite3 minimaws.sqlite3 < schema.sql
## $ python minimaws.py load --executable path/to/mame
##
## (The script uses the name "minimaws.sqlite3" for the database by