diff --git a/README.md b/README.md index f8da53b..db1ca4f 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ EDDN Status: http://eddn-gateway.elite-markets.net/ | http://eddn.ed-td.space/ | -------------------------------------------------------------------------------------- | ------------- | --------------- | --------------- | | [**E:D Market Connector**](https://github.com/Marginal/EDMarketConnector) | Otis B. | No | **Yes** (v1/v2) | | [**edce-client**](https://github.com/Andargor/edce-client/) | Andargor | No | **Yes** (v1/v2) | -| [**EDDB**](http://eddb.io/) | themroc | **Yes** (v1) | No | -| [**ED-TD**](http://ed-tb.space/) | AnthorNet | **Yes** (v1/v2) | **Yes** (v2) | +| [**EDDB**](http://eddb.io/) | themroc | **Yes** (v1/v2) | No | +| [**ED-TD**](http://ed-td.space/) | AnthorNet | **Yes** (v1/v2) | **Yes** (v2) | | [**EliteOCR**](https://forums.frontier.co.uk/showthread.php?t=68771) | seeebek | No | **Yes** (v1) | -| [**Maddavo's Market Data**](http://www.davek.com.au/td/) | maddavo | **Yes** (v1/v2) | **Yes** (v1/v2) | +| [**Maddavo's Market Data**](http://www.davek.com.au/td/) | maddavo | **Yes** (v1/v2) | **Yes** (v1/v2) | | [**RegulatedNoise DJ-version**](https://forums.frontier.co.uk/showthread.php?t=137732) | Duke | **Yes** (v1) | **Yes** (v1) | diff --git a/contrib/monitor/index.html b/contrib/monitor/index.html index be45c70..7673e50 100644 --- a/contrib/monitor/index.html +++ b/contrib/monitor/index.html @@ -39,7 +39,7 @@ @@ -100,6 +100,12 @@ - - + + Outdated messages + - + - + - + Messages passed to relay - @@ -223,10 +229,10 @@ -
+
-

Softwares

+

Software

@@ -260,7 +266,10 @@
-
+
+ Total hits calculated since May 5, 2015 +
+

Last updated: N/A.

@@ -310,7 +319,10 @@
-
+
+ Total hits calculated since May 5, 2015 +
+

Last updated: N/A.

@@ -326,7 +338,7 @@
-

Schemas

+

Schemas

@@ -360,7 +372,10 @@
-
+
+ Total hits calculated since May 5, 2015 +
+

Last updated: N/A.

