diff --git a/modules/boursorama/pages/two_authentication.py b/modules/boursorama/pages/two_authentication.py index 33bc97d2..2de11972 100644 --- a/modules/boursorama/pages/two_authentication.py +++ b/modules/boursorama/pages/two_authentication.py @@ -17,8 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from __future__ import print_function - from weboob.tools.browser import Page, BrowserIncorrectPassword import urllib2 import re @@ -86,7 +84,6 @@ class AuthenticationPage(Page): r = regex.search(info) token = r.group('value') #print "Extracted token", token - #self.print_cookies() #step2 url = "https://" + DOMAIN + "/ajax/banque/otp.phtml" @@ -97,7 +94,6 @@ class AuthenticationPage(Page): #print "after asking to send token authentification" \ # ,len(info), response.info() - #self.print_cookies() pin = raw_input('Enter the "Boursorama Banque" access code:') #print "Pin access code: ''%s''" % (pin) @@ -108,8 +104,6 @@ class AuthenticationPage(Page): #info = response.read() #print "after pin authentification", len(info), response.info() - #self.print_cookies() - url = "%s?" % (SECURE_PAGE) data = "org=/&device=%s" % (device) req = urllib2.Request(url, data, headers=headers) @@ -117,9 +111,3 @@ class AuthenticationPage(Page): #result = response.read() #print response, "\n", response.info() - - #self.print_cookies() - - def print_cookies(self): - for c in self.browser._ua_handlers["_cookies"].cookiejar: - print("%s : %s" % (c.name, c.value)) diff --git a/modules/cragr/web/pages.py b/modules/cragr/web/pages.py index 5971b0f1..c1edec5b 100644 --- a/modules/cragr/web/pages.py +++ b/modules/cragr/web/pages.py @@ -17,8 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from __future__ import print_function - import re from decimal import Decimal @@ -219,8 +217,8 @@ class CardsPage(Page): try: t.id = t.unique_id(seen) except UnicodeEncodeError: - print(t) - print(t.label) + self.logger.debug(t) + self.logger.debug(t.label) raise yield t diff --git a/modules/europarl/pages.py b/modules/europarl/pages.py index f6f83272..92de9a2f 100644 --- a/modules/europarl/pages.py +++ b/modules/europarl/pages.py @@ -18,8 +18,6 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from __future__ import print_function - from weboob.tools.mech import ClientForm ControlNotFoundError = ClientForm.ControlNotFoundError @@ -75,7 +73,6 @@ class VideoPage(Page): obj = self.parser.select(self.document.getroot(), 'meta[name=available]', 1) if obj is not None: value = obj.attrib['content'] - print(value) m = re.match('(\d\d)-(\d\d)-(\d\d\d\d)\s*(\d\d):(\d\d)', value) if not m: raise BrokenPageError('Unable to parse datetime: %r' % value) diff --git a/modules/gdcvault/browser.py b/modules/gdcvault/browser.py index 25987cc2..6b6c2783 100644 --- a/modules/gdcvault/browser.py +++ b/modules/gdcvault/browser.py @@ -18,8 +18,6 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from __future__ import print_function - import urllib from weboob.tools.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\ @@ -71,7 +69,6 @@ class GDCVaultBrowser(Browser): data = self.readurl('http://gdcvault.com/api/login.php', urllib.urlencode(params)) # some data returned as JSON, not sure yet if it's useful - #print data if data is None: self.openurl('/logout', '') @@ -100,9 +97,7 @@ class GDCVaultBrowser(Browser): self.open_novisit(url) #headers = req.info() except HTTPError as e: - # print e.getcode() if e.getcode() == 302 and hasattr(e, 'hdrs'): - #print e.hdrs['Location'] if e.hdrs['Location'] in ['/', '/login']: requires_account = True else: @@ -117,7 +112,6 @@ class GDCVaultBrowser(Browser): if video is None: m = re.match('http://[w\.]*gdcvault.com/play/(?P[\d]+)/?.*', url) if m: - # print m.group(1) video = GDCVaultVideo(int(m.group(1))) else: raise BrowserUnavailable('Cannot find ID on page with redirection') @@ -142,7 +136,6 @@ class GDCVaultBrowser(Browser): self.addheaders = [('Referer', 'http://gdcvault.com/'), ("Content-Type" , 'application/x-www-form-urlencoded') ] - #print post_data # is_logged assumes html page self.location('http://gdcvault.com/search.php', data=post_data, no_login=True) @@ -151,7 +144,6 @@ class GDCVaultBrowser(Browser): return self.page.iter_videos() def latest_videos(self): - print("browser:latest_videos()") #self.home() self.location('/free') assert self.is_on_page(IndexPage) diff --git a/modules/hellobank/browser.py b/modules/hellobank/browser.py index f9a63815..a0202859 100644 --- a/modules/hellobank/browser.py +++ b/modules/hellobank/browser.py @@ -18,8 +18,6 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from __future__ import print_function - import urllib import mechanize from datetime import datetime @@ -86,7 +84,7 @@ class HelloBank(Browser): accounts = self.page.get_accounts() if len(accounts) == 0: - print('no accounts') + self.logger.warning('no accounts') # oops, no accounts? check if we have not exhausted the allowed use # of this password for img in self.document.getroot().cssselect('img[align="middle"]'): diff --git a/modules/hellobank/perso/accounts_list.py b/modules/hellobank/perso/accounts_list.py index 08d0fd32..c567ffb0 100644 --- a/modules/hellobank/perso/accounts_list.py +++ b/modules/hellobank/perso/accounts_list.py @@ -18,8 +18,6 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from __future__ import print_function - from decimal import Decimal from weboob.capabilities.bank import Account @@ -67,7 +65,7 @@ class AccountsList(Page): l.append(account) if len(l) == 0: - print('no accounts') + self.logger.warning('no accounts') # oops, no accounts? check if we have not exhausted the allowed use # of this password for img in self.document.getroot().cssselect('img[align="middle"]'): diff --git a/modules/okc/optim/profiles_walker.py b/modules/okc/optim/profiles_walker.py index c6eaa2cf..77f62fcb 100644 --- a/modules/okc/optim/profiles_walker.py +++ b/modules/okc/optim/profiles_walker.py @@ -17,8 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from __future__ import print_function - from random import randint from weboob.tools.browser import BrowserUnavailable @@ -101,7 +99,7 @@ class ProfilesWalker(Optimization): self.profiles_queue.add(id) return except Exception as e: - print(e) + self.logger.exception(e) finally: if self.view_cron is not None: self.view_cron = self.sched.schedule(randint(5, 10), self.view_profile) diff --git a/modules/societegenerale/captcha.py b/modules/societegenerale/captcha.py index 7e5178c7..1e5a4b6c 100644 --- a/modules/societegenerale/captcha.py +++ b/modules/societegenerale/captcha.py @@ -17,9 +17,8 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from __future__ import print_function - import hashlib +from weboob.tools.log import getLogger try: from PIL import Image @@ -113,6 +112,7 @@ class Tile(object): def __init__(self, _id): self.id = _id self.valid = False + self.logger = getLogger('societegenerale.captcha') self.map = [] def __repr__(self): @@ -134,7 +134,7 @@ class Tile(object): raise TileError('Tile not found ' + sum, self) def display(self): - print(self.checksum()) + self.logger.debug(self.checksum()) #im = Image.new('RGB', (24, 23)) #im.putdata(self.map) #im.save('/tmp/%s.png' % self.checksum()) diff --git a/modules/transilien/pages.py b/modules/transilien/pages.py index 6fdadc99..560f598b 100644 --- a/modules/transilien/pages.py +++ b/modules/transilien/pages.py @@ -18,8 +18,6 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . -from __future__ import print_function - import re from weboob.browser2.page import JsonPage, HTMLPage, method @@ -144,7 +142,7 @@ class DeparturesPage2(HTMLPage): form['moiHoraire'] = '%s|%s' % (date.month, date.year) form['heureHoraire'] = date.hour form['minuteHoraire'] = date.minute - print(form) + self.logger.debug(form) form.submit() diff --git a/tools/pyflakes.sh b/tools/pyflakes.sh index 3e975bd3..97121bb7 100755 --- a/tools/pyflakes.sh +++ b/tools/pyflakes.sh @@ -9,6 +9,8 @@ grep -Fn '__future__ import with_statement' ${PYFILES} && echo 'Error: with_stat grep -nE '^[[:space:]]+except [[:alnum:] ]+,[[:alnum:] ]+' ${PYFILES} && echo 'Error: use new "as" way of naming exceptions' && exit 7 grep -nE "^ *print " ${PYFILES} && echo 'Error: Use the print function' && exit 8 grep -Fn ".has_key" ${PYFILES} && echo 'Error: Deprecated, use in' && exit 9 +MODULE_FILES=$(git ls-files|grep '^modules/.*\.py$'|tr '\n' ' ') +grep -nE "^ *print(\(| )" ${MODULE_FILES} && echo 'Error: Use of print in modules is forbidden, use logger instead' && exit 10 FLAKE8="" if which flake8 >/dev/null 2>&1; then