Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
secondfry committed May 14, 2018
2 parents 6b26d4f + 330e6e6 commit c37ebcf
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 59 deletions.
2 changes: 1 addition & 1 deletion src/shortcircuit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@


__appname__ = "Short Circuit"
__version__ = "v0.2.2-beta"
__version__ = "v0.2.3-beta"
2 changes: 1 addition & 1 deletion src/shortcircuit/model/evescout.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, eve_db, url="https://www.eve-scout.com/api/wormholes"):
def augment_map(self, solar_map):
connections = -1
headers = {
"User-Agent": "Short Circuit v0.2.2-beta"
"User-Agent": "Short Circuit v0.2.3-beta"
}
try:
result = requests.get(
Expand Down
121 changes: 64 additions & 57 deletions src/shortcircuit/model/tripwire.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Tripwire:
"""
Tripwire handler
"""
USER_AGENT = "Short Circuit v0.2.2-beta"
USER_AGENT = "Short Circuit v0.2.3-beta"

def __init__(self, eve_db, username, password, url):
self.eve_db = eve_db
Expand Down Expand Up @@ -92,15 +92,20 @@ def augment_map(self, solar_map):

# Process wormholes
for wormholeId, wormhole in chain['wormholes'].iteritems():
if wormhole['type'] == 'GATE':
continue
try:
if wormhole['type'] == 'GATE':
continue

if not wormhole['parent']:
signatureIn = chain['signatures'][wormhole['initialID']]
signatureOut = chain['signatures'][wormhole['secondaryID']]
wh_type = '????'
else:
parent = wormhole['parent'] + 'ID'
if wormhole['initialID'] not in chain['signatures']:
continue

if wormhole['secondaryID'] not in chain['signatures']:
continue

if not wormhole['parent']:
parent = 'initialID'
else:
parent = wormhole['parent'] + 'ID'
sibling = {
'initialID': 'secondaryID',
'secondaryID': 'initialID',
Expand All @@ -109,54 +114,56 @@ def augment_map(self, solar_map):
signatureOut = chain['signatures'][wormhole[sibling]]
wh_type = wormhole['type']

systemFrom = convert_to_int(signatureIn['systemID'])
systemTo = convert_to_int(signatureOut['systemID'])

if systemFrom == 0 or systemFrom < 10000 or systemTo == 0 or systemTo < 10000:
continue

connections += 1

wh_life = {
'stable': 1,
'critical': 0,
}.get(wormhole['life'], 0)

wh_mass = {
'stable': 2,
'destab': 1,
'critical': 0,
}.get(wormhole['mass'], 0)

# Compute time elapsed from this moment to when the signature was updated
last_modified = datetime.strptime(signatureIn['modifiedTime'], "%Y-%m-%d %H:%M:%S")
delta = datetime.utcnow() - last_modified
time_elapsed = round(delta.total_seconds() / 3600.0, 1)

# Determine wormhole size
wh_size = -1
if wormhole['type']:
wh_size = self.eve_db.get_whsize_by_code(wormhole['type'])
if wh_size not in [0, 1, 2, 3]:
# Wormhole codes are unknown => determine size based on class of wormholes
wh_size = self.eve_db.get_whsize_by_system(systemFrom, systemTo)

# Add wormhole conection to solar system
solar_map.add_connection(
systemFrom,
systemTo,
SolarMap.WORMHOLE,
[
signatureIn['signatureID'],
wh_type,
signatureOut['signatureID'],
'K162',
wh_size,
wh_life,
wh_mass,
time_elapsed
],
)
systemFrom = convert_to_int(signatureIn['systemID'])
systemTo = convert_to_int(signatureOut['systemID'])

if systemFrom == 0 or systemFrom < 10000 or systemTo == 0 or systemTo < 10000:
continue

connections += 1

wh_life = {
'stable': 1,
'critical': 0,
}.get(wormhole['life'], 0)

wh_mass = {
'stable': 2,
'destab': 1,
'critical': 0,
}.get(wormhole['mass'], 0)

# Compute time elapsed from this moment to when the signature was updated
last_modified = datetime.strptime(signatureIn['modifiedTime'], "%Y-%m-%d %H:%M:%S")
delta = datetime.utcnow() - last_modified
time_elapsed = round(delta.total_seconds() / 3600.0, 1)

# Determine wormhole size
wh_size = -1
if wormhole['type']:
wh_size = self.eve_db.get_whsize_by_code(wormhole['type'])
if wh_size not in [0, 1, 2, 3]:
# Wormhole codes are unknown => determine size based on class of wormholes
wh_size = self.eve_db.get_whsize_by_system(systemFrom, systemTo)

# Add wormhole conection to solar system
solar_map.add_connection(
systemFrom,
systemTo,
SolarMap.WORMHOLE,
[
signatureIn['signatureID'],
wh_type,
signatureOut['signatureID'],
'K162',
wh_size,
wh_life,
wh_mass,
time_elapsed
],
)
except Exception as e:
pass

return connections

Expand Down

0 comments on commit c37ebcf

Please sign in to comment.