import socket
+_moduleLogger = logging.getLogger("browser_emu")
socket.setdefaulttimeout(10)
@return: The raw HTML page data
"""
- logging.warning("Performing download of %s" % url)
+ _moduleLogger.warning("Performing download of %s" % url)
if extraheaders is None:
extraheaders = {}
req, u = self.build_opener(url, postdata, extraheaders, forbid_redirect)
openerdirector = u.open(req)
if self.debug:
- print req.get_method(), url
- print openerdirector.code, openerdirector.msg
- print openerdirector.headers
+ _moduleLogger.info("%r - %r" % (req.get_method(), url))
+ _moduleLogger.info("%r - %r" % (openerdirector.code, openerdirector.msg))
+ _moduleLogger.info("%r" % (openerdirector.headers))
self.cookies.extract_cookies(openerdirector, req)
if only_head:
return openerdirector
raise
# Retry :-)
- if self.debug:
- print "MozillaEmulator: urllib2.URLError, retryting ", cnt
+ _moduleLogger.info("MozillaEmulator: urllib2.URLError, retryting %d" % cnt)
def _read(self, openerdirector, trycount):
chunks = []
import channel
+_moduleLogger = logging.getLogger("channel_manager")
+
+
class ChannelManager(object):
def __init__(self, connection):
elif handle.get_type() == telepathy.HANDLE_TYPE_CONTACT:
chan = channel.contact_list.creat_contact_list_channel(self._connRef(), handle)
else:
- logging.warn("Unknown channel type %r" % handle.get_type())
+ _moduleLogger.warn("Unknown channel type %r" % handle.get_type())
self._listChannels[handle] = chan
self._connRef().add_channel(chan, handle, suppress_handler)
return chan
if handle in self._textChannels:
chan = self._textChannels[handle]
else:
- logging.debug("Requesting new text channel")
+ _moduleLogger.debug("Requesting new text channel")
contact = handle.contact
if conversation is None:
if handle in self._callChannels:
chan = self._callChannels[handle]
else:
- logging.debug("Requesting new call channel")
+ _moduleLogger.debug("Requesting new call channel")
contact = handle.contact
if conversation is None:
import simple_presence
+_moduleLogger = logging.getLogger("connection")
+
+
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePresenceMixin):
MANDATORY_PARAMETERS = {
self.set_self_handle(handle.create_handle(self, 'connection'))
- logging.info("Connection to the account %s created" % account)
+ _moduleLogger.info("Connection to the account %s created" % account)
except Exception, e:
- logging.exception("Failed to create Connection")
+ _moduleLogger.exception("Failed to create Connection")
raise
@property
"""
try:
self._backend.logout()
- logging.info("Disconnected")
+ _moduleLogger.info("Disconnected")
except Exception:
- logging.exception("Disconnecting Failed")
+ _moduleLogger.exception("Disconnecting Failed")
self.StatusChanged(
telepathy.CONNECTION_STATUS_DISCONNECTED,
telepathy.CONNECTION_STATUS_REASON_REQUESTED
import connection
+_moduleLogger = logging.getLogger("connection_manager")
+
+
class TheOneRingConnectionManager(telepathy.server.ConnectionManager):
def __init__(self, shutdown_func=None):
self._protos[constants._telepathy_protocol_name_] = connection.TheOneRingConnection
self._on_shutdown = shutdown_func
- logging.info("Connection manager created")
+ _moduleLogger.info("Connection manager created")
def GetParameters(self, proto):
"""
"""
for connection in self._connections:
connection.Disconnect()
- logging.info("Connection manager quitting")
+ _moduleLogger.info("Connection manager quitting")
def _shutdown(self):
if (
import Queue
+_moduleLogger = logging.getLogger("gtk_toolbox")
+
+
@contextlib.contextmanager
def flock(path, timeout=-1):
WAIT_FOREVER = -1
mappedItem = function(*item)
target.send(mappedItem)
except Exception, e:
- logging.exception("Forwarding exception!")
+ _moduleLogger.exception("Forwarding exception!")
target.throw(e.__class__, str(e))
simplejson = None
+_moduleLogger = logging.getLogger("gv_backend")
_TRUE_REGEX = re.compile("true")
_FALSE_REGEX = re.compile("false")
return itertools.izip(*nIterators)
-class NetworkError(RuntimeError):
- pass
-
-
class GVDialer(object):
"""
This class encapsulates all of the knowledge necessary to interact with the GoogleVoice servers
try:
self._grab_account_info()
except Exception, e:
- logging.exception(str(e))
+ _moduleLogger.exception(str(e))
return False
self._browser.cookies.save()
try:
loginSuccessOrFailurePage = self._browser.download(self._loginURL, loginPostData)
except urllib2.URLError, e:
- logging.exception(str(e))
- raise NetworkError("%s is not accesible" % self._loginURL)
+ _moduleLogger.exception(str(e))
+ raise RuntimeError("%s is not accesible" % self._loginURL)
return self.is_authed()
}
callSuccessPage = self._browser.download(self._clicktocallURL, clickToCallData, None, otherData)
except urllib2.URLError, e:
- logging.exception(str(e))
- raise NetworkError("%s is not accesible" % self._clicktocallURL)
+ _moduleLogger.exception(str(e))
+ raise RuntimeError("%s is not accesible" % self._clicktocallURL)
if self._gvDialingStrRe.search(callSuccessPage) is None:
raise RuntimeError("Google Voice returned an error")
}
smsSuccessPage = self._browser.download(self._sendSmsURL, smsData, None, otherData)
except urllib2.URLError, e:
- logging.exception(str(e))
- raise NetworkError("%s is not accesible" % self._sendSmsURL)
+ _moduleLogger.exception(str(e))
+ raise RuntimeError("%s is not accesible" % self._sendSmsURL)
return True
try:
contactsPage = self._browser.download(contactsPageUrl)
except urllib2.URLError, e:
- logging.exception(str(e))
- raise NetworkError("%s is not accesible" % contactsPageUrl)
+ _moduleLogger.exception(str(e))
+ raise RuntimeError("%s is not accesible" % contactsPageUrl)
for contact_match in self._contactsRe.finditer(contactsPage):
contactId = contact_match.group(1)
contactName = saxutils.unescape(contact_match.group(2))
try:
detailPage = self._browser.download(self._contactDetailURL + '/' + contactId)
except urllib2.URLError, e:
- logging.exception(str(e))
- raise NetworkError("%s is not accesible" % self._contactDetailURL)
+ _moduleLogger.exception(str(e))
+ raise RuntimeError("%s is not accesible" % self._contactDetailURL)
for detail_match in self._contactDetailPhoneRe.finditer(detailPage):
phoneNumber = detail_match.group(1)
try:
voicemailPage = self._browser.download(self._voicemailURL)
except urllib2.URLError, e:
- logging.exception(str(e))
- raise NetworkError("%s is not accesible" % self._voicemailURL)
+ _moduleLogger.exception(str(e))
+ raise RuntimeError("%s is not accesible" % self._voicemailURL)
voicemailHtml = self._grab_html(voicemailPage)
parsedVoicemail = self._parse_voicemail(voicemailHtml)
decoratedVoicemails = self._decorate_voicemail(parsedVoicemail)
try:
smsPage = self._browser.download(self._smsURL)
except urllib2.URLError, e:
- logging.exception(str(e))
- raise NetworkError("%s is not accesible" % self._smsURL)
+ _moduleLogger.exception(str(e))
+ raise RuntimeError("%s is not accesible" % self._smsURL)
smsHtml = self._grab_html(smsPage)
parsedSms = self._parse_sms(smsHtml)
decoratedSms = self._decorate_sms(parsedSms)
if anGroup is not None:
self._accountNum = anGroup.group(1)
else:
- logging.debug("Could not extract account number from GoogleVoice")
+ _moduleLogger.debug("Could not extract account number from GoogleVoice")
self._callbackNumbers = {}
for match in self._callbackRe.finditer(page):
try:
flatXml = self._browser.download(url)
except urllib2.URLError, e:
- logging.exception(str(e))
- raise NetworkError("%s is not accesible" % url)
+ _moduleLogger.exception(str(e))
+ raise RuntimeError("%s is not accesible" % url)
allRecentHtml = self._grab_html(flatXml)
allRecentData = self._parse_voicemail(allRecentHtml)
import telepathy
+_moduleLogger = logging.getLogger("handle")
+
+
class MetaMemoize(type):
"""
Allows a class to cache off instances for reuse
obj, newlyCreated = cls.__new__(cls, connection, *args)
if newlyCreated:
obj.__init__(connection, connection.get_handle_id(), *args)
- logging.info("New Handle %r" % obj)
+ _moduleLogger.info("New Handle %r" % obj)
return obj
import telepathy
+_moduleLogger = logging.getLogger("simple_presence")
+
+
class TheOneRingPresence(object):
ONLINE = 'available'
BUSY = 'dnd'
self.gvoice_backend.mark_dnd(False)
else:
raise telepathy.errors.InvalidArgument
- logging.info("Setting Presence to '%s'" % status)
+ _moduleLogger.info("Setting Presence to '%s'" % status)
def _get_statuses(self):