From b97e374cdbc7988e193f6377f2604f1d4b6264ea Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 4 Aug 2017 19:23:18 +1000 Subject: minimaws: expose system BIOS, better way of dropping tables --- scripts/minimaws/lib/assets/machine.js | 27 +++++++++++++++++++++++++++ scripts/minimaws/lib/dbaccess.py | 11 ++++++++--- scripts/minimaws/lib/htmltmpl.py | 13 +++++++++++-- scripts/minimaws/lib/wsgiserve.py | 18 ++++++++++++++++++ scripts/minimaws/minimaws.py | 5 +---- 5 files changed, 65 insertions(+), 9 deletions(-) (limited to 'scripts/minimaws') 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( ' Runnable:${runnable}\n' \ ' Source file:${sourcefile}\n') -MACHINE_SLOTS_PLACEHOLDER = string.Template( +MACHINE_OPTIONS_HEADING = string.Template( '

Options

\n' \ - '

\n' \ + '

\n') + +MACHINE_BIOS_PROLOGUE = string.Template( + '

System BIOS

' \ + '\n\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 -- cgit v1.2.3-70-g09d2