projects
/
theonering
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4354d30
)
Switching back to module level loggers
author
Ed Page
<eopage@byu.net>
Mon, 28 Sep 2009 22:59:10 +0000
(17:59 -0500)
committer
Ed Page
<eopage@byu.net>
Mon, 28 Sep 2009 22:59:10 +0000
(17:59 -0500)
src/browser_emu.py
patch
|
blob
|
history
src/channel_manager.py
patch
|
blob
|
history
src/connection.py
patch
|
blob
|
history
src/connection_manager.py
patch
|
blob
|
history
src/gtk_toolbox.py
patch
|
blob
|
history
src/gv_backend.py
patch
|
blob
|
history
src/handle.py
patch
|
blob
|
history
src/simple_presence.py
patch
|
blob
|
history
diff --git
a/src/browser_emu.py
b/src/browser_emu.py
index
88a0b62
..
32ffbca
100644
(file)
--- a/
src/browser_emu.py
+++ b/
src/browser_emu.py
@@
-32,6
+32,7
@@
import logging
import socket
import socket
+_moduleLogger = logging.getLogger("browser_emu")
socket.setdefaulttimeout(10)
socket.setdefaulttimeout(10)
@@
-100,7
+101,7
@@
class MozillaEmulator(object):
@return: The raw HTML page data
"""
@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 = {}
if extraheaders is None:
extraheaders = {}
@@
-113,9
+114,9
@@
class MozillaEmulator(object):
req, u = self.build_opener(url, postdata, extraheaders, forbid_redirect)
openerdirector = u.open(req)
if self.debug:
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
self.cookies.extract_cookies(openerdirector, req)
if only_head:
return openerdirector
@@
-127,8
+128,7
@@
class MozillaEmulator(object):
raise
# Retry :-)
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 = []
def _read(self, openerdirector, trycount):
chunks = []
diff --git
a/src/channel_manager.py
b/src/channel_manager.py
index
ad6faed
..
90fdd99
100644
(file)
--- a/
src/channel_manager.py
+++ b/
src/channel_manager.py
@@
-6,6
+6,9
@@
import telepathy
import channel
import channel
+_moduleLogger = logging.getLogger("channel_manager")
+
+
class ChannelManager(object):
def __init__(self, connection):
class ChannelManager(object):
def __init__(self, connection):
@@
-31,7
+34,7
@@
class ChannelManager(object):
elif handle.get_type() == telepathy.HANDLE_TYPE_CONTACT:
chan = channel.contact_list.creat_contact_list_channel(self._connRef(), handle)
else:
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
self._listChannels[handle] = chan
self._connRef().add_channel(chan, handle, suppress_handler)
return chan
@@
-40,7
+43,7
@@
class ChannelManager(object):
if handle in self._textChannels:
chan = self._textChannels[handle]
else:
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:
contact = handle.contact
if conversation is None:
@@
-55,7
+58,7
@@
class ChannelManager(object):
if handle in self._callChannels:
chan = self._callChannels[handle]
else:
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:
contact = handle.contact
if conversation is None:
diff --git
a/src/connection.py
b/src/connection.py
index
3fe60b1
..
304491d
100644
(file)
--- a/
src/connection.py
+++ b/
src/connection.py
@@
-10,6
+10,9
@@
import channel_manager
import simple_presence
import simple_presence
+_moduleLogger = logging.getLogger("connection")
+
+
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePresenceMixin):
MANDATORY_PARAMETERS = {
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePresenceMixin):
MANDATORY_PARAMETERS = {
@@
-45,9
+48,9
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
self.set_self_handle(handle.create_handle(self, 'connection'))
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:
except Exception, e:
- logging.exception("Failed to create Connection")
+ _moduleLogger.exception("Failed to create Connection")
raise
@property
raise
@property
@@
-98,9
+101,9
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
"""
try:
self._backend.logout()
"""
try:
self._backend.logout()
- logging.info("Disconnected")
+ _moduleLogger.info("Disconnected")
except Exception:
except Exception:
- logging.exception("Disconnecting Failed")
+ _moduleLogger.exception("Disconnecting Failed")
self.StatusChanged(
telepathy.CONNECTION_STATUS_DISCONNECTED,
telepathy.CONNECTION_STATUS_REASON_REQUESTED
self.StatusChanged(
telepathy.CONNECTION_STATUS_DISCONNECTED,
telepathy.CONNECTION_STATUS_REASON_REQUESTED
diff --git
a/src/connection_manager.py
b/src/connection_manager.py
index
68e9be6
..
9f9dd88
100644
(file)
--- a/
src/connection_manager.py
+++ b/
src/connection_manager.py
@@
-7,6
+7,9
@@
import constants
import connection
import connection
+_moduleLogger = logging.getLogger("connection_manager")
+
+
class TheOneRingConnectionManager(telepathy.server.ConnectionManager):
def __init__(self, shutdown_func=None):
class TheOneRingConnectionManager(telepathy.server.ConnectionManager):
def __init__(self, shutdown_func=None):
@@
-14,7
+17,7
@@
class TheOneRingConnectionManager(telepathy.server.ConnectionManager):
self._protos[constants._telepathy_protocol_name_] = connection.TheOneRingConnection
self._on_shutdown = shutdown_func
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):
"""
def GetParameters(self, proto):
"""
@@
-67,7
+70,7
@@
class TheOneRingConnectionManager(telepathy.server.ConnectionManager):
"""
for connection in self._connections:
connection.Disconnect()
"""
for connection in self._connections:
connection.Disconnect()
- logging.info("Connection manager quitting")
+ _moduleLogger.info("Connection manager quitting")
def _shutdown(self):
if (
def _shutdown(self):
if (
diff --git
a/src/gtk_toolbox.py
b/src/gtk_toolbox.py
index
da9accc
..
a74dea6
100644
(file)
--- a/
src/gtk_toolbox.py
+++ b/
src/gtk_toolbox.py
@@
-12,6
+12,9
@@
import threading
import Queue
import Queue
+_moduleLogger = logging.getLogger("gtk_toolbox")
+
+
@contextlib.contextmanager
def flock(path, timeout=-1):
WAIT_FOREVER = -1
@contextlib.contextmanager
def flock(path, timeout=-1):
WAIT_FOREVER = -1
@@
-137,7
+140,7
@@
def comap(function, target):
mappedItem = function(*item)
target.send(mappedItem)
except Exception, e:
mappedItem = function(*item)
target.send(mappedItem)
except Exception, e:
- logging.exception("Forwarding exception!")
+ _moduleLogger.exception("Forwarding exception!")
target.throw(e.__class__, str(e))
target.throw(e.__class__, str(e))
diff --git
a/src/gv_backend.py
b/src/gv_backend.py
index
9af81cf
..
4d6e19c
100644
(file)
--- a/
src/gv_backend.py
+++ b/
src/gv_backend.py
@@
-46,6
+46,7
@@
except ImportError:
simplejson = None
simplejson = None
+_moduleLogger = logging.getLogger("gv_backend")
_TRUE_REGEX = re.compile("true")
_FALSE_REGEX = re.compile("false")
_TRUE_REGEX = re.compile("true")
_FALSE_REGEX = re.compile("false")
@@
-97,10
+98,6
@@
def itergroup(iterator, count, padValue = None):
return itertools.izip(*nIterators)
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
class GVDialer(object):
"""
This class encapsulates all of the knowledge necessary to interact with the GoogleVoice servers
@@
-137,7
+134,7
@@
class GVDialer(object):
try:
self._grab_account_info()
except Exception, e:
try:
self._grab_account_info()
except Exception, e:
- logging.exception(str(e))
+ _moduleLogger.exception(str(e))
return False
self._browser.cookies.save()
return False
self._browser.cookies.save()
@@
-166,8
+163,8
@@
class GVDialer(object):
try:
loginSuccessOrFailurePage = self._browser.download(self._loginURL, loginPostData)
except urllib2.URLError, e:
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()
return self.is_authed()
@@
-197,8
+194,8
@@
class GVDialer(object):
}
callSuccessPage = self._browser.download(self._clicktocallURL, clickToCallData, None, otherData)
except urllib2.URLError, e:
}
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")
if self._gvDialingStrRe.search(callSuccessPage) is None:
raise RuntimeError("Google Voice returned an error")
@@
-222,8
+219,8
@@
class GVDialer(object):
}
smsSuccessPage = self._browser.download(self._sendSmsURL, smsData, None, otherData)
except urllib2.URLError, e:
}
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
return True
@@
-343,8
+340,8
@@
class GVDialer(object):
try:
contactsPage = self._browser.download(contactsPageUrl)
except urllib2.URLError, e:
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))
for contact_match in self._contactsRe.finditer(contactsPage):
contactId = contact_match.group(1)
contactName = saxutils.unescape(contact_match.group(2))
@@
-370,8
+367,8
@@
class GVDialer(object):
try:
detailPage = self._browser.download(self._contactDetailURL + '/' + contactId)
except urllib2.URLError, e:
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)
for detail_match in self._contactDetailPhoneRe.finditer(detailPage):
phoneNumber = detail_match.group(1)
@@
-385,8
+382,8
@@
class GVDialer(object):
try:
voicemailPage = self._browser.download(self._voicemailURL)
except urllib2.URLError, e:
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)
voicemailHtml = self._grab_html(voicemailPage)
parsedVoicemail = self._parse_voicemail(voicemailHtml)
decoratedVoicemails = self._decorate_voicemail(parsedVoicemail)
@@
-394,8
+391,8
@@
class GVDialer(object):
try:
smsPage = self._browser.download(self._smsURL)
except urllib2.URLError, e:
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)
smsHtml = self._grab_html(smsPage)
parsedSms = self._parse_sms(smsHtml)
decoratedSms = self._decorate_sms(parsedSms)
@@
-436,7
+433,7
@@
class GVDialer(object):
if anGroup is not None:
self._accountNum = anGroup.group(1)
else:
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):
self._callbackNumbers = {}
for match in self._callbackRe.finditer(page):
@@
-472,8
+469,8
@@
class GVDialer(object):
try:
flatXml = self._browser.download(url)
except urllib2.URLError, e:
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)
allRecentHtml = self._grab_html(flatXml)
allRecentData = self._parse_voicemail(allRecentHtml)
diff --git
a/src/handle.py
b/src/handle.py
index
69b782e
..
e2c7ae3
100644
(file)
--- a/
src/handle.py
+++ b/
src/handle.py
@@
-4,6
+4,9
@@
import weakref
import telepathy
import telepathy
+_moduleLogger = logging.getLogger("handle")
+
+
class MetaMemoize(type):
"""
Allows a class to cache off instances for reuse
class MetaMemoize(type):
"""
Allows a class to cache off instances for reuse
@@
-13,7
+16,7
@@
class MetaMemoize(type):
obj, newlyCreated = cls.__new__(cls, connection, *args)
if newlyCreated:
obj.__init__(connection, connection.get_handle_id(), *args)
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
return obj
diff --git
a/src/simple_presence.py
b/src/simple_presence.py
index
4219e84
..
b309e14
100644
(file)
--- a/
src/simple_presence.py
+++ b/
src/simple_presence.py
@@
-3,6
+3,9
@@
import logging
import telepathy
import telepathy
+_moduleLogger = logging.getLogger("simple_presence")
+
+
class TheOneRingPresence(object):
ONLINE = 'available'
BUSY = 'dnd'
class TheOneRingPresence(object):
ONLINE = 'available'
BUSY = 'dnd'
@@
-56,7
+59,7
@@
class SimplePresenceMixin(telepathy.server.ConnectionInterfaceSimplePresence):
self.gvoice_backend.mark_dnd(False)
else:
raise telepathy.errors.InvalidArgument
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):
def _get_statuses(self):