From 3611f431b93e4bed0bfb8d360dc19cb2aa52778b Mon Sep 17 00:00:00 2001 From: "Kuldeep Joshi (OpenERP)" Date: Thu, 14 Jun 2012 11:34:50 +0530 Subject: [IMP]document: remove warning bzr revid: kjo@tinyerp.com-20120614060450-w8771020su128gmg --- addons/document_webdav/webdav_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/document_webdav') diff --git a/addons/document_webdav/webdav_view.xml b/addons/document_webdav/webdav_view.xml index b0101c01574..a5935f42af4 100644 --- a/addons/document_webdav/webdav_view.xml +++ b/addons/document_webdav/webdav_view.xml @@ -77,7 +77,7 @@ form - + - + -- cgit v1.2.3 From 0c374a66bc3de5cdf48eb66b2078c0946aa045db Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 22 Jun 2012 12:18:39 +0530 Subject: [IMP] Add logging at the top of python files bzr revid: fka@tinyerp.com-20120622064839-llitm8szgikxznwr --- addons/document_webdav/redirect.py | 6 ++--- addons/document_webdav/test_davclient.py | 46 ++++++++++++++++---------------- addons/document_webdav/webdav_server.py | 20 +++++++++----- 3 files changed, 39 insertions(+), 33 deletions(-) (limited to 'addons/document_webdav') diff --git a/addons/document_webdav/redirect.py b/addons/document_webdav/redirect.py index 7bc0883f9e8..31f462bcbbe 100644 --- a/addons/document_webdav/redirect.py +++ b/addons/document_webdav/redirect.py @@ -24,9 +24,9 @@ import logging import urlparse from service.websrv_lib import FixSendError, HTTPHandler, HttpOptions from service.http_server import HttpLogHandler - +_logger = logging.getLogger(__name__) class RedirectHTTPHandler(HttpLogHandler, FixSendError, HttpOptions, HTTPHandler): - _logger = logging.getLogger('httpd.well-known') + _HTTP_OPTIONS = { 'Allow': ['OPTIONS', 'GET', 'HEAD', 'PROPFIND'] } redirect_paths = {} @@ -80,7 +80,7 @@ class RedirectHTTPHandler(HttpLogHandler, FixSendError, HttpOptions, HTTPHandler self.send_header("Content-Length", 0) self.end_headers() # Do we need a Cache-content: header here? - self._logger.debug("redirecting %s to %s", self.path, redir_path) + _logger.debug("redirecting %s to %s", self.path, redir_path) return None def do_PROPFIND(self): diff --git a/addons/document_webdav/test_davclient.py b/addons/document_webdav/test_davclient.py index 3c20cfed5b8..a62515de14e 100755 --- a/addons/document_webdav/test_davclient.py +++ b/addons/document_webdav/test_davclient.py @@ -43,7 +43,7 @@ from xmlrpclib import Transport, ProtocolError import StringIO import base64 -log = logging.getLogger('http-client') +_log = logging.getLogger(__name__) class HTTP11(httplib.HTTP): _http_vsn = 11 @@ -62,7 +62,7 @@ class PersistentTransport(Transport): if not self._http.has_key(host): host, extra_headers, x509 = self.get_host_info(host) self._http[host] = HTTP11(host) - log.debug("New connection to %s", host) + _log.debug("New connection to %s", host) return self._http[host] def get_host_info(self, host): @@ -170,7 +170,7 @@ class SafePersistentTransport(PersistentTransport): if not self._http.has_key(host): host, extra_headers, x509 = self.get_host_info(host) self._http[host] = httplib.HTTPS(host, None, **(x509 or {})) - log.debug("New connection to %s", host) + _log.debug("New connection to %s", host) return self._http[host] class AuthClient(object): @@ -191,8 +191,8 @@ class BasicAuthClient(AuthClient): return super(BasicAuthClient,self).getAuth(atype, realm) if not self._realm_dict.has_key(realm): - log.debug("realm dict: %r", self._realm_dict) - log.debug("missing key: \"%s\"" % realm) + _log.debug("realm dict: %r", self._realm_dict) + _log.debug("missing key: \"%s\"" % realm) self.resolveFailedRealm(realm) return 'Basic '+ self._realm_dict[realm] @@ -239,7 +239,7 @@ class addAuthTransport: # This line will bork if self.setAuthClient has not # been issued. That is a programming error, fix your code! auths = self._auth_client.getAuth(atype, realm) - log.debug("sending authorization: %s", auths) + _log.debug("sending authorization: %s", auths) h.putheader('Authorization', auths) self.send_content(h, request_body) @@ -255,8 +255,8 @@ class addAuthTransport: log.warning("Why have data on a 401 auth. message?") if realm.startswith('realm="') and realm.endswith('"'): realm = realm[7:-1] - log.debug("Resp: %r %r", resp.version,resp.isclosed(), resp.will_close) - log.debug("Want to do auth %s for realm %s", atype, realm) + _log.debug("Resp: %r %r", resp.version,resp.isclosed(), resp.will_close) + _log.debug("Want to do auth %s for realm %s", atype, realm) if atype != 'Basic': raise ProtocolError(host+handler, 403, "Unknown authentication method: %s" % atype, resp.msg) @@ -315,7 +315,7 @@ class HTTPSConnection(httplib.HTTPSConnection): lf = (len(ssl.PEM_FOOTER)+1) if cert[0-lf] != '\n': cert = cert[:0-lf]+'\n'+cert[0-lf:] - log.debug("len-footer: %s cert: %r", lf, cert[0-lf]) + _log.debug("len-footer: %s cert: %r", lf, cert[0-lf]) return cert @@ -390,7 +390,7 @@ class DAVClient(object): import base64 dbg = self.dbg hdrs.update(self.hdrs) - log.debug("Getting %s http://%s:%d/%s", method, self.host, self.port, path) + _log.debug("Getting %s http://%s:%d/%s", method, self.host, self.port, path) conn = httplib.HTTPConnection(self.host, port=self.port, timeout=self.timeout) conn.set_debuglevel(dbg) if not path: @@ -409,8 +409,8 @@ class DAVClient(object): data1 = r1.read() if not self.user: raise Exception('Must auth, have no user/pass!') - log.debug("Ver: %s, closed: %s, will close: %s", r1.version,r1.isclosed(), r1.will_close) - log.debug("Want to do auth %s for realm %s", atype, realm) + _log.debug("Ver: %s, closed: %s, will close: %s", r1.version,r1.isclosed(), r1.will_close) + _log.debug("Want to do auth %s for realm %s", atype, realm) if atype == 'Basic' : auths = base64.encodestring(self.user + ':' + self.passwd) if auths[-1] == "\n": @@ -422,22 +422,22 @@ class DAVClient(object): else: raise Exception("Unknown auth type %s" %atype) else: - log.warning("Got 401, cannot auth") + _log.warning("Got 401, cannot auth") raise Exception('No auth') - log.debug("Reponse: %s %s",r1.status, r1.reason) + _log.debug("Reponse: %s %s",r1.status, r1.reason) data1 = r1.read() if method != 'GET': - log.debug("Body:\n%s\nEnd of body", data1) + _log.debug("Body:\n%s\nEnd of body", data1) try: ctype = r1.msg.getheader('content-type') if ctype and ';' in ctype: ctype, encoding = ctype.split(';',1) if ctype == 'text/xml': doc = xml.dom.minidom.parseString(data1) - log.debug("XML Body:\n %s", doc.toprettyxml(indent="\t")) + _log.debug("XML Body:\n %s", doc.toprettyxml(indent="\t")) except Exception: - log.warning("could not print xml", exc_info=True) + _log.warning("could not print xml", exc_info=True) pass conn.close() return r1.status, r1.msg, data1 @@ -474,7 +474,7 @@ class DAVClient(object): s, m, d = self._http_request(path, method='OPTIONS', hdrs=hdrs) assert s == 200, "Status: %r" % s assert 'OPTIONS' in m.getheader('Allow') - log.debug('Options: %r', m.getheader('Allow')) + _log.debug('Options: %r', m.getheader('Allow')) if expect: self._assert_headers(expect, m) @@ -493,10 +493,10 @@ class DAVClient(object): for cnod in node.childNodes: if cnod.nodeType != node.ELEMENT_NODE: if strict: - log.debug("Found %r inside <%s>", cnod, node.tagName) + _log.debug("Found %r inside <%s>", cnod, node.tagName) continue if namespaces and (cnod.namespaceURI not in namespaces): - log.debug("Ignoring <%s> in <%s>", cnod.tagName, node.localName) + _log.debug("Ignoring <%s> in <%s>", cnod.tagName, node.localName) continue yield cnod @@ -533,10 +533,10 @@ class DAVClient(object): assert htver == 'HTTP/1.1' rstatus = int(sta) else: - log.debug("What is <%s> inside a ?", pno.tagName) + _log.debug("What is <%s> inside a ?", pno.tagName) else: - log.debug("Unknown node: %s", cno.tagName) + _log.debug("Unknown node: %s", cno.tagName) res.setdefault(href,[]).append((status, res_nss)) @@ -637,7 +637,7 @@ class DAVClient(object): if lsp[1] in davprops: lsline[lsp[0]] = lsp[2] else: - log.debug("Strange status: %s", st) + _log.debug("Strange status: %s", st) res.append(lsline) diff --git a/addons/document_webdav/webdav_server.py b/addons/document_webdav/webdav_server.py index ae75d0b80fc..4cb3233cf69 100644 --- a/addons/document_webdav/webdav_server.py +++ b/addons/document_webdav/webdav_server.py @@ -55,6 +55,9 @@ from DAV.propfind import PROPFIND from xml.dom import minidom from redirect import RedirectHTTPHandler +_logger_DAV = logging.getLogger(__name__) +_logger = logging.getLogger(__name__) +_log_web = logging.getLogger(__name__) khtml_re = re.compile(r' KHTML/([0-9\.]+) ') def OpenDAVConfig(**kw): @@ -73,7 +76,7 @@ def OpenDAVConfig(**kw): class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler): verbose = False - _logger = logging.getLogger('webdav') + protocol_version = 'HTTP/1.1' _HTTP_OPTIONS= { 'DAV' : ['1', '2'], 'Allow' : [ 'GET', 'HEAD', 'COPY', 'MOVE', 'POST', 'PUT', @@ -127,10 +130,10 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler): return self.davpath def log_message(self, format, *args): - self._logger.debug(format % args) + _logger.debug(format % args) def log_error(self, format, *args): - self._logger.warning(format % args) + _logger.warning(format % args) def _prep_OPTIONS(self, opts): ret = opts @@ -477,7 +480,7 @@ class dummy_dav_interface(object): uri2 = uri.split('/') if len(uri2) < 3: return True - logging.getLogger('webdav').debug("Requested uri: %s", uri) + _logger_DAV.debug("Requested uri: %s", uri) return None # no def is_collection(self, uri): @@ -487,6 +490,7 @@ class dummy_dav_interface(object): class DAVStaticHandler(http_server.StaticHTTPHandler): """ A variant of the Static handler, which will serve dummy DAV requests """ + verbose = False protocol_version = 'HTTP/1.1' _HTTP_OPTIONS= { 'DAV' : ['1', '2'], @@ -573,7 +577,7 @@ try: conf = OpenDAVConfig(**_dc) handler._config = conf reg_http_service(directory, DAVHandler, DAVAuthProvider) - logging.getLogger('webdav').info("WebDAV service registered at path: %s/ "% directory) + _logger_DAV.info("WebDAV service registered at path: %s/ "% directory) if not (config.get_misc('webdav', 'no_root_hack', False)): # Now, replace the static http handler with the dav-enabled one. @@ -595,7 +599,7 @@ try: reg_http_service('/', DAVStaticHandler) except Exception, e: - logging.getLogger('webdav').error('Cannot launch webdav: %s' % e) + _logger_DAV.error('Cannot launch webdav: %s' % e) def init_well_known(): @@ -616,6 +620,8 @@ def init_well_known(): init_well_known() class PrincipalsRedirect(RedirectHTTPHandler): + + redirect_paths = {} def _find_redirect(self): @@ -639,7 +645,7 @@ def init_principals_redirect(): if dbname: PrincipalsRedirect.redirect_paths[''] = '/webdav/%s/principals' % dbname reg_http_service('/principals', PrincipalsRedirect) - logging.getLogger("web-services").info( + _log_web.info( "Registered HTTP redirect handler for /principals to the %s db.", dbname) -- cgit v1.2.3 From 87decf703a549d4f81d5742898066277d584c787 Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Fri, 22 Jun 2012 12:55:45 +0530 Subject: [IMP] Add logging at the top of python files bzr revid: fka@tinyerp.com-20120622072545-uuok6zj2jm2koxw4 --- addons/document_webdav/webdav_server.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'addons/document_webdav') diff --git a/addons/document_webdav/webdav_server.py b/addons/document_webdav/webdav_server.py index 4cb3233cf69..65ebb49ff5f 100644 --- a/addons/document_webdav/webdav_server.py +++ b/addons/document_webdav/webdav_server.py @@ -54,10 +54,7 @@ from DAV.propfind import PROPFIND # from DAV.constants import DAV_VERSION_1, DAV_VERSION_2 from xml.dom import minidom from redirect import RedirectHTTPHandler - -_logger_DAV = logging.getLogger(__name__) _logger = logging.getLogger(__name__) -_log_web = logging.getLogger(__name__) khtml_re = re.compile(r' KHTML/([0-9\.]+) ') def OpenDAVConfig(**kw): @@ -480,7 +477,7 @@ class dummy_dav_interface(object): uri2 = uri.split('/') if len(uri2) < 3: return True - _logger_DAV.debug("Requested uri: %s", uri) + _logger.debug("Requested uri: %s", uri) return None # no def is_collection(self, uri): @@ -577,7 +574,7 @@ try: conf = OpenDAVConfig(**_dc) handler._config = conf reg_http_service(directory, DAVHandler, DAVAuthProvider) - _logger_DAV.info("WebDAV service registered at path: %s/ "% directory) + _logger.info("WebDAV service registered at path: %s/ "% directory) if not (config.get_misc('webdav', 'no_root_hack', False)): # Now, replace the static http handler with the dav-enabled one. @@ -599,7 +596,7 @@ try: reg_http_service('/', DAVStaticHandler) except Exception, e: - _logger_DAV.error('Cannot launch webdav: %s' % e) + _logger.error('Cannot launch webdav: %s' % e) def init_well_known(): @@ -645,7 +642,7 @@ def init_principals_redirect(): if dbname: PrincipalsRedirect.redirect_paths[''] = '/webdav/%s/principals' % dbname reg_http_service('/principals', PrincipalsRedirect) - _log_web.info( + _logger.info( "Registered HTTP redirect handler for /principals to the %s db.", dbname) -- cgit v1.2.3 From 06391b79366765df2845c5e1f67adf566b50349a Mon Sep 17 00:00:00 2001 From: "Foram Katharotiya (OpenERP)" Date: Mon, 25 Jun 2012 14:36:19 +0530 Subject: [IMP] add logger instead of_loggerdoc or _log., Add .warning() instead of .debug() in account bzr revid: fka@tinyerp.com-20120625090619-r25n9pqs89oh5180 --- addons/document_webdav/test_davclient.py | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'addons/document_webdav') diff --git a/addons/document_webdav/test_davclient.py b/addons/document_webdav/test_davclient.py index a62515de14e..a4dda231bd8 100755 --- a/addons/document_webdav/test_davclient.py +++ b/addons/document_webdav/test_davclient.py @@ -43,7 +43,7 @@ from xmlrpclib import Transport, ProtocolError import StringIO import base64 -_log = logging.getLogger(__name__) +_logger = logging.getLogger(__name__) class HTTP11(httplib.HTTP): _http_vsn = 11 @@ -62,7 +62,7 @@ class PersistentTransport(Transport): if not self._http.has_key(host): host, extra_headers, x509 = self.get_host_info(host) self._http[host] = HTTP11(host) - _log.debug("New connection to %s", host) + _logger.debug("New connection to %s", host) return self._http[host] def get_host_info(self, host): @@ -170,7 +170,7 @@ class SafePersistentTransport(PersistentTransport): if not self._http.has_key(host): host, extra_headers, x509 = self.get_host_info(host) self._http[host] = httplib.HTTPS(host, None, **(x509 or {})) - _log.debug("New connection to %s", host) + _logger.debug("New connection to %s", host) return self._http[host] class AuthClient(object): @@ -191,8 +191,8 @@ class BasicAuthClient(AuthClient): return super(BasicAuthClient,self).getAuth(atype, realm) if not self._realm_dict.has_key(realm): - _log.debug("realm dict: %r", self._realm_dict) - _log.debug("missing key: \"%s\"" % realm) + _logger.debug("realm dict: %r", self._realm_dict) + _logger.debug("missing key: \"%s\"" % realm) self.resolveFailedRealm(realm) return 'Basic '+ self._realm_dict[realm] @@ -239,7 +239,7 @@ class addAuthTransport: # This line will bork if self.setAuthClient has not # been issued. That is a programming error, fix your code! auths = self._auth_client.getAuth(atype, realm) - _log.debug("sending authorization: %s", auths) + _logger.debug("sending authorization: %s", auths) h.putheader('Authorization', auths) self.send_content(h, request_body) @@ -255,8 +255,8 @@ class addAuthTransport: log.warning("Why have data on a 401 auth. message?") if realm.startswith('realm="') and realm.endswith('"'): realm = realm[7:-1] - _log.debug("Resp: %r %r", resp.version,resp.isclosed(), resp.will_close) - _log.debug("Want to do auth %s for realm %s", atype, realm) + _logger.debug("Resp: %r %r", resp.version,resp.isclosed(), resp.will_close) + _logger.debug("Want to do auth %s for realm %s", atype, realm) if atype != 'Basic': raise ProtocolError(host+handler, 403, "Unknown authentication method: %s" % atype, resp.msg) @@ -315,7 +315,7 @@ class HTTPSConnection(httplib.HTTPSConnection): lf = (len(ssl.PEM_FOOTER)+1) if cert[0-lf] != '\n': cert = cert[:0-lf]+'\n'+cert[0-lf:] - _log.debug("len-footer: %s cert: %r", lf, cert[0-lf]) + _logger.debug("len-footer: %s cert: %r", lf, cert[0-lf]) return cert @@ -390,7 +390,7 @@ class DAVClient(object): import base64 dbg = self.dbg hdrs.update(self.hdrs) - _log.debug("Getting %s http://%s:%d/%s", method, self.host, self.port, path) + _logger.debug("Getting %s http://%s:%d/%s", method, self.host, self.port, path) conn = httplib.HTTPConnection(self.host, port=self.port, timeout=self.timeout) conn.set_debuglevel(dbg) if not path: @@ -409,8 +409,8 @@ class DAVClient(object): data1 = r1.read() if not self.user: raise Exception('Must auth, have no user/pass!') - _log.debug("Ver: %s, closed: %s, will close: %s", r1.version,r1.isclosed(), r1.will_close) - _log.debug("Want to do auth %s for realm %s", atype, realm) + _logger.debug("Ver: %s, closed: %s, will close: %s", r1.version,r1.isclosed(), r1.will_close) + _logger.debug("Want to do auth %s for realm %s", atype, realm) if atype == 'Basic' : auths = base64.encodestring(self.user + ':' + self.passwd) if auths[-1] == "\n": @@ -422,22 +422,22 @@ class DAVClient(object): else: raise Exception("Unknown auth type %s" %atype) else: - _log.warning("Got 401, cannot auth") + _logger.warning("Got 401, cannot auth") raise Exception('No auth') - _log.debug("Reponse: %s %s",r1.status, r1.reason) + _logger.debug("Reponse: %s %s",r1.status, r1.reason) data1 = r1.read() if method != 'GET': - _log.debug("Body:\n%s\nEnd of body", data1) + _logger.debug("Body:\n%s\nEnd of body", data1) try: ctype = r1.msg.getheader('content-type') if ctype and ';' in ctype: ctype, encoding = ctype.split(';',1) if ctype == 'text/xml': doc = xml.dom.minidom.parseString(data1) - _log.debug("XML Body:\n %s", doc.toprettyxml(indent="\t")) + _logger.debug("XML Body:\n %s", doc.toprettyxml(indent="\t")) except Exception: - _log.warning("could not print xml", exc_info=True) + _logger.warning("could not print xml", exc_info=True) pass conn.close() return r1.status, r1.msg, data1 @@ -474,7 +474,7 @@ class DAVClient(object): s, m, d = self._http_request(path, method='OPTIONS', hdrs=hdrs) assert s == 200, "Status: %r" % s assert 'OPTIONS' in m.getheader('Allow') - _log.debug('Options: %r', m.getheader('Allow')) + _logger.debug('Options: %r', m.getheader('Allow')) if expect: self._assert_headers(expect, m) @@ -493,10 +493,10 @@ class DAVClient(object): for cnod in node.childNodes: if cnod.nodeType != node.ELEMENT_NODE: if strict: - _log.debug("Found %r inside <%s>", cnod, node.tagName) + _logger.debug("Found %r inside <%s>", cnod, node.tagName) continue if namespaces and (cnod.namespaceURI not in namespaces): - _log.debug("Ignoring <%s> in <%s>", cnod.tagName, node.localName) + _logger.debug("Ignoring <%s> in <%s>", cnod.tagName, node.localName) continue yield cnod @@ -533,10 +533,10 @@ class DAVClient(object): assert htver == 'HTTP/1.1' rstatus = int(sta) else: - _log.debug("What is <%s> inside a ?", pno.tagName) + _logger.debug("What is <%s> inside a ?", pno.tagName) else: - _log.debug("Unknown node: %s", cno.tagName) + _logger.debug("Unknown node: %s", cno.tagName) res.setdefault(href,[]).append((status, res_nss)) @@ -637,7 +637,7 @@ class DAVClient(object): if lsp[1] in davprops: lsline[lsp[0]] = lsp[2] else: - _log.debug("Strange status: %s", st) + _logger.debug("Strange status: %s", st) res.append(lsline) -- cgit v1.2.3