Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command line tools for status, webfinger, profile.
These help to reveal some bugs and other issues.
- Loading branch information
Showing
8 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
import httplib2 | ||
|
||
from ostatus.webfinger import finger | ||
|
||
PROFILE = "http://webfinger.net/rel/profile-page" | ||
|
||
HTTP = httplib2.Http() | ||
|
||
class ProfileError(Exception): | ||
pass | ||
|
||
def profile(identifier): | ||
links = finger(identifier) | ||
|
||
profile = None | ||
for link in links: | ||
if link['rel'] == PROFILE: | ||
profile = _get_data(link['href']) | ||
break | ||
|
||
if not profile: | ||
raise ProfileError('no links found to get profile') | ||
else: | ||
return profile | ||
|
||
def _get_data(uri): | ||
response, content = HTTP.request(uri) | ||
|
||
if response['status'] != '200': | ||
logging.debug(response, content) | ||
raise StatusError('bad status when fetching profile data: %s' % | ||
response['status']) | ||
else: | ||
return content | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
from ostatus.profile import profile | ||
|
||
def run(): | ||
args = sys.argv | ||
for arg in args[1:]: | ||
data = profile(arg) | ||
print data | ||
|
||
|
||
if __name__ == '__main__': | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
from ostatus.status import status | ||
|
||
def run(): | ||
args = sys.argv | ||
for arg in args[1:]: | ||
entry = status(arg) | ||
print entry['updated'] | ||
print '\t', entry['content'] | ||
|
||
|
||
if __name__ == '__main__': | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
|
||
from ostatus.webfinger import finger | ||
|
||
def run(): | ||
args = sys.argv | ||
for arg in args[1:]: | ||
links = finger(arg) | ||
for link in links: | ||
try: | ||
print link['rel'] | ||
print '\t%s' % link['href'] | ||
except KeyError: | ||
continue | ||
|
||
if __name__ == '__main__': | ||
run() |