@@ -392,4 +407,4 @@ - \ No newline at end of file + diff --git a/contrib/monitor/js/eddn.js b/contrib/monitor/js/eddn.js index 3a76909..5dcfd66 100644 --- a/contrib/monitor/js/eddn.js +++ b/contrib/monitor/js/eddn.js @@ -76,7 +76,7 @@ var doUpdateSoftwares = function() dataType: "json", url: monitorEndPoint + 'getTotalSoftwares/', success: function(softwaresTotalData){ - var chart = $('#softwares .chart').highcharts(), + var chart = $('#software .chart').highcharts(), series = chart.get('softwares'); // Count total by software, all versions included @@ -99,13 +99,13 @@ var doUpdateSoftwares = function() tmp.sort(function(a,b) { return b.total - a.total; }); softwaresTotal = tmp; - $('#softwares .table tbody').empty(); + $('#software .table tbody').empty(); // Prepare drilldowns $.each(softwaresTotalData, function(software, hits){ softwareSplit = software.split(' | '); - $('#softwares .table tbody').append( + $('#software .table tbody').append( newTr = $('').attr('data-type', 'drilldown').attr('data-parent', softwareSplit[0]).attr('data-name', software).on('mouseover', function(){ chart.get('software-' + makeSlug(software)).setState('hover'); chart.tooltip.refresh(chart.get('software-' + makeSlug(software))); @@ -144,7 +144,7 @@ var doUpdateSoftwares = function() // Add main softwares $.each(softwaresTotal, function(key, values){ - $('#softwares .table tbody').append( + $('#software .table tbody').append( newTr = $('').attr('data-type', 'parent').attr('data-name', values.name).on('click', function(event){ event.stopImmediatePropagation(); currentSoftware = $(this).attr('data-name'); @@ -153,22 +153,22 @@ var doUpdateSoftwares = function() { currentDrillDown = currentSoftware; - $('#softwares .table thead th:eq(0)').html('') + $('#software .table thead th:eq(0)').html('') .css('cursor','pointer') .on('click', function(){ currentDrillDown = false; chart.showDrillUpButton(); - $('#softwares .table thead th:eq(0)').html(''); - $('#softwares .table thead th:eq(1)').html(''); - $('#softwares .table tbody tr[data-type=parent]').show(); - $('#softwares .table tbody tr[data-type=drilldown]').hide(); + $('#software .table thead th:eq(0)').html(''); + $('#software .table thead th:eq(1)').html(''); + $('#software .table tbody tr[data-type=parent]').show(); + $('#software .table tbody tr[data-type=drilldown]').hide(); drillDownSoftware = !drillDownSoftware; doUpdateSoftwares(); chart.drillUp(); }); - $('#softwares .table thead th:eq(1)').html(currentSoftware); - $('#softwares .table tbody tr[data-type=parent]').hide(); - $('#softwares .table tbody tr[data-type=drilldown][data-parent="' + currentSoftware + '"]').show(); + $('#software .table thead th:eq(1)').html(currentSoftware); + $('#software .table tbody tr[data-type=parent]').hide(); + $('#software .table tbody tr[data-type=drilldown][data-parent="' + currentSoftware + '"]').show(); var currentData = []; @@ -191,7 +191,7 @@ var doUpdateSoftwares = function() if(chart.drillUpButton) chart.drillUpButton = chart.drillUpButton.destroy(); - $('#softwares .table tbody tr[data-type=drilldown][data-parent="' + currentSoftware + '"]').each(function(){ + $('#software .table tbody tr[data-type=drilldown][data-parent="' + currentSoftware + '"]').each(function(){ $(this).find('.square').css('background', chart.get('software-' + makeSlug($(this).attr('data-name'))).color); }); } @@ -237,18 +237,18 @@ var doUpdateSoftwares = function() }); if(drillDownSoftware) - $('#softwares .table tbody tr[data-type=drilldown][data-parent="' + currentDrillDown + '"]').each(function(){ + $('#software .table tbody tr[data-type=drilldown][data-parent="' + currentDrillDown + '"]').each(function(){ $(this).find('.square').css('background', chart.get('software-' + makeSlug($(this).attr('data-name'))).color); }); chart.redraw(); - $('#softwares').find(".stat").removeClass("warning").each(function() { + $('#software').find(".stat").removeClass("warning").each(function() { if ($(this).html() == "0") $(this).addClass("warning"); }); - $('#softwares').find(".update_timestamp").html(d.toString("yyyy-MM-dd HH:mm:ss")); + $('#software').find(".update_timestamp").html(d.toString("yyyy-MM-dd HH:mm:ss")); } }); } @@ -451,6 +451,10 @@ var showStats = function(type, currentItem){ el.find(".invalid_1min").html((currentItemStats["invalid"] || {})['1min'] || 0); el.find(".invalid_5min").html((currentItemStats["invalid"] || {})['5min'] || 0); el.find(".invalid_60min").html((currentItemStats["invalid"] || {})['60min'] || 0); + + el.find(".outdated_1min").html((currentItemStats["outdated"] || {})['1min'] || 0); + el.find(".outdated_5min").html((currentItemStats["outdated"] || {})['5min'] || 0); + el.find(".outdated_60min").html((currentItemStats["outdated"] || {})['60min'] || 0); } if(type == 'relays') @@ -525,8 +529,9 @@ var start = function(){ credits: { enabled: false }, exporting: { enabled: false }, series: [ - {id: 'inbound', data: [], name: 'Messages received', zIndex: 300}, - {id: 'invalid', data: [], name: 'Invalid messages', zIndex: 1}, + {id: 'inbound', data: [], name: 'Messages received', zIndex: 300}, + {id: 'invalid', data: [], name: 'Invalid messages', zIndex: 1}, + {id: 'outdated', data: [], name: 'Outdated messages', zIndex: 1}, {id: 'outbound', data: [], name: 'Messages passed to relay', zIndex: 200} ] }).hide(); @@ -590,7 +595,7 @@ var start = function(){ }, updateInterval); // Grab software from monitor - $('#softwares .chart').highcharts({ + $('#software .chart').highcharts({ chart: { type: 'pie', animation: Highcharts.svg }, diff --git a/contrib/monitor/schemas.html b/contrib/monitor/schemas.html new file mode 100644 index 0000000..e033951 --- /dev/null +++ b/contrib/monitor/schemas.html @@ -0,0 +1,312 @@ + + + + + + + EDDN Status - Schemas + + + + + + + + + + + + + +
+ +
+ +
+
+
+

Schemas (Last 60 days)

+
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+

Schemas in percent (Last 60 days)

+
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+ + + + + + + + + + + diff --git a/schemas/commodity-v0.1.json b/schemas/commodity-v0.1.json deleted file mode 100644 index c98b3dd..0000000 --- a/schemas/commodity-v0.1.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "id": "http://schemas.elite-markets.net/eddn/commodity/1#", - "type": "object", - "additionalProperties": false, - "properties": { - "$schemaRef": { - "type": "string", - "additionalProperties": false - }, - "header": { - "type": "object", - "additionalProperties": true, - "properties": { - "uploaderID": { - "type": "string", - "additionalProperties": false - }, - "softwareName": { - "type": "string", - "additionalProperties": false - }, - "softwareVersion": { - "type": "string", - "additionalProperties": false - }, - "gatewayTimestamp": { - "type": "string", - "format": "date-time", - "description": "Timestamp upon receipt at the gateway. If present, this property will be overwritten by the gateway; submitters are not intended to populate this property.", - "additionalProperties": false - } - } - }, - "message": { - "type": "object", - "additionalProperties": true, - "properties": { - "systemName": { - "type": "string", - "additionalProperties": false - }, - "stationName": { - "type": "string", - "additionalProperties": false - }, - "itemName": { - "type": "string", - "additionalProperties": false - }, - "buyPrice": { - "type": "integer", - "description": "Price to buy from the market", - "additionalProperties": false - }, - "stationStock": { - "type": "integer", - "additionalProperties": false - }, - "supplyLevel": { - "$ref": "#/definitions/levelType" - }, - "sellPrice": { - "type": "integer", - "description": "Price to sell to the market", - "additionalProperties": false - }, - "demand": { - "type": "integer", - "additionalProperties": false - }, - "demandLevel": { - "$ref": "#/definitions/levelType" - }, - "timestamp": { - "type": "string", - "format": "date-time", - "additionalProperties": false - } - }, - "required": [ - "systemName", - "stationName", - "itemName", - "stationStock", - "sellPrice", - "demand", - "timestamp" - ] - } - }, - "required": [ - "$schemaRef", - "header", - "message" - ], - "definitions" : { - "levelType" : { - "enum": ["Low", "Med", "High"] - } - } -} \ No newline at end of file diff --git a/schemas/shipyard-v1.0-draft.json b/schemas/shipyard-v1.0.json similarity index 100% rename from schemas/shipyard-v1.0-draft.json rename to schemas/shipyard-v1.0.json diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index fe0e39d..5534aeb 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -45,7 +45,7 @@ def configure(): sender.bind(binding) for schemaRef, schemaFile in Settings.GATEWAY_JSON_SCHEMAS.iteritems(): - validator.addSchemaResource(schemaRef, resource_string(__name__, schemaFile)) + validator.addSchemaResource(schemaRef, resource_string('eddn.Gateway', schemaFile)) def push_message(string_message, topic): @@ -130,6 +130,12 @@ def parse_and_error_handle(data): logger.error("Error to %s: %s" % (get_remote_address(), exc.message)) return str(exc) + # Here we check if an outdated schema has been passed + if parsed_message["$schemaRef"] in Settings.GATEWAY_OUTDATED_SCHEMAS: + response.status = '426 Upgrade Required' # Bottle (and underlying httplib) don't know this one + statsCollector.tally("outdated") + return "FAIL: The schema you have used is no longer supported. Please check for an updated version of your application." + validationResults = validator.validate(parsed_message) if validationResults.severity <= ValidationSeverity.WARN: @@ -206,7 +212,6 @@ class MalformedUploadError(Exception): def main(): loadConfig() - configure() run(host='0.0.0.0', port=Settings.GATEWAY_HTTP_PORT, server='gevent') diff --git a/src/eddn/conf/Settings.py b/src/eddn/conf/Settings.py index 1d436c7..c4cafcf 100644 --- a/src/eddn/conf/Settings.py +++ b/src/eddn/conf/Settings.py @@ -38,13 +38,18 @@ class _Settings(object): GATEWAY_IP_KEY_SALT = None GATEWAY_JSON_SCHEMAS = { - "http://schemas.elite-markets.net/eddn/commodity/1": "schemas/commodity-v0.1.json", - "http://schemas.elite-markets.net/eddn/commodity/1/test": "schemas/commodity-v0.1.json", - "http://schemas.elite-markets.net/eddn/commodity/2": "schemas/commodity-v2.0.json", - "http://schemas.elite-markets.net/eddn/commodity/2/test": "schemas/commodity-v2.0.json" + "http://schemas.elite-markets.net/eddn/commodity/2/test": "schemas/commodity-v2.0.json", + + "http://schemas.elite-markets.net/eddn/shipyard/1": "schemas/shipyard-v1.0.json", + "http://schemas.elite-markets.net/eddn/shipyard/1/test": "schemas/shipyard-v1.0.json" } + GATEWAY_OUTDATED_SCHEMAS = [ + "http://schemas.elite-markets.net/eddn/commodity/1", + "http://schemas.elite-markets.net/eddn/commodity/1/test" + ] + ############################################################################### # Monitor settings ############################################################################### diff --git a/src/eddn/conf/Version.py b/src/eddn/conf/Version.py index 5b67b06..6c46f47 100644 --- a/src/eddn/conf/Version.py +++ b/src/eddn/conf/Version.py @@ -1,3 +1,2 @@ -# coding: utf8 - -__version__ = "0.4" +# This should be a version number as understood by setuptools +__version__ = "0.5"