Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
maddavo committed Jan 23, 2015
1 parent 3c75a05 commit 867dfd7
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 19 deletions.
37 changes: 31 additions & 6 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,36 @@ def getItemByNameIndex(cur):
REE[O0] |
\BDOCK\b |
\BTERMINAL\b |
\bKIOO\b |
\bKID?[O0] |
\b[O3]E\b |
\bANDRA[O3]E\b |
\bAN[O3]RADE\b |
\bAN[O3]RA[O3]E\b
)\b''', flags=re.X)
\bAN[O3]RA[O3]E\b |
VVELL\b |
[O0]IRAC\b |
\bVV |
\b[O0]ER?\b |
\b[O0]RAKE |
HAR[O0]T\b |
\b[O0]ARK |
\b[O0]DAM |
[O0]EPOT |
\bMERE[O0] |
\b[O0]ENN?IS |
\bBRAN[o0] |
W[O0]{3} |
GO(D[O0]|[O0]D|[O0][O])ARD |
GO[DO0]{2}AR[O0] |
ORBRAL\b |
\bJOR[O0]A |
\bST[O0]ART |
\bQUIMPY |
\bVAR[O0]E |
EN[^T]?ERPRISE |
EN..ERPRISE |
\bMUR[O0]O |
\bBAR[O0]E
)''', flags=re.X)


def checkForOcrDerp(tdenv, systemName, stationName):
Expand Down Expand Up @@ -387,16 +411,17 @@ def changeStation(matches):

tdenv.DEBUG0("NEW STATION: {}", facility)

if checkForOcrDerp(tdenv, systemName, stationName):
stationID = DELETED
return

# Make sure it's valid.
try:
stationID = stationByName[facility]
except KeyError:
stationID = -1

if stationID < 0:
if checkForOcrDerp(tdenv, systemName, stationName):
stationID = DELETED
return
corrected = True
try:
correctName = corrections.systems[systemName]
Expand Down
1 change: 0 additions & 1 deletion commands/shipvendor_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# Original by Dirk Wilhelm

import csvexport
import difflib
import re
import sys

Expand Down
19 changes: 19 additions & 0 deletions corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
}

stations = {
"ANINOHANU/BAROEEN HANGER": DELETED,
"ANLAVE/SURIPARK" : DELETED,
"ARTEMIS/BURCKHAROT STATION": DELETED,
"BD-02 4304/BRANOENSTEIN ENTERPRISE": DELETED,
"ERLIK/REYNOLOS TERMINAL": DELETED,
"FUTHORC/ACQUIREO TASTE ORBITAL": DELETED,
"G 165-13/NAODODOUR PLATFORM": DELETED,
"HATMEHING/HEVEI.IUS TERMINAL": DELETED,
"HATMEHING/HEVEIIUS TERMINAL": DELETED,
"HIP 69913/KONORATYEV OUTPOST": DELETED,
"LHS 1453/SAAVEORA PORT": DELETED,
"LHS 3447/WORLIOGE TERMINAL": DELETED,
"LUGH/BALANOIN GATEWAY": DELETED,
"NARASIMHA/MENOEL SURVEY": DELETED,
"OSSITO/STOART MINES": DELETED,
"SORBAGO/CARROLLSURVEY": DELETED,
"THUNDERBIRD/QUIMPY PORT": DELETED,
"VEROANDI/VAROEMAN GATEWAY": DELETED,
"171 G. AQUARII/ELCANO OOCK": "Elcano Dock",
"21 DRACO/ROBERTS PORT": DELETED,
"37 XI BOOTIS/SCHIRRA PLANT": "Schirba Plant",
Expand Down Expand Up @@ -117,6 +135,7 @@
"MISISTURE/GELFANO DOCK": "Gelfand Dock",
"MISISTURE/GELFANO OOCK": "Gelfand Dock",
"MOKOSH/LUBEN ORBITAL": "Lubin Orbital",
"NLTT 49528/OCONNORLANQNG": "O'Connor Landing",
"NLTT 49528/O‹CONNOR LANDING": "O'Connor Landing",
"OCSHODHIS/LLOYD OOCK": "Lloyd Dock",
"ONGKAMPAN/PATTERSON STATION:274": "Patterson Station",
Expand Down
76 changes: 75 additions & 1 deletion data/System.csv

Large diffs are not rendered by default.

47 changes: 45 additions & 2 deletions edscupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,35 @@
import tradedb
import math
import misc.edsc
import os
import re
import sys

from tkinter import Tk

class UsageError(Exception):
pass


def get_cmdr(tdb):
try:
return os.environ['CMDR']
except KeyError:
pass

if 'SHLVL' not in os.environ and platform.system() == 'Windows':
how = 'set CMDR="yourname"'
else:
how = 'export CMDR="yourname"'

raise UsageError(
"No 'CMDR' variable set.\n"
"You can set an environment variable by typing:\n"
" "+how+"\n"
"at the command/shell prompt."
)


r = Tk()
r.withdraw()

Expand All @@ -46,6 +70,8 @@
tdb = tradedb.TradeDB()
date = tdb.query("SELECT MAX(modified) FROM System").fetchone()[0]

cmdr = get_cmdr(tdb)

startSys = tdb.lookupPlace(sys.argv[1])
ox, oy, oz = startSys.posX, startSys.posY, startSys.posZ

Expand All @@ -65,9 +91,11 @@
data = edsq.fetch()

ignore = [
'ADAM NAPAT',
'AN SEXSTANS',
'ALRAI SECTOR EL-Y C3-1',
'ALRAI SECTOR OI-T B3-6 A', # No 'A' at the end
'COL 285 SECTOR ZJ-Y B140-1',
'CORE SYS SECTOR HH-V B2-7',
'CRU7CIS SECTOR EQ-Y B2',
'CRUCIS SECTO GB-X B1-0',
Expand All @@ -87,6 +115,7 @@
'ROSS 41 A',
'SCORPII SECTOR KB-X A1-01', # should be SCORPII SECTOR KB-X A1-0
'WISE 0410+ 1502', # should be WISE 0410+1502
'WISE 2200-3628',
'WOLF 851 A',
'ZAGARAS',
]
Expand Down Expand Up @@ -129,6 +158,9 @@ def ischange(sysinfo):
]
print("{} changes".format(len(systems)))

