本文整理汇总了Python中munin.loadable.planet函数的典型用法代码示例。如果您正苦于以下问题:Python planet函数的具体用法?Python planet怎么用?Python planet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了planet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: parse_news
def parse_news(self, scan_id,page):
m = re.search('on (\d+)\:(\d+)\:(\d+) in tick (\d+)', page)
x = m.group(1)
y = m.group(2)
z = m.group(3)
tick = m.group(4)
p=loadable.planet(x, y, z)
if not p.load_most_recent(self.cursor): #really, this should never, ever fail.
return
#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):
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)
owner=loadable.planet(originx,originy,originz)
if not owner.load_most_recent(self.cursor):
continue
query="INSERT INTO fleet (scan_id,owner_id,target,fleet_size,fleet_name,launch_tick,landing_tick,mission) VALUES (%s,%s,%s,%s,%s,%s,%s,'unknown')"
try:
self.cursor.execute(query,(scan_id,owner.id,p.id,numships,fleetname,newstick,arrivaltick))
except Exception, e:
print "Exception in news: "+e.__str__()
traceback.print_exc()
continue
print 'Incoming: ' + newstick + ':' + fleetname + '-' + originx + ':' + originy + ':' + originz + '-' + arrivaltick + '|' + numships
开发者ID:kaaveland,项目名称:munin,代码行数:33,代码来源:scan.py
示例2: parse_jumpgate
def parse_jumpgate(self, scan_id,page):
m = re.search('on (\d+)\:(\d+)\:(\d+) in tick (\d+)', page)
x = m.group(1)
y = m.group(2)
z = m.group(3)
tick = m.group(4)
# <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>
p=loadable.planet(x, y, z)
if not p.load_most_recent(self.cursor): #really, this should never, ever fail, but exiles might bork it
return
# <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):
originx = m.group(1)
originy = m.group(2)
originz = m.group(3)
mission = m.group(4)
fleet = m.group(5)
eta = m.group(6)
fleetsize = m.group(7).replace(',', '')
print "JGP fleet "
attacker=loadable.planet(originx,originy,originz)
if not attacker.load_most_recent(self.cursor):
print "Can't find attacker in db: %s:%s:%s"%(originx,originy,originz)
continue
query="INSERT INTO fleet (scan_id,owner_id,target,fleet_size,fleet_name,landing_tick,mission) VALUES (%s,%s,%s,%s,%s,%s,%s)"
try:
self.cursor.execute(query,(scan_id,attacker.id,p.id,fleetsize,fleet,int(tick)+int(eta),mission.lower()))
except psycopg.IntegrityError, e:
print "Caught exception in jgp: "+e.__str__()
traceback.print_exc()
print "Trying to update instead"
query="UPDATE fleet SET scan_id=%s WHERE owner_id=%s AND target=%s AND fleet_size=%s AND fleet_name=%s AND landing_tick=%s AND mission=%s"
try:
self.cursor.execute(query,(scan_id,attacker.id,p.id,fleetsize,fleet,int(tick)+int(eta),mission.lower()))
except:
print "Exception trying to update jgp: "+e.__str__()
traceback.print_exc()
continue
except Exception, e:
print "Exception in jgp: "+e.__str__()
traceback.print_exc()
continue
开发者ID:kaaveland,项目名称:munin,代码行数:54,代码来源:scan.py
示例3: execute
def execute(self,user,access,irc_msg):
m=self.commandre.search(irc_msg.command)
if not m:
return 0
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
m=self.paramre.search(m.group(1))
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
u=self.load_user_with_planet(user,irc_msg)
if not u:
return 0
# assign param variables
x=m.group(1)
y=m.group(2)
z=m.group(3)
sum=m.group(5)
p=loadable.planet(x=x,y=y,z=z)
if not p.load_most_recent(self.cursor):
irc_msg.reply("No planet matching '%s:%s:%s' found"%(x,y,z))
return 1
res=u.planet.resources_per_agent(p)
reply="Your Seagals will ninja %s resources from %s:%s:%s - 13: %s, 35: %s."%(res,p.x,p.y,p.z,self.format_real_value(res*13),self.format_real_value(res*35))
if sum:
reply+=" You need %s Seagals to ninja %sk res."%(int(math.ceil((float(sum)*1000)/res)),sum)
irc_msg.reply(reply)
return 1
开发者ID:kaaveland,项目名称:munin,代码行数:34,代码来源:seagal.py
示例4: execute
def execute(self, user, access, irc_msg):
m = irc_msg.match_command(self.commandre)
if not m:
return 0
m = self.paramre.match(m.group(1))
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
planet = None
if m.lastindex == 3 and m.group(1) and m.group(2) and m.group(3):
planet = loadable.planet(x=m.group(1), y=m.group(2), z=m.group(3))
if not planet.load_most_recent(self.cursor, irc_msg.round):
irc_msg.reply("%s:%s:%s is not a valid planet" % (planet.x, planet.y, planet.z))
return 1
else:
u = loadable.user(pnick=irc_msg.user)
if not u.load_from_db(self.cursor, irc_msg.round):
irc_msg.reply(
"You must be registered to use the automatic " +
self.__class__.__name__ +
" command (log in with P and set mode +x, then make sure your planet is set with the pref command)")
return 1
if u.planet_id:
planet = u.planet
else:
irc_msg.reply("Usage: %s (make sure your planet is set with the pref command)" % (self.usage,))
return 1
if not planet:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
query = "SELECT score"
query += " FROM planet_dump"
query += " WHERE tick=(SELECT max_tick(%s::smallint)) AND round=%s"
query += " ORDER BY score_rank ASC"
query += " LIMIT 20"
self.cursor.execute(query, (irc_msg.round, irc_msg.round,))
if self.cursor.rowcount < 1:
irc_msg.reply("Error retrieving score of top 20 planets from database")
top20_average_score = reduce(lambda s, p: s + float(p['score']) / 20.0,
self.cursor.dictfetchall(),
0.0)
score_modifier = 0.5 * (1.0 - float(planet.score) / top20_average_score)
race_bonus = self.config.getfloat('Planetarion', planet.race + '_salvage_bonus')
salvage_rate = 0.3 * (1.0 + race_bonus) * (1.0 + score_modifier)
reply = "%s:%s:%s (%s|%s) gets a defense salvage rate of %2.1f%%" % (planet.x, planet.y, planet.z, self.format_value(
planet.value * 100), self.format_value(planet.score * 100), 100 * salvage_rate)
irc_msg.reply(reply)
return 1
开发者ID:munin,项目名称:munin,代码行数:58,代码来源:salvage.py
示例5: execute
def execute(self,user,access,irc_msg):
m=irc_msg.match_command(self.commandre)
if not m:
return 0
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
m=self.paramre.search(m.group(1))
if not m or not m.group(1):
u=loadable.user(pnick=irc_msg.user)
if not u.load_from_db(self.cursor):
irc_msg.reply("Usage: %s (you must be registered for automatic lookup)" % (self.usage,))
return 1
if u.planet:
reply=self.surprise(x=u.planet.x,y=u.planet.y,z=u.planet.z)
irc_msg.reply(reply)
else:
irc_msg.reply("Usage: %s (you must be registered for automatic lookup)" % (self.usage,))
return 0
# assign param variables
param=m.group(1)
m=self.coordre.search(param)
if m:
x=m.group(1)
y=m.group(2)
z=m.group(4)
if z:
p=loadable.planet(x=x,y=y,z=z)
if not p.load_most_recent(self.cursor):
irc_msg.reply("No planet matching '%s' found"%(param,))
return 1
reply=self.surprise(x=p.x,y=p.y,z=p.z)
irc_msg.reply(reply)
return 1
else:
g=loadable.galaxy(x=x,y=y)
if not g.load_most_recent(self.cursor):
irc_msg.reply("No galaxy matching '%s' found"%(param,))
return 1
reply=self.surprise(x=g.x,y=g.y)
irc_msg.reply(reply)
return 1
a=loadable.alliance(name=param.strip())
if not a.load_most_recent(self.cursor):
irc_msg.reply("No alliance matching '%s' found" % (param,))
return 1
reply=self.surprise(alliance=a.name)
irc_msg.reply(reply)
return 1
开发者ID:kaaveland,项目名称:munin,代码行数:57,代码来源:surprisesex.py
示例6: unsafe_method
def unsafe_method(self,message,nick,pnick,source):
message=message.replace("\x02","")
m=self.statusre.search(message)
if not m:
return
print m.groups()
target_x=m.group(1)
target_y=m.group(2)
target_z=m.group(3)
owner_x=m.group(4)
owner_y=m.group(5)
owner_z=m.group(6)
fleetname=m.group(7)
race=m.group(9)
fleetsize=m.group(10)
mission=m.group(11)
eta=m.group(12)
print "%s:%s:%s %s:%s:%s '%s' %s m:%s e:%s"%(owner_x,owner_y,owner_z,target_x,target_y,target_z,fleetname,fleetsize,mission,eta)
target=loadable.planet(target_x,target_y,target_z)
if not target.load_most_recent(self.cursor):
return
owner=loadable.planet(owner_x,owner_y,owner_z)
if not owner.load_most_recent(self.cursor):
return
self.cursor.execute("SELECT max_tick() AS max_tick")
curtick=self.cursor.dictfetchone()['max_tick']
landing_tick = int(eta) + int(curtick)
query="INSERT INTO fleet(owner_id,target,fleet_size,fleet_name,landing_tick,mission) VALUES (%s,%s,%s,%s,%s,%s)"
try:
self.cursor.execute(query,(owner.id,target.id,fleetsize,fleetname,landing_tick,mission.lower()))
except Exception,e:
print "Exception in galstatus: "+e.__str__()
traceback.print_exc()
开发者ID:kaaveland,项目名称:munin,代码行数:44,代码来源:galstatus.py
示例7: save_planet
def save_planet(self, irc_msg, u, x, y, z, round):
p = loadable.planet(x=x, y=y, z=z)
if not p.load_most_recent(self.cursor, round):
irc_msg.reply("%s:%s:%s is not a valid planet" % (x, y, z))
return 0
if u.pref:
query = "INSERT INTO round_user_pref (user_id,round,planet_id) VALUES (%s,%s,%s)"
query += " ON CONFLICT (user_id,round) DO"
query += " UPDATE SET planet_id=EXCLUDED.planet_id"
self.cursor.execute(query, (u.id, round, p.id,))
irc_msg.reply("Your planet has been saved as %s:%s:%s" % (x, y, z))
return p.id
开发者ID:munin,项目名称:munin,代码行数:13,代码来源:pref.py
示例8: execute
def execute(self, user, access, irc_msg):
m = irc_msg.match_command(self.commandre)
if not m:
return 0
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
planet = None
param = m.group(1)
m = self.paramre.search(param)
if not m or not m.group(1):
u = loadable.user(pnick=irc_msg.user)
if not u.load_from_db(self.cursor, irc_msg.round):
irc_msg.reply(
"You must be registered to use the automatic " +
self.__class__.__name__ +
" command (log in with P and set mode +x, then make sure you've set your planet with the pref command)")
#
return 1
if u.planet:
planet = u.planet
else:
irc_msg.reply("Usage: %s" % (self.usage,))
return 1
else:
m = self.coordre.search(param)
if m:
x = m.group(1)
y = m.group(2)
z = m.group(4)
# assign param variables
if z:
p = loadable.planet(x=x, y=y, z=z)
if not p.load_most_recent(self.cursor, irc_msg.round):
irc_msg.reply("No planet matching '%s' found" % (param,))
return 1
planet = p
else:
irc_msg.reply("Usage: %s (you must be registered for automatic lookup)" % (self.usage,))
return 1
if planet:
reply = "%s:%s:%s can hit planets with value %d or above or score %d or above" % (
planet.x, planet.y, planet.z, int(planet.value * .4), int(planet.score * .6))
irc_msg.reply(reply)
return 1
开发者ID:munin,项目名称:munin,代码行数:48,代码来源:basher.py
示例9: execute
def execute(self, user, access, irc_msg):
m = irc_msg.match_command(self.commandre)
if not m:
return 0
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
m = self.paramre.search(m.group(1))
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
# assign param variables
params = m.group(1)
m = self.planet_coordre.search(params)
reply = ""
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
x = m.group(1)
y = m.group(2)
z = m.group(3)
p = loadable.planet(x=x, y=y, z=z)
if not p.load_most_recent(self.cursor):
irc_msg.reply("No planet matching '%s:%s:%s' found" % (x, y, z))
return 1
query = "SELECT tick,nick,scantype,rand_id,tick"
query += " FROM scan AS t1"
query += " WHERE t1.pid=%s AND scantype='news' ORDER BY tick DESC LIMIT 10"
self.cursor.execute(query, (p.id,))
if self.cursor.rowcount > 0:
s = self.cursor.dictfetchall()
reply = "Latest news scans on %s:%s:%s - http://game.planetarion.com/showscan.pl?scan_id=%s" % (
x,
y,
z,
", ".join(map(lambda x: "%s (pt %s)" % (x["rand_id"], x["tick"]), s)),
)
else:
reply = "No news available on %s:%s:%s" % (x, y, z)
irc_msg.reply(reply)
return 1
开发者ID:kaaveland,项目名称:munin,代码行数:48,代码来源:news.py
示例10: save_planet
def save_planet(self, irc_msg, u, x, y, z):
p = loadable.planet(x=x, y=y, z=z)
if not p.load_most_recent(self.cursor):
irc_msg.reply("%s:%s:%s is not a valid planet" % (x, y, z))
return 0
if u.pref:
query = "UPDATE user_list SET planet_id=%s WHERE id=%s"
self.cursor.execute(query, (p.id, u.id))
irc_msg.reply("Your planet has been saved as %s:%s:%s" % (x, y, z))
return p.id
else:
raise Exception("This code /should/ be defunct now that prefs are in the user_list table")
query = "INSERT INTO user_pref (id,planet_id) VALUES (%s,%s)"
self.cursor.execute(query, (u.id, p.id))
irc_msg.reply("Your planet has been saved as %s:%s:%s" % (x, y, z))
开发者ID:kaaveland,项目名称:munin,代码行数:16,代码来源:pref.py
示例11: execute
def execute(self,user,access,irc_msg):
m=irc_msg.match_command(self.commandre)
if not m:
return 0
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
m=self.planet_coordre.search(m.group(1))
if m:
x=m.group(1)
y=m.group(2)
z=m.group(3)
p=loadable.planet(x=x,y=y,z=z)
if not p.load_most_recent(self.cursor):
irc_msg.reply("No planet matching '%s:%s:%s' found"%(x,y,z))
return 1
query="SELECT scantype,max(tick) AS latest,count(*) AS count FROM scan WHERE pid=%s GROUP BY scantype"
self.cursor.execute(query,(p.id,))
reply=""
if self.cursor.rowcount < 1:
reply+="No scans available on %s:%s:%s" % (p.x,p.y,p.z)
else:
reply+="scans for %s:%s:%s -" % (p.x,p.y,p.z)
prev=[]
for p in self.cursor.dictfetchall():
prev.append("(%d %s, latest pt%s)" % (p['count'],p['scantype'],p['latest']))
reply+=" "+string.join(prev,', ')
irc_msg.reply(reply)
else:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
return 1
开发者ID:kaaveland,项目名称:munin,代码行数:43,代码来源:scans.py
示例12: execute
def execute(self,user,access,irc_msg):
m=irc_msg.match_command(self.commandre)
if not m:
return 0
victim=None
params=m.group(1)
m=self.planet_coordre.search(params)
if m:
victim=loadable.planet(x=m.group(1),y=m.group(2),z=m.group(3))
if not victim.load_most_recent(self.cursor):
irc_msg.reply("%s:%s:%s is not a valid planet" % (victim.x,victim.y,victim.z))
return 1
total_roids=victim.size
else:
m=self.paramre.search(params)
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
total_roids=int(m.group(1))
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
reply=""
cap=0
cap_rate=.25
u=self.load_user_from_pnick(user)
if u and u.planet and victim:
cap_rate=u.planet.cap_rate(victim)
for i in range(1,5):
cap+=int(total_roids*cap_rate)
reply+="Wave %d: %d (%d), " % (i,int(total_roids*cap_rate),cap)
total_roids = total_roids - int(total_roids*cap_rate)
irc_msg.reply("Caprate: %s%% %s"%(int(cap_rate*100),reply.strip(', ')))
return 1
开发者ID:kaaveland,项目名称:munin,代码行数:38,代码来源:maxcap.py
示例13: surprise
def surprise(self, round, x=None, y=None, z=None, alliance=None):
args = (round, round,)
query = "SELECT t1.id AS attacker,count(t1.id) AS attacks "
query += " FROM planet_canon AS t1"
query += " INNER JOIN fleet AS t3 ON t1.id=t3.owner_id"
query += " INNER JOIN planet_dump AS t4 ON t4.id=t3.target"
query += " INNER JOIN intel AS t5 ON t3.target=t5.pid"
query += " INNER JOIN alliance_canon AS t6 ON t5.alliance_id=t6.id"
query += " WHERE mission = 'attack'"
query += " AND t4.tick=(SELECT max_tick(%s::smallint)) AND t4.round=%s"
if x and y:
query += " AND t4.x=%s AND t4.y=%s"
args += (x, y)
if z:
query += " AND t4.z=%s"
args += (z,)
if alliance:
query += " AND t6.name ilike %s"
args += ('%' + alliance + '%',)
query += " GROUP BY t1.id"
query += " ORDER BY count(t1.id) DESC"
self.cursor.execute(query, args)
attackers = self.cursor.dictfetchall()
if not len(attackers):
reply = "No fleets found targeting"
if x and y:
reply += " coords %s:%s" % (x, y)
if z:
reply += ":%s" % (z,)
if alliance:
reply += " alliance %s" % (alliance,)
else:
reply = "Top attackers on"
if x and y:
reply += " coords %s:%s" % (x, y)
if z:
reply += ":%s" % (z,)
if alliance:
reply += " alliance %s" % (alliance,)
reply += " are "
i = 0
prev = []
for a in attackers:
if i > 4:
break
else:
i += 1
p = loadable.planet(id=a['attacker'])
if not p.load_most_recent(self.cursor, round):
i -= 1
pass
prev.append("%s:%s:%s - %s" % (p.x, p.y, p.z, a['attacks']))
reply += ' | '.join(prev)
return reply
开发者ID:munin,项目名称:munin,代码行数:61,代码来源:topcunts.py
示例14: execute
def execute(self, user, access, irc_msg):
m = irc_msg.match_command(self.commandre)
if not m:
return 0
m = self.paramre.search(m.group(1))
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
# assign param variables
param = m.group(2)
if not param:
param = ""
if access < self.level:
if access >= 50:
self.hacky_stupid_half_member_status(irc_msg)
return 1
irc_msg.reply("You do not have enough access to use this command")
return 0
curtick = self.current_tick(irc_msg.round)
m = self.coordre.search(param)
if m:
x = m.group(1)
y = m.group(2)
z = m.group(4)
when = m.group(6)
if when:
when = int(when)
if when and when < 32:
tick = curtick + when
elif when and when < curtick:
irc_msg.reply(
"Can not check status on the past. You wanted tick %s, but current tick is %s. (If you really need to know, poke %s.)" %
(when,
curtick,
self.config.get(
'Auth',
'owner_nick')))
return 1
elif when:
tick = when
args = ()
query = "SELECT t1.id AS id, t1.nick AS nick, t1.pid AS pid, t1.tick AS tick, t1.uid AS uid, t2.pnick AS pnick, t2.userlevel AS userlevel, t3.x AS x, t3.y AS y, t3.z AS z"
query += " FROM target AS t1"
query += " INNER JOIN planet_dump AS t3 ON t1.pid=t3.id"
query += " LEFT JOIN user_list AS t2 ON t1.uid=t2.id"
query += " WHERE"
if when:
query += " t1.tick = %s AND t1.round = %s"
args += (tick, irc_msg.round)
else:
query += " t1.tick > (SELECT max_tick(%s::smallint)) AND t1.round = %s"
args += (irc_msg.round, irc_msg.round,)
query += " AND t3.tick = (SELECT max_tick(%s::smallint)) AND t3.round = %s AND t3.x=%s AND t3.y=%s"
args += (irc_msg.round, irc_msg.round,)
if z:
p = loadable.planet(x=x, y=y, z=z)
if not p.load_most_recent(self.cursor, irc_msg.round):
irc_msg.reply("No planet matching '%s:%s:%s' found" % (x, y, z))
return 1
query += " AND t3.z=%s"
query += " ORDER BY t1.tick ASC"
self.cursor.execute(query, args + (x, y, z))
if self.cursor.rowcount < 1:
reply = "No bookings matching planet %s:%s:%s" % (x, y, z)
if when:
reply += " for tick %s" % (tick,)
irc_msg.reply(reply)
return 1
reply = "Status for %s:%s:%s -" % (x, y, z)
if when:
res = self.cursor.dictfetchall()
type = "nick"
owner = res[0]['nick']
if res[0]['pnick']:
owner = res[0]['pnick']
type = "user"
reply += " booked for landing pt %s (eta %s) by %s %s" % (
res[0]['tick'], res[0]['tick'] - curtick, type, owner)
else:
prev = []
for r in self.cursor.dictfetchall():
owner = "nick:" + r['nick']
if r['pnick']:
owner = "user:" + r['pnick']
prev.append("(%s %s)" % (r['tick'], owner))
reply += " " + ', '.join(prev)
irc_msg.reply(reply)
else:
query += " ORDER BY y, z, x, tick"
self.cursor.execute(query, args + (x, y))
#.........这里部分代码省略.........
开发者ID:munin,项目名称:munin,代码行数:101,代码来源:status.py
示例15: execute
def execute(self,user,access,irc_msg):
m=irc_msg.match_command(self.commandre)
if not m:
return 0
m=self.paramre.search(m.group(1))
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
# assign param variables
when=None
x=m.group(1)
y=m.group(2)
z=m.group(3)
when=m.group(5)
if when: when=int(when)
override=m.group(7)
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
curtick=self.current_tick()
tick=-1
p=loadable.planet(x=x,y=y,z=z)
if not p.load_most_recent(self.cursor):
irc_msg.reply("No planet matching '%s:%s:%s' found"%(x,y,z))
return 1
u=loadable.user(pnick=irc_msg.user)
if not u.load_from_db(self.cursor):
u=None
if when and when < 32:
tick=curtick+when
elif when and when < curtick:
irc_msg.reply("Can not unbook targets in the past. You wanted tick %s, but current tick is %s."%(when,curtick))
return 1
elif when:
tick=when
if not override: # trying to unbook own target
query="DELETE FROM target WHERE pid = %s "
args=(p.id,)
if when:
query+=" AND tick = %s "
args+=(tick,)
else:
query+=" AND tick > %s "
args+=(curtick,)
if u:
#query+=" AND (uid ILIKE %s OR uid IS NULL)"
query+=" AND uid = %s"
args+=(u.id,)
else:
query+=" AND nick ILIKE %s"
args+=(irc_msg.nick,)
self.cursor.execute(query,args)
if self.cursor.rowcount == 0:
reply="You have no bookings matching %s:%s:%s" %(p.x,p.y,p.z)
if when:
reply+=" for landing on tick %s"%(tick,)
reply+=". If you are trying to unbook someone else's target, you must confirm with 'yes'."
else:
reply="You have unbooked %s:%s:%s"%(p.x,p.y,p.z)
if when:
reply+=" for landing pt %s"%(tick,)
else:
reply+=" for %d booking(s)"%(self.cursor.rowcount)
reply+="."
else:
query="SELECT t1.id AS id, t1.nick AS nick, t1.pid AS pid, t1.tick AS tick, t1.uid AS uid, t2.pnick AS pnick, t2.userlevel AS userlevel "
query+=" FROM target AS t1 LEFT JOIN user_list AS t2 ON t1.uid=t2.id "
query+=" WHERE t1.pid=%s "
args=(p.id,)
if when:
query+=" AND tick=%s"
args+=(tick,)
else:
query+=" AND tick > %s"
args+=(curtick,)
self.cursor.execute(query,args)
if self.cursor.rowcount < 1:
reply="No bookings matching %s:%s:%s" %(p.x,p.y,p.z)
if when:
reply+=" for landing on tick %s"%(tick,)
irc_msg.reply(reply)
return 1
res=self.cursor.dictfetchall()
query="DELETE FROM target WHERE pid = %s "
args=(p.id,)
if when:
query+=" AND tick = %s "
#.........这里部分代码省略.........
开发者ID:kaaveland,项目名称:munin,代码行数:101,代码来源:unbook.py
示例16: execute
def execute(self,user,access,irc_msg):
m=irc_msg.match_command(self.commandre)
if not m:
return 0
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
m=self.paramre.search(m.group(1))
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
# assign param variables
params=m.group(1)
m=self.planet_coordre.search(params)
reply=""
if m:
x=m.group(1)
y=m.group(2)
z=m.group(3)
p=loadable.planet(x=x,y=y,z=z)
if not p.load_most_recent(self.cursor):
irc_msg.reply("No planet matching '%s:%s:%s' found"%(x,y,z))
return 1
query="SELECT t1.tick,t1.nick,t1.scantype,t1.rand_id,t3.name,t2.amount"
query+=" FROM scan AS t1"
query+=" INNER JOIN unit AS t2 ON t1.id=t2.scan_id"
query+=" INNER JOIN ship AS t3 ON t2.ship_id=t3.id"
query+=" WHERE t1.pid=%s AND t1.id=(SELECT id FROM scan WHERE pid=t1.pid AND scantype='unit' ORDER BY tick DESC LIMIT 1)"
self.cursor.execute(query,(p.id,))
if self.cursor.rowcount < 1:
reply+="No unit scans available on %s:%s:%s" % (p.x,p.y,p.z)
else:
reply+="Newest unit scan on %s:%s:%s" % (p.x,p.y,p.z)
prev=[]
for s in self.cursor.dictfetchall():
prev.append("%s %s" % (s['name'],s['amount']))
tick=s['tick']
rand_id=s['rand_id']
reply+=" (id: %s, pt: %s) " % (rand_id,tick)
reply+=string.join(prev,' | ')
else:
m=self.idre.search(params)
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
rand_id=m.group(1)
query="SELECT x,y,z,t1.tick,t1.nick,t1.scantype,t1.rand_id,t3.name,t2.amount"
query+=" FROM scan AS t1"
query+=" INNER JOIN unit AS t2 ON t1.id=t2.scan_id"
query+=" INNER JOIN ship AS t3 ON t2.ship_id=t3.id"
query+=" INNER JOIN planet_dump AS t4 ON t1.pid=t4.id"
query+=" WHERE t4.tick=(SELECT max_tick()) AND t1.rand_id=%s"
self.cursor.execute(query,(rand_id,))
if self.cursor.rowcount < 1:
reply+="No planet scans matching ID %s" % (rand_id,)
else:
reply+="Newest unit scan on "
prev=[]
for s in self.cursor.dictfetchall():
prev.append("%s %s" % (s['name'],s['amount']))
tick=s['tick']
x=s['x']
y=s['y']
z=s['z']
reply+="%s:%s:%s (id: %s, pt: %s) " % (x,y,z,rand_id,tick)
reply+=string.join(prev,' | ')
irc_msg.reply(reply)
return 1
开发者ID:kaaveland,项目名称:munin,代码行数:83,代码来源:unit.py
示例17: execute
def execute(self, user, access, irc_msg):
m = irc_msg.match_command(self.commandre)
if not m:
return 0
if access < self.level:
irc_msg.reply("You do not have enough access to use this command")
return 0
m = self.paramre.search(m.group(1))
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
# assign param variables
params = m.group(1)
m = self.planet_coordre.search(params)
reply = ""
if m:
x = m.group(1)
y = m.group(2)
z = m.group(3)
p = loadable.planet(x=x, y=y, z=z)
if not p.load_most_recent(self.cursor, irc_msg.round):
irc_msg.reply("No planet matching '%s:%s:%s' found" % (x, y, z))
return 1
query = "SELECT t3.x,t3.y,t3.z,t1.tick AS tick,t1.nick,t1.scantype,t1.rand_id,t2.mission,t2.fleet_size,t2.fleet_name,t2.landing_tick-t1.tick AS eta"
query += " FROM scan AS t1"
query += " INNER JOIN fleet AS t2 ON t1.id=t2.scan_id"
query += " INNER JOIN planet_dump AS t3 ON t2.owner_id=t3.id"
query += " WHERE t1.pid=%s AND t3.tick=(SELECT max_tick(%s::smallint)) AND t3.round=%s"
query += " AND t1.id=(SELECT id FROM scan WHERE pid=t1.pid AND scantype='jgp'"
query += " ORDER BY tick DESC, id DESC LIMIT 1) ORDER BY eta ASC"
self.cursor.execute(query, (p.id, irc_msg.round, irc_msg.round,))
if self.cursor.rowcount < 1:
if self.fallback(irc_msg, p, None, irc_msg.round):
return 1
else:
reply += "No JGP scans available on %s:%s:%s" % (p.x, p.y, p.z)
else:
reply += "Newest JGP scan on %s:%s:%s" % (p.x, p.y, p.z)
prev = []
for s in self.cursor.dictfetchall():
prev.append(
"(%s:%s:%s %s | %s %s %s)" %
(s['x'],
s['y'],
s['z'],
s['fleet_name'],
s['fleet_size'],
s['mission'],
s['eta']))
tick = s['tick']
rand_id = s['rand_id']
reply += " (id: %s, pt: %s) " % (rand_id, tick)
reply += ' | '.join(prev)
if len(reply) > 450:
reply = " Newest JGP scan on %s:%s:%s (pt: %s) " % (x, y, z, tick)
reply += "http://game.planetarion.com/showscan.pl?scan_id=%s" % (rand_id,)
else:
m = self.idre.search(params)
if not m:
irc_msg.reply("Usage: %s" % (self.usage,))
return 0
rand_id = m.group(1)
query = "SELECT t4.x AS targ_x,t4.y AS targ_y,t4.z AS targ_z,t1.tick,t1.nick,t1.scantype,t1.rand_id,t2.mission,t2.fleet_size,t2.fleet_name,t2.landing_tick-t1.tick AS eta"
query += ",t5.x AS x,t5.y AS y,t5.z AS z"
query += " FROM scan AS t1"
query += " INNER JOIN fleet AS t2 ON t1.id=t2.scan_id"
query += " INNER JOIN planet_dump AS t4 ON t1.pid=t4.id"
query += " INNER JOIN planet_dump AS t5 ON t4.tick=t5.tick AND t2.owner_id=t5.id"
query += " WHERE t4.tick=(SELECT max_tick(%s::smallint)) AND t4.round=%s AND t1.rand_id=%s"
self.cursor.execute(query, (irc_msg.round, irc_msg.round, rand_id,))
if self.cursor.rowcount < 1:
if self.fallback(irc_msg, None, rand_id, irc_msg.round):
return 1
else:
reply += "No JGP scans matching ID %s" % (rand_id,)
else:
reply += "Newest JGP scan on "
prev = []
for s in self.cursor.dictfetchall():
prev.append(
"(%s:%s:%s %s | %s %s %s)" %
(s['x'],
s['y'],
s['z'],
s['fleet_name'],
s['fleet_size'],
#.........这里部分代码省略.........
开发者ID:munin,项目名称:munin,代码行数:101,代码来源:jgp.py
示例18: execute
def execute(self,user,access,irc_msg):
m=irc_msg.match_command(self.commandre)
if not m:
return 0
print acc
|
请发表评论