/usr/share/pyshared/gwibber/microblog/util/exceptions.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 | import os, subprocess
import xdg, time
import logging
logger = logging.getLogger("Exceptions")
import gettext
from gettext import lgettext as _
if hasattr(gettext, 'bind_textdomain_codeset'):
gettext.bind_textdomain_codeset('gwibber','UTF-8')
gettext.textdomain('gwibber')
class GwibberError(Exception):
"""Base class for exceptions in gwibber."""
pass
class GwibberServiceError(GwibberError):
"""Exception raised for errors from services.
Attributes:
service
username
message
kind
"""
def __init__(self, kind="UNKNOWN", service="UNKNOWN", username="UNKNOWN", message="UNKNOWN"):
if kind == "keyring" or kind == "auth":
logger.error("Failed to find credentials in the keyring")
accounts_error = os.path.join(xdg.BaseDirectory.xdg_cache_home, "gwibber", ".accounts_error")
if os.path.exists(accounts_error) and os.path.getmtime(accounts_error) > time.time()-600:
logger.info("gwibber-accounts was raised less than 600 seconds")
return
else:
open(accounts_error, 'w').close()
else:
logger.error("%s failure: %s:%s - %s", kind, service, username, message)
display_message = _("There was an %(kind)s failure from %(service)s for account %(account)s, error was %(error)s") % {
"kind": kind,
"service": service,
"account": username,
"error": message
}
title = _("Gwibber")
level = "info"
if kind == "auth":
display_message = _("Authentication error from %(service)s for account %(account)s") % {
"service": service,
"account": username
}
title = _("Gwibber Authentication Error")
level = "error"
if kind == "network":
display_message = _("There was a network error communicating with %(message)s") % { "message": message}
title = _("Gwibber Network Error")
level = "error"
if os.path.exists(os.path.join("bin", "gwibber-error")):
cmd = os.path.join("bin", "gwibber-error")
else:
cmd = "gwibber-error"
ret = subprocess.Popen([cmd, '-m', display_message, '-t', title, '-c', level, '-s', service, '-u', username, '-e', kind], shell=False)
|