Skip to content

Commit

Permalink
Merge branch 'release/20190424001'
Browse files Browse the repository at this point in the history
  • Loading branch information
eve-n0rman committed Apr 25, 2019
2 parents 927668e + fa78785 commit ae4d5cb
Show file tree
Hide file tree
Showing 10 changed files with 1,378 additions and 1,253 deletions.
1 change: 1 addition & 0 deletions Pipfile
Expand Up @@ -11,6 +11,7 @@ redis = "*"
diskcache = "*"
esipy = "*"
pyyaml = ">=4.2b1"
urllib3 = "==1.23"

[requires]
python_version = "2.7"
133 changes: 72 additions & 61 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions requirements-dev.txt
@@ -1,4 +1,7 @@
-i https://pypi.org/simple
coverage==4.5.2
nose2==0.8.0
coverage==4.5.3
funcsigs==1.0.2 ; python_version < '3.3'
mock==2.0.0 ; python_version < '3.6'
nose2==0.9.1
pbr==5.1.3
six==1.12.0
14 changes: 7 additions & 7 deletions requirements.txt
@@ -1,21 +1,21 @@
-i https://pypi.org/simple
certifi==2018.11.29
certifi==2019.3.9
chardet==3.0.4
diskcache==3.1.1
ecdsa==0.13
ecdsa==0.13.2
esipy==1.0.0
future==0.17.1
futures==3.2.0
idna==2.8
pyaml==18.11.0
pyaml==19.4.1
pyasn1==0.4.5
pyswagger==0.8.39
python-jose==3.0.1
pytz==2018.9
pyyaml==4.2b4
redis==3.0.1
pytz==2019.1
pyyaml==5.1
redis==3.2.1
requests==2.21.0
rsa==4.0
six==1.12.0
urllib3==1.24.1
urllib3==1.23
validate-email==1.3
74 changes: 55 additions & 19 deletions structurebot.py
@@ -1,35 +1,71 @@
#!/usr/bin/env python

import logging
import argparse

from structurebot.config import CONFIG
from structurebot.util import notify_slack, name_to_id
from structurebot.citadels import check_citadels
from structurebot.citadels import Structure
from structurebot.assets import Asset
from structurebot.pos import check_pos


if __name__ == '__main__':
level = logging.WARNING
if CONFIG['DEBUG']:
level = logging.INFO
logging.basicConfig(level=level)
level = logging.WARNING
if CONFIG['DEBUG']:
level = logging.INFO
logging.basicConfig(level=level)

parser = argparse.ArgumentParser()
parser.add_argument('--suppress-upcoming-detonations', dest='upcoming_detonations', action='store_false')
parser.add_argument('--suppress-unscheduled-detonations', dest='unscheduled_detonations', action='store_false')
parser.add_argument('--suppress-ansiblex-ozone', dest='ansiblex_ozone', action='store_false')
parser.add_argument('--suppress-fuel-warning', dest='fuel_warning', action='store_false')
parser.add_argument('--suppress-service-state', dest='service_state', action='store_false')
parser.add_argument('--suppress-structure-state', dest='structure_state', action='store_false')

args = parser.parse_args()

messages = []
try:
corp_name = CONFIG['CORPORATION_NAME']
CONFIG['CORP_ID'] = name_to_id(corp_name, 'corporation')
assets = Asset.from_name(corp_name)
structures = Structure.from_corporation(corp_name, assets)
messages = []
try:
messages += check_citadels(corp_name, assets)
messages += check_pos(corp_name, assets)
except Exception, e:
if CONFIG['DEBUG']:
raise
if e.message:
messages = [e.message]
else:
raise
if messages:
messages.insert(0, ' Upcoming {} Structure Maintenence Tasks'.format(corp_name))
notify_slack(sorted(messages))
for structure in structures:
message = []
if not structure.accessible:
msg = 'Found an inaccesible citadel ({}) in {}'.format(structure.structure_id, structure.system_id)
messages.append(msg)
continue
if args.unscheduled_detonations and structure.needs_detonation:
message.append('Needs to have an extraction scheduled')
if args.upcoming_detonations and structure.detonates_soon:
message.append('Ready to detonate {}'.format(structure.detonation))
if args.ansiblex_ozone and structure.needs_ozone:
message.append('Low on Liquid Ozone: {}'.format(structure.jump_fuel))
if args.fuel_warning and structure.needs_fuel:
message.append('Runs out of fuel on {}'.format(structure.fuel_expires))
if args.service_state:
if structure.online_services:
message.append('Online Services: {}'.format(', '.join(structure.online_services)))
if structure.offline_services:
message.append('Offline Services: {}'.format(', '.join(structure.offline_services)))
if args.service_state and structure.offline_services:
message.append('Offline services: {}'.format(', '.join(structure.offline_services)))
if args.structure_state and (structure.vulnerable or structure.reinforced):
state = structure.state.replace('_', ' ').title()
message.append('{} until {}'.format(state, structure.state_timer_end))
if message:
messages.append(u'\n'.join([u'{}'.format(structure.name)] + message))
messages += check_pos(corp_name, assets)
except Exception, e:
if CONFIG['DEBUG']:
raise
else:
messages = [str(e)]
if messages:
messages.insert(0, ' Upcoming {} Structure Maintenence Tasks'.format(corp_name))
notify_slack(sorted(messages))


0 comments on commit ae4d5cb

Please sign in to comment.