/usr/share/pyshared/gwibber/lib/__init__.py is in gwibber-service 3.4.0-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | import dbus
from gwibber.microblog import util
class GwibberPublic:
"""
GwibberPublic is the public python class which provides convience methods
for using Gwibber.
"""
def __init__(self):
self.bus = dbus.SessionBus()
self.accounts = self.getbus("Accounts")
self.service = self.getbus("Service")
self.shortener = self.getbus("URLShorten")
def getbus(self, name):
obj = self.bus.get_object(
"com.Gwibber.%s" % name,
"/com/gwibber/%s" % name,
follow_name_owner_changes=True)
return dbus.Interface(obj, "com.Gwibber.%s" % name)
def post(self, message):
args = [message]
self.microblog.operation({
"args": args,
"opname": "send",
})
def GetServices(self):
"""
Returns a list of services available as json string
example:
import json, gwibber.lib
gw = gwibber.lib.GwibberPublic()
services = json.loads(gw.GetServices())
"""
return self.service.GetServices()
def GetAccounts(self):
"""
Returns a list of services available as json string
example:
import json, gwibber.lib
gw = gwibber.lib.GwibberPublic()
accounts = json.loads(gw.GetAccounts())
"""
return self.accounts.List()
def SendMessage(self, message):
"""
Posts a message/status update to all accounts with send_enabled = True. It
takes one argument, which is a message formated as a string.
example:
import gwibber.lib
gw = gwibber.lib.GwibberPublic()
gw.SendMessage("This is a message")
"""
return self.service.SendMessage(message)
def Refresh(self):
"""
Calls the Gwibber Service to trigger a refresh operation
example:
import gwibber.lib
gw = gwibber.lib.GwibberPublic()
gw.Refresh()
"""
return self.service.Refresh()
def Shorten(self, url):
"""
Takes a long url in and returns a shortened url as a string, based on your
configured shortening service
example:
import gwibber.lib
gw = gwibber.lib.GwibberPublic()
gw.Shorten(url)
"""
return self.shortener.Shorten(url)
def MonitorAccountCreated(self, cb):
self.accounts.connect_to_signal("AccountCreated", cb)
def MonitorAccountChanged(self, cb):
self.accounts.connect_to_signal("AccountChanged", cb)
def MonitorAccountDeleted(self, cb):
self.accounts.connect_to_signal("AccountDeleted", cb)
|