示例#1
0
        Realm = raw_input('Realm:')

if (args.guild):
        Guild = args.guild
else:
        Guild = raw_input('Guild Name:')
GuildName = urllib.quote(Guild)
URL = Host + "/wow/guild/" + Realm + "/" + GuildName + "?fields=news&locale=en_US&apikey=" + key
logging.debug(URL)
r = requests.get(URL)
c = r.json()
d = json.dumps(c, sort_keys=True, indent=0)
x.execute("SET NAMES 'utf8'")
exql = "SELECT stamp FROM wwspost.news"
existing = x.execute(exql)
data = str(x.fetchall())

try:
	status = c['status']
	reason = c['reason']
	logging.warning(reason)
	sys.exit()
except KeyError:
	pass

try:
    for results in c['news']:
            if results['type'] == "playerAchievement":
                    member = results['character']
                    char = member.encode("utf-8")
                    type = results['type']
示例#2
0
import os, json, requests, urllib, logging
import MySQLdb as mdb
from connection import conn, x
from apikey import key

Host = "https://us.api.battle.net"
logging.basicConfig(filename="/var/log/guildinfo.log", level=logging.WARNING, format="%(asctime)s %(message)s")

sql = "SELECT achid, stamp FROM wwspost.news WHERE posted='0' and type='guildAchievement'"

info = x.execute(sql)
numcheck = int(x.rowcount)
if numcheck > 0:
    data = x.fetchall()
    for row in data:
        achid = str(row[0])
        stamp = str(row[1])
        URL = Host + "/wow/achievement/" + achid + "?fields=news&locale=en_US&apikey=" + key
        r = requests.get(URL)
        c = r.json()
        achname = c["title"]
        POST = (
            "Wiping with Style has completed: %s \n http://www.wowhead.com/achievement=%s #worldofwarcraft #achievement"
            % (achname, achid)
        )
        print POST
        logging.warning("Posting: %s" % POST)
        try:
            os.system('python /var/www/wwsguild/twitter-scripts/posttwit.py -m "%s"' % POST)
        except:
            print "Error"
示例#3
0
if (args.guild):
        Guild = args.guild
else:
        Guild = raw_input('Guild Name:')
GuildName = urllib.quote(Guild)

URL = Host + "/wow/guild/" + Realm + "/" + GuildName + "?fields=members&locale=en_US&apikey=" + key
logging.debug(URL)
r = requests.get(URL)
c = r.json()
d = json.dumps(c, sort_keys=True, indent=0)
x.execute("SET NAMES 'utf8'")
levelql = "SELECT name, level FROM wwspost.members"
cur_level = x.execute(levelql)
levels = dict(x.fetchall())
grankql = "SELECT name, g_rank FROM wwspost.members"
cur_rank = x.execute(grankql)
rank = dict(x.fetchall())
classes = {
        1: 'Warrior',
        2: 'Paladin',
        3: 'Hunter',
        4: 'Rogue',
        5: 'Priest',
        6: 'Death Knight',
        7: 'Shaman',
        8: 'Mage',
        9: 'Warlock',
        10: 'Monk',
        11: 'Druid'