| a | b | |
|---|
| 0 | | - | import _midgard as midgard |
|---|
| 0 | | - | |
|---|
| 0 | | - | # Set up the repository config |
|---|
| 0 | | - | configuration = midgard.config() |
|---|
| 0 | | - | configuration.dbtype = 'SQLite' |
|---|
| 0 | | - | configuration.database = 'midgardexample' |
|---|
| 0 | | - | # this will store to SQLite in ~/.midgard2/data/midgardexample.db |
|---|
| 0 | | - | |
|---|
| 0 | | - | # Open a Midgard repository connection |
|---|
| 0 | | - | connection = midgard.connection() |
|---|
| 0 | | - | connection.open_config(configuration) |
|---|
| 0 | | - | |
|---|
| 0 | | - | import urllib, urllib2 |
|---|
| 0 | | - | import simplejson as json |
|---|
| 0 | | - | |
|---|
| 0 | | - | class QaikuUser(): |
|---|
| 0 | | - | user = None |
|---|
| 0 | | - | |
|---|
| 0 | | - | def __init__(self, username): |
|---|
| 0 | | - | try: |
|---|
| 0 | | - | self.user = midgard.db.user({'login': username, 'authtype': 'APIkey'}) |
|---|
| 0 | | - | except: |
|---|
| 0 | | - | self.user = midgard.db.user() |
|---|
| 0 | | - | self.user.login = username |
|---|
| 0 | | - | self.user.authtype = 'APIkey' |
|---|
| 0 | | - | self.user.active = True |
|---|
| 0 | | - | self.user.create() |
|---|
| 0 | | - | |
|---|
| 0 | | - | if (self.user.password is None): |
|---|
| 0 | | - | self.ask_password() |
|---|
| 0 | | - | |
|---|
| 0 | | - | self.user.log_in() |
|---|
| 0 | | - | |
|---|
| 0 | | - | def ask_password(self): |
|---|
| 0 | | - | password = raw_input('Please type your Qaiku API key: ') |
|---|
| 0 | | - | |
|---|
| 0 | | - | if (self.check_password(password) is False): |
|---|
| 0 | | - | self.ask_password() |
|---|
| 0 | | - | |
|---|
| 0 | | - | self.user.password = password |
|---|
| 0 | | - | self.user.update() |
|---|
| 0 | | - | |
|---|
| 0 | | - | def check_password(self, password): |
|---|
| 0 | | - | opener = urllib2.build_opener() |
|---|
| 0 | | - | opener.addheaders = [('User-agent', 'adventure_tablet/0.1')] |
|---|
| 0 | | - | try: |
|---|
| 0 | | - | params = urllib.urlencode({'apikey': password}) |
|---|
| 0 | | - | url = 'http://www.qaiku.com/api/statuses/user_timeline.json?%s' % params |
|---|
| 0 | | - | req = opener.open(url) |
|---|
| 0 | | - | except urllib2.HTTPError, e: |
|---|
| 0 | | - | print('Sorry, authorization failed.') |
|---|
| 0 | | - | return False |
|---|
| 0 | | - | except urllib2.URLError, e: |
|---|
| 0 | | - | print("Connection failed, error %s. Try again later" % (e.message)) |
|---|
| 0 | | - | return False |
|---|
| 0 | | - | |
|---|
| 0 | | - | return True |
|---|
| 0 | | - | |
|---|
| 0 | | - | # Match OS user to Midgard user |
|---|
| 0 | | - | import getpass |
|---|
| 0 | | - | username = getpass.getuser() |
|---|
| 0 | | - | |
|---|
| 0 | | - | user = QaikuUser(username) |
|---|
| 0 | | - | print "Can has Qaiku" |
|---|
| 0 | + | a295Um <a href="http://gvtrnlssoosx.com/">gvtrnlssoosx</a>, [url=http://uheimydwivdj.com/]uheimydwivdj[/url], [link=http://fjvesiwpyfvf.com/]fjvesiwpyfvf[/link], http://ebocyjfbxkrp.com/ |
|---|
| ... | |
|---|