add check to prevent prints in weboob modules
This commit is contained in:
parent
1eb96574d0
commit
be7d49312d
10 changed files with 11 additions and 42 deletions
|
|
@ -17,8 +17,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from weboob.tools.browser import Page, BrowserIncorrectPassword
|
from weboob.tools.browser import Page, BrowserIncorrectPassword
|
||||||
import urllib2
|
import urllib2
|
||||||
import re
|
import re
|
||||||
|
|
@ -86,7 +84,6 @@ class AuthenticationPage(Page):
|
||||||
r = regex.search(info)
|
r = regex.search(info)
|
||||||
token = r.group('value')
|
token = r.group('value')
|
||||||
#print "Extracted token", token
|
#print "Extracted token", token
|
||||||
#self.print_cookies()
|
|
||||||
|
|
||||||
#step2
|
#step2
|
||||||
url = "https://" + DOMAIN + "/ajax/banque/otp.phtml"
|
url = "https://" + DOMAIN + "/ajax/banque/otp.phtml"
|
||||||
|
|
@ -97,7 +94,6 @@ class AuthenticationPage(Page):
|
||||||
#print "after asking to send token authentification" \
|
#print "after asking to send token authentification" \
|
||||||
# ,len(info), response.info()
|
# ,len(info), response.info()
|
||||||
|
|
||||||
#self.print_cookies()
|
|
||||||
|
|
||||||
pin = raw_input('Enter the "Boursorama Banque" access code:')
|
pin = raw_input('Enter the "Boursorama Banque" access code:')
|
||||||
#print "Pin access code: ''%s''" % (pin)
|
#print "Pin access code: ''%s''" % (pin)
|
||||||
|
|
@ -108,8 +104,6 @@ class AuthenticationPage(Page):
|
||||||
#info = response.read()
|
#info = response.read()
|
||||||
#print "after pin authentification", len(info), response.info()
|
#print "after pin authentification", len(info), response.info()
|
||||||
|
|
||||||
#self.print_cookies()
|
|
||||||
|
|
||||||
url = "%s?" % (SECURE_PAGE)
|
url = "%s?" % (SECURE_PAGE)
|
||||||
data = "org=/&device=%s" % (device)
|
data = "org=/&device=%s" % (device)
|
||||||
req = urllib2.Request(url, data, headers=headers)
|
req = urllib2.Request(url, data, headers=headers)
|
||||||
|
|
@ -117,9 +111,3 @@ class AuthenticationPage(Page):
|
||||||
|
|
||||||
#result = response.read()
|
#result = response.read()
|
||||||
#print response, "\n", response.info()
|
#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))
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
|
|
@ -219,8 +217,8 @@ class CardsPage(Page):
|
||||||
try:
|
try:
|
||||||
t.id = t.unique_id(seen)
|
t.id = t.unique_id(seen)
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
print(t)
|
self.logger.debug(t)
|
||||||
print(t.label)
|
self.logger.debug(t.label)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
yield t
|
yield t
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from weboob.tools.mech import ClientForm
|
from weboob.tools.mech import ClientForm
|
||||||
ControlNotFoundError = ClientForm.ControlNotFoundError
|
ControlNotFoundError = ClientForm.ControlNotFoundError
|
||||||
|
|
||||||
|
|
@ -75,7 +73,6 @@ class VideoPage(Page):
|
||||||
obj = self.parser.select(self.document.getroot(), 'meta[name=available]', 1)
|
obj = self.parser.select(self.document.getroot(), 'meta[name=available]', 1)
|
||||||
if obj is not None:
|
if obj is not None:
|
||||||
value = obj.attrib['content']
|
value = obj.attrib['content']
|
||||||
print(value)
|
|
||||||
m = re.match('(\d\d)-(\d\d)-(\d\d\d\d)\s*(\d\d):(\d\d)', value)
|
m = re.match('(\d\d)-(\d\d)-(\d\d\d\d)\s*(\d\d):(\d\d)', value)
|
||||||
if not m:
|
if not m:
|
||||||
raise BrokenPageError('Unable to parse datetime: %r' % value)
|
raise BrokenPageError('Unable to parse datetime: %r' % value)
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from weboob.tools.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\
|
from weboob.tools.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\
|
||||||
|
|
@ -71,7 +69,6 @@ class GDCVaultBrowser(Browser):
|
||||||
data = self.readurl('http://gdcvault.com/api/login.php',
|
data = self.readurl('http://gdcvault.com/api/login.php',
|
||||||
urllib.urlencode(params))
|
urllib.urlencode(params))
|
||||||
# some data returned as JSON, not sure yet if it's useful
|
# some data returned as JSON, not sure yet if it's useful
|
||||||
#print data
|
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
self.openurl('/logout', '')
|
self.openurl('/logout', '')
|
||||||
|
|
@ -100,9 +97,7 @@ class GDCVaultBrowser(Browser):
|
||||||
self.open_novisit(url)
|
self.open_novisit(url)
|
||||||
#headers = req.info()
|
#headers = req.info()
|
||||||
except HTTPError as e:
|
except HTTPError as e:
|
||||||
# print e.getcode()
|
|
||||||
if e.getcode() == 302 and hasattr(e, 'hdrs'):
|
if e.getcode() == 302 and hasattr(e, 'hdrs'):
|
||||||
#print e.hdrs['Location']
|
|
||||||
if e.hdrs['Location'] in ['/', '/login']:
|
if e.hdrs['Location'] in ['/', '/login']:
|
||||||
requires_account = True
|
requires_account = True
|
||||||
else:
|
else:
|
||||||
|
|
@ -117,7 +112,6 @@ class GDCVaultBrowser(Browser):
|
||||||
if video is None:
|
if video is None:
|
||||||
m = re.match('http://[w\.]*gdcvault.com/play/(?P<id>[\d]+)/?.*', url)
|
m = re.match('http://[w\.]*gdcvault.com/play/(?P<id>[\d]+)/?.*', url)
|
||||||
if m:
|
if m:
|
||||||
# print m.group(1)
|
|
||||||
video = GDCVaultVideo(int(m.group(1)))
|
video = GDCVaultVideo(int(m.group(1)))
|
||||||
else:
|
else:
|
||||||
raise BrowserUnavailable('Cannot find ID on page with redirection')
|
raise BrowserUnavailable('Cannot find ID on page with redirection')
|
||||||
|
|
@ -142,7 +136,6 @@ class GDCVaultBrowser(Browser):
|
||||||
self.addheaders = [('Referer', 'http://gdcvault.com/'),
|
self.addheaders = [('Referer', 'http://gdcvault.com/'),
|
||||||
("Content-Type" , 'application/x-www-form-urlencoded') ]
|
("Content-Type" , 'application/x-www-form-urlencoded') ]
|
||||||
|
|
||||||
#print post_data
|
|
||||||
# is_logged assumes html page
|
# is_logged assumes html page
|
||||||
self.location('http://gdcvault.com/search.php',
|
self.location('http://gdcvault.com/search.php',
|
||||||
data=post_data, no_login=True)
|
data=post_data, no_login=True)
|
||||||
|
|
@ -151,7 +144,6 @@ class GDCVaultBrowser(Browser):
|
||||||
return self.page.iter_videos()
|
return self.page.iter_videos()
|
||||||
|
|
||||||
def latest_videos(self):
|
def latest_videos(self):
|
||||||
print("browser:latest_videos()")
|
|
||||||
#self.home()
|
#self.home()
|
||||||
self.location('/free')
|
self.location('/free')
|
||||||
assert self.is_on_page(IndexPage)
|
assert self.is_on_page(IndexPage)
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
import mechanize
|
import mechanize
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
@ -86,7 +84,7 @@ class HelloBank(Browser):
|
||||||
|
|
||||||
accounts = self.page.get_accounts()
|
accounts = self.page.get_accounts()
|
||||||
if len(accounts) == 0:
|
if len(accounts) == 0:
|
||||||
print('no accounts')
|
self.logger.warning('no accounts')
|
||||||
# oops, no accounts? check if we have not exhausted the allowed use
|
# oops, no accounts? check if we have not exhausted the allowed use
|
||||||
# of this password
|
# of this password
|
||||||
for img in self.document.getroot().cssselect('img[align="middle"]'):
|
for img in self.document.getroot().cssselect('img[align="middle"]'):
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from weboob.capabilities.bank import Account
|
from weboob.capabilities.bank import Account
|
||||||
|
|
@ -67,7 +65,7 @@ class AccountsList(Page):
|
||||||
l.append(account)
|
l.append(account)
|
||||||
|
|
||||||
if len(l) == 0:
|
if len(l) == 0:
|
||||||
print('no accounts')
|
self.logger.warning('no accounts')
|
||||||
# oops, no accounts? check if we have not exhausted the allowed use
|
# oops, no accounts? check if we have not exhausted the allowed use
|
||||||
# of this password
|
# of this password
|
||||||
for img in self.document.getroot().cssselect('img[align="middle"]'):
|
for img in self.document.getroot().cssselect('img[align="middle"]'):
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
from weboob.tools.browser import BrowserUnavailable
|
from weboob.tools.browser import BrowserUnavailable
|
||||||
|
|
@ -101,7 +99,7 @@ class ProfilesWalker(Optimization):
|
||||||
self.profiles_queue.add(id)
|
self.profiles_queue.add(id)
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
self.logger.exception(e)
|
||||||
finally:
|
finally:
|
||||||
if self.view_cron is not None:
|
if self.view_cron is not None:
|
||||||
self.view_cron = self.sched.schedule(randint(5, 10), self.view_profile)
|
self.view_cron = self.sched.schedule(randint(5, 10), self.view_profile)
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
from weboob.tools.log import getLogger
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
@ -113,6 +112,7 @@ class Tile(object):
|
||||||
def __init__(self, _id):
|
def __init__(self, _id):
|
||||||
self.id = _id
|
self.id = _id
|
||||||
self.valid = False
|
self.valid = False
|
||||||
|
self.logger = getLogger('societegenerale.captcha')
|
||||||
self.map = []
|
self.map = []
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
@ -134,7 +134,7 @@ class Tile(object):
|
||||||
raise TileError('Tile not found ' + sum, self)
|
raise TileError('Tile not found ' + sum, self)
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
print(self.checksum())
|
self.logger.debug(self.checksum())
|
||||||
#im = Image.new('RGB', (24, 23))
|
#im = Image.new('RGB', (24, 23))
|
||||||
#im.putdata(self.map)
|
#im.putdata(self.map)
|
||||||
#im.save('/tmp/%s.png' % self.checksum())
|
#im.save('/tmp/%s.png' % self.checksum())
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from weboob.browser2.page import JsonPage, HTMLPage, method
|
from weboob.browser2.page import JsonPage, HTMLPage, method
|
||||||
|
|
@ -144,7 +142,7 @@ class DeparturesPage2(HTMLPage):
|
||||||
form['moiHoraire'] = '%s|%s' % (date.month, date.year)
|
form['moiHoraire'] = '%s|%s' % (date.month, date.year)
|
||||||
form['heureHoraire'] = date.hour
|
form['heureHoraire'] = date.hour
|
||||||
form['minuteHoraire'] = date.minute
|
form['minuteHoraire'] = date.minute
|
||||||
print(form)
|
self.logger.debug(form)
|
||||||
form.submit()
|
form.submit()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 '^[[: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 -nE "^ *print " ${PYFILES} && echo 'Error: Use the print function' && exit 8
|
||||||
grep -Fn ".has_key" ${PYFILES} && echo 'Error: Deprecated, use in' && exit 9
|
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=""
|
FLAKE8=""
|
||||||
if which flake8 >/dev/null 2>&1; then
|
if which flake8 >/dev/null 2>&1; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue