Exemplo n.º 1
0
	def loadConfig(self):
		# Load the user information from the configuration file
		config = SafeConfigParser()
		configFileList = config.read('.me2day')

		# Create a new configuration file
		if len(configFileList) == 0:
			config.add_section("UserInfo")
			id = raw_input('\nInput your me2day ID? ')
			userKey = raw_input('Input your userKey? ')
			config.set('UserInfo', 'userID', id)
			config.set('UserInfo', 'userKey', userKey)
			f = open('.me2day', 'w')
			config.write(f)
			f.close()		
		else:
			try:
				id = config.get('UserInfo', 'userID')
				userKey = config.get('UserInfo', 'userKey')
			except NoSectionError:
				print 'No Section UserInfo' 
				print 'Check the configuration file'
				exit()

		r = me2dayAPI.init(id, userKey, 'xml')
		return id
Exemplo n.º 2
0
# -*- coding: utf-8 -*-
import me2dayAPI
import _mysql
import re
from xml.dom.minidom import *
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

r = me2dayAPI.init("", "", 'xml')


def decodingXML(xmlStr):
    dom = parseString(xmlStr)
    return dom.toxml('utf-8')


def gt(dom, name):
    try:
        return dom.getElementsByTagName(name)[0].childNodes[0].data
    except Exception:
        return ""


def query(sql):
    db = _mysql.connect("localhost", "root", "", "me2echelon")
    db.set_character_set('utf8')
    db.query(sql)
    r = db.store_result()
    if r:
        data = r.fetch_row()