def parse_N(self, scan_id, scan, page): #incoming fleets #<td class=left valign=top>Incoming</td><td valign=top>851</td><td class=left valign=top>We have detected an open jumpgate from Tertiary, located at 18:5:11. The fleet will approach our system in tick 855 and appears to have roughly 95 ships.</td> for m in re.finditer('<td class="left" valign="top">Incoming</td><td valign="top">(\d+)</td><td class="left" valign="top">We have detected an open jumpgate from ([^<]+), located at (\d+):(\d+):(\d+). The fleet will approach our system in tick (\d+) and appears to have roughly (\d+) ships.</td>', page): fleetscan = FleetScan() newstick = m.group(1) fleetname = m.group(2) originx = m.group(3) originy = m.group(4) originz = m.group(5) arrivaltick = int(m.group(6)) numships = m.group(7) fleetscan.mission = "Unknown" fleetscan.fleet_name = fleetname fleetscan.launch_tick = newstick fleetscan.landing_tick = arrivaltick fleetscan.fleet_size = numships owner=Planet.load(originx,originy,originz) if owner is None: continue fleetscan.owner = owner fleetscan.target = scan.planet try: scan.fleets.append(fleetscan) session.commit() except Exception, e: session.rollback() print "Exception in news: "+e.__str__() traceback.print_exc() continue print 'Incoming: ' + newstick + ':' + fleetname + '-' + originx + ':' + originy + ':' + originz + '-' + arrivaltick + '|' + numships
def parse_J(self, scan_id, scan, page): # <td class=left>Origin</td><td class=left>Mission</td><td>Fleet</td><td>ETA</td><td>Fleetsize</td> # <td class=left>13:10:5</td><td class=left>Attack</td><td>Gamma</td><td>5</td><td>265</td> # <td class="left">15:7:11 </td><td class="left">Defend </td><td>Ad infinitum</td><td>9</td><td>0</td> #<tr><td class="left">10:4:9</td><td class="left">Return</td><td>They look thirsty</td><td>5</td><td>3000</td></tr> # <tr><td class="left">4:1:10</td><td class="left">Return</td><td>Or Is It?</td><td>9</td><td>3000</td></tr> #<tr><td class="left">10:1:10</td><td class="left">Defend</td><td class="left">Pesticide IV</td><td class="right">1</td><td class="right">0</td></tr> for m in re.finditer('<td[^>]*>(?:<a[^>]+>)?(\d+)\:(\d+)\:(\d+)(?:</a>)?[^/]*/[^/]*/td><td[^>]*>([^<]+)</td><td[^>]*>([^<]+)</td><td[^>]*>(\d+)</td><td[^>]*>(\d+(?:,\d{3})*)</td>', page): scanlog("%s:%s:%s %s %s %s %s" %m.groups()) fleetscan = FleetScan() originx = m.group(1) originy = m.group(2) originz = m.group(3) mission = m.group(4) fleet = m.group(5) eta = int(m.group(6)) fleetsize = m.group(7).replace(',', '') fleetscan.mission = mission fleetscan.fleet_name = fleet fleetscan.landing_tick = eta + scan.tick fleetscan.fleet_size = fleetsize attacker=PlanetHistory.load_planet(originx,originy,originz,scan.tick) if attacker is None: scanlog("Can't find attacker in db: %s:%s:%s tick: %s"%(originx,originy,originz, scan.tick)) continue fleetscan.owner = attacker fleetscan.target = scan.planet fleetscan.in_cluster = fleetscan.owner.x == fleetscan.target.x fleetscan.in_galaxy = fleetscan.in_cluster and fleetscan.owner.y == fleetscan.target.y try: scan.fleets.append(fleetscan) session.commit() except IntegrityError, e: session.rollback() scanlog("Caught integrity exception in jgp: %s"%(str(e),)) scanlog("Trying to update instead") query = session.query(FleetScan).filter_by(owner=attacker, target=scan.planet, fleet_size=fleetsize, fleet_name=fleet, landing_tick=eta+scan.tick, mission=mission) try: query.update({"scan_id": scan_id}) session.commit() except Exception, e: session.rollback() scanlog("Exception trying to update jgp: %s"%(str(e),), traceback=True) continue
def parse_J(self, scan_id, scan, page): # <td class=left>Origin</td><td class=left>Mission</td><td>Fleet</td><td>ETA</td><td>Fleetsize</td> # <td class=left>13:10:5</td><td class=left>Attack</td><td>Gamma</td><td>5</td><td>265</td> # <td class="left">15:7:11 </td><td class="left">Defend </td><td>Ad infinitum</td><td>9</td><td>0</td> #<tr><td class="left">10:4:9</td><td class="left">Return</td><td>They look thirsty</td><td>5</td><td>3000</td></tr> # <tr><td class="left">4:1:10</td><td class="left">Return</td><td>Or Is It?</td><td>9</td><td>3000</td></tr> #<tr><td class="left">10:1:10</td><td class="left">Defend</td><td class="left">Pesticide IV</td><td class="right">1</td><td class="right">0</td></tr> for m in re.finditer('<td[^>]*>(\d+)\:(\d+)\:(\d+)</td><td[^>]*>([^<]+)</td><td[^>]*>([^<]+)</td><td[^>]*>(\d+)</td><td[^>]*>(\d+(?:,\d{3})*)</td>', page): fleetscan = FleetScan() originx = m.group(1) originy = m.group(2) originz = m.group(3) mission = m.group(4) fleet = m.group(5) eta = int(m.group(6)) fleetsize = m.group(7).replace(',', '') fleetscan.mission = mission fleetscan.fleet_name = fleet fleetscan.landing_tick = eta + scan.tick fleetscan.fleet_size = fleetsize print "JGP fleet " attacker=Planet.load(originx,originy,originz) if attacker is None: print "Can't find attacker in db: %s:%s:%s"%(originx,originy,originz) continue fleetscan.owner = attacker fleetscan.target = scan.planet try: scan.fleets.append(fleetscan) session.commit() except IntegrityError, e: session.rollback() print "Caught integrity exception in jgp: "+e.__str__() print "Trying to update instead" query = session.query(FleetScan).filter_by(owner=attacker, target=scan.planet, fleet_size=fleetsize, fleet_name=fleet, landing_tick=eta+scan.tick, mission=mission) try: query.update({"scan_id": scan_id}) session.commit() except Exception, e: session.rollback() print "Exception trying to update jgp: "+e.__str__() traceback.print_exc() continue
def parse_N(self, scan_id, scan, page): #incoming fleets #<td class=left valign=top>Incoming</td><td valign=top>851</td><td class=left valign=top>We have detected an open jumpgate from Tertiary, located at 18:5:11. The fleet will approach our system in tick 855 and appears to have roughly 95 ships.</td> for m in re.finditer( '<td class="left" valign="top">Incoming</td><td valign="top">(\d+)</td><td class="left" valign="top">We have detected an open jumpgate from ([^<]+), located at <a[^>]+>(\d+):(\d+):(\d+)</a>. The fleet will approach our system in tick (\d+) and appears to have (\d+) visible ships.</td>', page): fleetscan = FleetScan() newstick = m.group(1) fleetname = m.group(2) originx = m.group(3) originy = m.group(4) originz = m.group(5) arrivaltick = m.group(6) numships = m.group(7) fleetscan.mission = "Unknown" fleetscan.fleet_name = fleetname fleetscan.launch_tick = newstick fleetscan.landing_tick = int(arrivaltick) fleetscan.fleet_size = numships owner = PlanetHistory.load_planet( originx, originy, originz, newstick, closest=not Config.getboolean("Misc", "catchup")) if owner is None: continue fleetscan.owner = owner fleetscan.target = scan.planet fleetscan.in_cluster = fleetscan.owner.x == fleetscan.target.x fleetscan.in_galaxy = fleetscan.in_cluster and fleetscan.owner.y == fleetscan.target.y try: scan.fleets.append(fleetscan) session.commit() except Exception, e: session.rollback() scanlog("Exception in news: %s" % (str(e), ), traceback=True) continue scanlog('Incoming: ' + newstick + ':' + fleetname + '-' + originx + ':' + originy + ':' + originz + '-' + arrivaltick + '|' + numships)
def parse_N(self, scan_id, scan, page): #incoming fleets #<td class=left valign=top>Incoming</td><td valign=top>851</td><td class=left valign=top>We have detected an open jumpgate from Tertiary, located at 18:5:11. The fleet will approach our system in tick 855 and appears to have roughly 95 ships.</td> for m in re.finditer('<td class="left" valign="top">Incoming</td><td valign="top">(\d+)</td><td class="left" valign="top">We have detected an open jumpgate from ([^<]+), located at <a[^>]+>(\d+):(\d+):(\d+)</a>. The fleet will approach our system in tick (\d+) and appears to have (\d+) visible ships.</td>', page): fleetscan = FleetScan() newstick = m.group(1) fleetname = m.group(2) originx = m.group(3) originy = m.group(4) originz = m.group(5) arrivaltick = m.group(6) numships = m.group(7) fleetscan.mission = "Unknown" fleetscan.fleet_name = fleetname fleetscan.launch_tick = newstick fleetscan.landing_tick = int(arrivaltick) fleetscan.fleet_size = numships owner = PlanetHistory.load_planet(originx,originy,originz,newstick,closest=not Config.getboolean("Misc", "catchup")) if owner is None: continue fleetscan.owner = owner fleetscan.target = scan.planet fleetscan.in_cluster = fleetscan.owner.x == fleetscan.target.x fleetscan.in_galaxy = fleetscan.in_cluster and fleetscan.owner.y == fleetscan.target.y try: scan.fleets.append(fleetscan) session.commit() except Exception, e: session.rollback() scanlog("Exception in news: %s"%(str(e),), traceback=True) continue scanlog('Incoming: ' + newstick + ':' + fleetname + '-' + originx + ':' + originy + ':' + originz + '-' + arrivaltick + '|' + numships)
def parse_J(self, scan_id, scan, page): # <td class=left>Origin</td><td class=left>Mission</td><td>Fleet</td><td>ETA</td><td>Fleetsize</td> # <td class=left>13:10:5</td><td class=left>Attack</td><td>Gamma</td><td>5</td><td>265</td> # <td class="left">15:7:11 </td><td class="left">Defend </td><td>Ad infinitum</td><td>9</td><td>0</td> #<tr><td class="left">10:4:9</td><td class="left">Return</td><td>They look thirsty</td><td>5</td><td>3000</td></tr> # <tr><td class="left">4:1:10</td><td class="left">Return</td><td>Or Is It?</td><td>9</td><td>3000</td></tr> #<tr><td class="left">10:1:10</td><td class="left">Defend</td><td class="left">Pesticide IV</td><td class="right">1</td><td class="right">0</td></tr> for m in re.finditer( '<td[^>]*>(?:<a[^>]+>)?(\d+)\:(\d+)\:(\d+)(?:</a>)?[^/]*/[^/]*/td><td[^>]*>([^<]+)</td><td[^>]*>([^<]+)</td><td[^>]*>(\d+)</td><td[^>]*>(\d+(?:,\d{3})*)</td>', page): scanlog("%s:%s:%s %s %s %s %s" % m.groups()) fleetscan = FleetScan() originx = m.group(1) originy = m.group(2) originz = m.group(3) mission = m.group(4) fleet = m.group(5) eta = int(m.group(6)) fleetsize = m.group(7).replace(',', '') fleetscan.mission = mission fleetscan.fleet_name = fleet fleetscan.landing_tick = eta + scan.tick fleetscan.fleet_size = fleetsize attacker = PlanetHistory.load_planet(originx, originy, originz, scan.tick) if attacker is None: scanlog("Can't find attacker in db: %s:%s:%s tick: %s" % (originx, originy, originz, scan.tick)) continue fleetscan.owner = attacker fleetscan.target = scan.planet fleetscan.in_cluster = fleetscan.owner.x == fleetscan.target.x fleetscan.in_galaxy = fleetscan.in_cluster and fleetscan.owner.y == fleetscan.target.y try: scan.fleets.append(fleetscan) session.commit() except IntegrityError, e: session.rollback() scanlog("Caught integrity exception in jgp: %s" % (str(e), )) scanlog("Trying to update instead") query = session.query(FleetScan).filter_by( owner=attacker, target=scan.planet, fleet_size=fleetsize, fleet_name=fleet, landing_tick=eta + scan.tick, mission=mission) try: query.update({"scan_id": scan_id}) session.commit() except Exception, e: session.rollback() scanlog("Exception trying to update jgp: %s" % (str(e), ), traceback=True) continue
fleetscan.mission = "Attack" fleetscan.fleet_name = fleetname fleetscan.launch_tick = newstick fleetscan.landing_tick = arrivaltick target = PlanetHistory.load_planet( originx, originy, originz, newstick, closest=not Config.getboolean("Misc", "catchup")) if target is None: continue fleetscan.owner = scan.planet fleetscan.target = target fleetscan.in_cluster = fleetscan.owner.x == fleetscan.target.x fleetscan.in_galaxy = fleetscan.in_cluster and fleetscan.owner.y == fleetscan.target.y try: scan.fleets.append(fleetscan) session.commit() except Exception, e: session.rollback() scanlog("Exception in news: %s" % (str(e), ), traceback=True) continue scanlog('Attack:' + newstick + ':' + fleetname + ':' + originx + ':' + originy + ':' + originz + ':' + arrivaltick) #launched defending fleets
fleetname = m.group(2) originx = m.group(3) originy = m.group(4) originz = m.group(5) arrivaltick = m.group(6) fleetscan.mission = "Attack" fleetscan.fleet_name = fleetname fleetscan.launch_tick = newstick fleetscan.landing_tick = arrivaltick target=Planet.load(originx,originy,originz) if target is None: continue fleetscan.owner = scan.planet fleetscan.target = target try: scan.fleets.append(fleetscan) session.commit() except Exception, e: session.rollback() print "Exception in news: "+e.__str__() traceback.print_exc() continue print 'Attack:' + newstick + ':' + fleetname + ':' + originx + ':' + originy + ':' + originz + ':' + arrivaltick #launched defending fleets #<td class=left valign=top>Launch</td><td valign=top>847</td><td class=left valign=top>The Ship Collection fleet has been launched, heading for 2:9:14, on a mission to Defend. Arrival tick: 853</td> for m in re.finditer('<td class="left" valign="top">Launch</td><td valign="top">(\d+)</td><td class="left" valign="top">The ([^<]+) fleet has been launched, heading for (\d+):(\d+):(\d+), on a mission to Defend. Arrival tick: (\d+)</td>', page):
fleetname = m.group(2) originx = m.group(3) originy = m.group(4) originz = m.group(5) arrivaltick = m.group(6) fleetscan.mission = "Attack" fleetscan.fleet_name = fleetname fleetscan.launch_tick = newstick fleetscan.landing_tick = arrivaltick target = PlanetHistory.load_planet(originx,originy,originz,newstick,closest=not Config.getboolean("Misc", "catchup")) if target is None: continue fleetscan.owner = scan.planet fleetscan.target = target fleetscan.in_cluster = fleetscan.owner.x == fleetscan.target.x fleetscan.in_galaxy = fleetscan.in_cluster and fleetscan.owner.y == fleetscan.target.y try: scan.fleets.append(fleetscan) session.commit() except Exception, e: session.rollback() scanlog("Exception in news: %s"%(str(e),), traceback=True) continue scanlog('Attack:' + newstick + ':' + fleetname + ':' + originx + ':' + originy + ':' + originz + ':' + arrivaltick) #launched defending fleets #<td class=left valign=top>Launch</td><td valign=top>847</td><td class=left valign=top>The Ship Collection fleet has been launched, heading for 2:9:14, on a mission to Defend. Arrival tick: 853</td>
fleetname = m.group(2) originx = m.group(3) originy = m.group(4) originz = m.group(5) arrivaltick = m.group(6) fleetscan.mission = "Attack" fleetscan.fleet_name = fleetname fleetscan.launch_tick = newstick fleetscan.landing_tick = arrivaltick target = Planet.load(originx, originy, originz) if target is None: continue fleetscan.owner = scan.planet fleetscan.target = target fleetscan.in_cluster = fleetscan.owner.x == fleetscan.target.x fleetscan.in_galaxy = fleetscan.in_cluster and fleetscan.owner.y == fleetscan.target.y try: scan.fleets.append(fleetscan) session.commit() except Exception, e: session.rollback() scanlog("Exception in news: %s" % (str(e), ), traceback=True) continue scanlog('Attack:' + newstick + ':' + fleetname + ':' + originx + ':' + originy + ':' + originz + ':' + arrivaltick) #launched defending fleets