if len(systems) > 0:
print("At the prompt enter y, n or q. Default is n")

with open("new.systems.csv", "w") as output:
try:
for sysinfo in systems:
Expand Down Expand Up @@ -162,16 +194,27 @@ def ischange(sysinfo):
name, x, y, z,
mname, mx, my, mz
), file=sys.stderr)
distance = float("{:.2f}".format(dist(x, y, z)))
paste(name.lower())
prompt = "'{}'".format(name)
prompt += " ({:.2f}ly)".format(dist(x, y, z))
prompt += " ({:.2f}ly)".format(distance)

ok = input(prompt+": y, n or q (default 'n')? ".format(name))
ok = input(prompt+"? ".format(name))
if ok.lower() == 'q':
break
if ok.lower() == 'y':
print("'{}',{},{},{},'Release 1.00-EDStar','{}'".format(
name, x, y, z, created,
), file=output)
print("Submitting distance")
sub = misc.edsc.StarSubmission(
star=name.upper(),
commander=cmdr,
distances={startSys.name(): distance},
)
r = sub.submit()
misc.edsc.annotate_submission_response(r)
print()
except KeyboardInterrupt:
print("^C")

33 changes: 33 additions & 0 deletions misc/derp-sentinel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python

import tradedb
tdb = tradedb.TradeDB()

names = set()

for sys in tdb.systemByID.values():
for stn in sys.stations:
names.add(stn.name().upper())

mutators = {
'D': [ 'O', '0', ],
'W': [ 'VV', ],
'R': [ 'IT' ],
}

def mutate(text, pos):
for i in range(pos, len(text)):
char = text[i]
if char not in mutators:
continue
bef, aft = text[:i], text[i+1:]
for mutant in mutators[char]:
t2 = bef + mutant + aft
yield t2
yield from mutate(str(t2), i+len(mutant))

for name in names:
for mutant in mutate(name, 0):
if mutant in names:
print("{} <-> {}".format(name, mutant))

46 changes: 45 additions & 1 deletion misc/edsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import absolute_import, with_statement, print_function, division, unicode_literals

from collections import defaultdict
from urllib.parse import urlencode
from urllib.request import Request, urlopen

Expand Down Expand Up @@ -138,6 +139,50 @@ def submit(self):
raise SubmissionError("Invalid server response: " + resp)


def annotate_submission_response(r):
if not isinstance(r, dict) or 'status' not in r:
print("Unknown EDSC response: {}".format(r))
return
status = r['status']
result = status['input'][0]['status']
if result['statusnum'] != 0:
print("*** {} (#{})".format(result['msg'], result['statusnum']))
systems = defaultdict(list)
for sysEnt in status['system']:
sysName = sysEnt['system'].upper()
systems[sysName] += [
"{} (#{})".format(
sysEnt['status']['msg'],
sysEnt['status']['statusnum'],
)
]
for triEnt in status['trilat']:
sysName = triEnt['system'].upper()
triStatus = triEnt['status']
triStatusNum = triStatus['statusnum']
if triStatusNum == 401:
coord = triEnt['coord']
msg = "Position [{},{},{}]".format(
coord['x'], coord['y'], coord['z']
)
else:
msg = "{} (#{})".format(triStatus['msg'], triStatusNum)
if not msg in systems[sysName]:
systems[sysName].append(msg)
for sys, vals in systems.items():
print("{}: {}.".format(sys, '. '.join(vals)))
for distEnt in status['dist']:
lhsName = distEnt['system1'].upper()
rhsName = distEnt['system2'].upper()
print("{}->{}: {} (#{}). Dist={}".format(
lhsName, rhsName,
distEnt['status']['msg'],
distEnt['status']['statusnum'],
distEnt['dist'],

))


if __name__ == "__main__":
edsq = StarQuery(test=False, confidence=0)
data = edsq.fetch()
Expand All @@ -153,4 +198,3 @@ def submit(self):

for sysinfo in systems:
print(sysinfo['id'], sysinfo['name'], sysinfo['coord'], sysinfo['createdate'])

19 changes: 11 additions & 8 deletions submit-distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import sys
import tradedb

from misc.edsc import StarSubmission
from misc.edsc import StarSubmission, annotate_submission_response
from tkinter import Tk

try:
Expand Down Expand Up @@ -354,13 +354,16 @@ def main():
)
resp = sub.submit()

status = resp['status']['input'][0]['status']
if status['statusnum'] == 0:
print(status['msg'])
else:
print("ERROR: {} ({})".format(
status['msg'], status['statusnum'],
))
try:
annotate_submission_response(resp)
except:
status = resp['status']['input'][0]['status']
if status['statusnum'] == 0:
print(status['msg'])
else:
print("ERROR: {} ({})".format(
status['msg'], status['statusnum'],
))


if __name__ == "__main__":
Expand Down

0 comments on commit 867dfd7

Please sign in to comment.