コード例 #1
0
	def run(self, inputStr):
		cmd = inputStr.split(' ')		
		numOfParam = len(cmd) - 1
		
		res = me2dayResult('', 0)

		if cmd[0] == 'getFriends' or cmd[0] == 'gf':
			if numOfParam == 1:
				res = me2dayAPI.getFriends(cmd[1], 'all')
				r = self.decodingXML(res.body)
			elif numOfParam == 2:
				res = me2dayAPI.getFriends(cmd[1], cmd[2])
				r = self.decodingXML(res.body)
			else:
				r = 'Invalid Paramter'
			

		elif cmd[0] == 'createPost' or cmd[0] == 'cp':
			cmdList = re.findall('"[^"]*"', inputStr)
			if cmdList != None and len(cmdList) == 2:
				body = cmdList[0]
				body = body[1:len(body)-1]

				tags = cmdList[1]
				tags = tags[1:len(tags)-1]

				icon = 1 # default icon

				cmd[numOfParam].strip()
				if cmd[numOfParam].isdigit() == True: 
					icon = cmd[numOfParam]

				res = me2dayAPI.createPost(body, tags , icon)
				#r = decodingXML(res.body)
				dom = parseString(res.body)
				nodePermaLink = dom.getElementsByTagName('permalink')[0]
				self.lastCreatedPermLink = nodePermaLink.childNodes[0].data
				r = dom.toxml('utf-8')
			else:
				r = 'Invalid Parameters'
				
		elif cmd[0] == 'createComment' or cmd[0] == 'cc':
			if numOfParam >= 2:
				cmdList = re.findall('"[^"]*"', inputStr)
				if cmdList != None and len(cmdList) == 1:
					body = cmdList[0]
					body = body[1:len(body)-1]

					res = me2dayAPI.createComment(cmd[1], body)
					r = self.decodingXML(res.body)
			else:
				r = 'Invalid paramter'

		elif cmd[0] == 'getSettings' or cmd[0] == 'gs':
			if numOfParam == 0:
				res = me2dayAPI.getSettings()
				r = self.decodingXML(res.body)
			else:
				r = 'Invalid paramter'
		elif cmd[0] == 'getLatests' or cmd[0] == 'gl':
			if numOfParam == 1:
				res = me2dayAPI.getLatests(cmd[1])
				r = self.decodingXML(res.body)
			else:
				r = 'Invalid paramter'
				
		elif cmd[0] == 'getComments' or cmd[0] == 'gc':
			if numOfParam == 1:
				res = me2dayAPI.getComments(cmd[1])
				r = self.decodingXML(res.body)
			else:
				r = 'Invalid Parameter'
		elif cmd[0] == 'getPerson' or cmd[0] == 'gp':
			if numOfParam == 1:
				res = me2dayAPI.getPerson(cmd[1])
				r = self.decodingXML(res.body)
			else:
				r = 'Invalid Parameter'

		elif cmd[0] == 'noop':
			res = me2dayAPI.noop()
			r = self.decodingXML(res.body)
		elif cmd[0] == 'help' or cmd[0] == 'h':
			print 'me2day Commands:' 
			print 'createPost(cp)  createComment(cc)' 
			print 'getFriends(gf)  getLatests(gl) '
			print 'getPerson(gp)   getSettings(gs)'
			r = ''
		else:
			r = 'Invalid Command'

		print(r)
		
		return res.status
コード例 #2
0
    sql = sql.encode('utf-8')
    try:
        query(sql)
    except Exception:
        pass


def ut(name):
    sql = "UPDATE `me2echelon`.`crazysearch_user` SET `last` = NOW( ) WHERE `crazysearch_user`.`name` ='%s' LIMIT 1 ;" % name
    query(sql)


while 1:  #데몬은 죽지 않는다
    who = sw().rstrip()
    print who
    res = me2dayAPI.getFriends(who, "all")
    #	dom = decodingXML(res.body)
    dom = parseString(res.body)
    friends = dom.getElementsByTagName("person")
    #=re.findall("<id>(.*)</id>",r)
    for friend in friends:
        name = gt(friend, "id")
        nickname = gt(friend, "nickname")
        description = gt(friend, "description")
        img = gt(friend, "face")
        rank = gt(friend, "friendsCount")
        ip(name, nickname, description, img, rank)
#	faces=re.findall("<face>(.*)</face>",r)
#	print(faces[0])
#	break
    ut(who)