-
Notifications
You must be signed in to change notification settings - Fork 6
/
example_dashboard.py
executable file
·38 lines (27 loc) · 1.24 KB
/
example_dashboard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# This example will authenticate as an app with your server,
# fetch the recent posts from you and people you follow,
# and print them to the screen.
from __future__ import division
import pprint, time
import tentapp
from colors import *
print yellow('-----------------------------------------------------------------------\\')
print
entityUrl = 'https://pythonclienttest.tent.is'
app = tentapp.TentApp(entityUrl)
app.authorizeFromCommandLine('keystore.js')
# Because we've authenticated, getPosts() will get not only our own public posts
# but also those of people we follow and posts that mention us.
# tent.is limits this to the last 50 posts or so unless additional parameters are present
posts = app.getPosts()
# # By default posts are sorted newest first.
# # If you wanted to sort oldest first:
# posts.sort(key = lambda p: p['published_at'])
for post in posts:
if post['type'] == 'https://tent.io/types/post/status/v0.1.0':
timestamp = time.asctime(time.localtime( post['published_at'] ))
print '%s %s'%(yellow(post['entity']), white(timestamp))
print ' %s'%cyan(post['content']['text'])
print
print yellow('-----------------------------------------------------------------------/')