add check to prevent prints in weboob modules

This commit is contained in:
Romain Bignon 2014-10-06 16:42:56 +02:00
commit be7d49312d
10 changed files with 11 additions and 42 deletions

View file

@ -17,8 +17,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
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))

View file

@ -17,8 +17,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
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

View file

@ -18,8 +18,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
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)

View file

@ -18,8 +18,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
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<id>[\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)

View file

@ -18,8 +18,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
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"]'):

View file

@ -18,8 +18,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
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"]'):

View file

@ -17,8 +17,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
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)

View file

@ -17,9 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
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())

View file

@ -18,8 +18,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
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()

View file

@ -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