Use the print function everywhere
python modernize.py --no-six -f libmodernize.fixes.fix_print -w With manual fixes as the import was put always on top.
This commit is contained in:
parent
d22656308a
commit
74a4ef6723
73 changed files with 499 additions and 442 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
# 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 datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -138,7 +139,7 @@ class BoobotBrowser(StandardBrowser):
|
||||||
# meta charset=...
|
# meta charset=...
|
||||||
encoding = meta.attrib.get('charset', encoding).lower()
|
encoding = meta.attrib.get('charset', encoding).lower()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print e
|
print(e)
|
||||||
finally:
|
finally:
|
||||||
r.seek(0)
|
r.seek(0)
|
||||||
if encoding == 'iso-8859-1' or not encoding:
|
if encoding == 'iso-8859-1' or not encoding:
|
||||||
|
|
@ -159,7 +160,7 @@ class BoobotBrowser(StandardBrowser):
|
||||||
title = ' '.join(title.splitlines())
|
title = ' '.join(title.splitlines())
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
# invalid HTML
|
# invalid HTML
|
||||||
print e
|
print(e)
|
||||||
|
|
||||||
return content_type, hsize, title
|
return content_type, hsize, title
|
||||||
|
|
||||||
|
|
@ -377,7 +378,7 @@ class Boobot(SingleServerIRCBot):
|
||||||
for msg in getattr(self, func)(backend, _id):
|
for msg in getattr(self, func)(backend, _id):
|
||||||
yield msg
|
yield msg
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print get_backtrace()
|
print(get_backtrace())
|
||||||
yield u'Oops: [%s] %s' % (type(e).__name__, e)
|
yield u'Oops: [%s] %s' % (type(e).__name__, e)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
@ -394,7 +395,7 @@ class Boobot(SingleServerIRCBot):
|
||||||
except BrowserUnavailable as e:
|
except BrowserUnavailable as e:
|
||||||
yield u'URL (error): %s' % e
|
yield u'URL (error): %s' % e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print get_backtrace()
|
print(get_backtrace())
|
||||||
yield u'Oops: [%s] %s' % (type(e).__name__, e)
|
yield u'Oops: [%s] %s' % (type(e).__name__, e)
|
||||||
|
|
||||||
def obj_info_video(self, backend, id):
|
def obj_info_video(self, backend, id):
|
||||||
|
|
@ -418,7 +419,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
bot.start()
|
bot.start()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print "Stopped."
|
print("Stopped.")
|
||||||
|
|
||||||
thread.stop()
|
thread.stop()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,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 subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
@ -69,10 +71,10 @@ class Downloadboob(object):
|
||||||
for local_link_name in dirList:
|
for local_link_name in dirList:
|
||||||
link_name = self.links_directory + "/" + local_link_name
|
link_name = self.links_directory + "/" + local_link_name
|
||||||
if not self.check_link(link_name):
|
if not self.check_link(link_name):
|
||||||
print u"Remove %s" % link_name
|
print(u"Remove %s" % link_name)
|
||||||
os.remove(link_name)
|
os.remove(link_name)
|
||||||
else:
|
else:
|
||||||
print u"Keep %s" % link_name
|
print(u"Keep %s" % link_name)
|
||||||
|
|
||||||
def check_link(self, link_name):
|
def check_link(self, link_name):
|
||||||
if os.path.islink(link_name):
|
if os.path.islink(link_name):
|
||||||
|
|
@ -85,10 +87,10 @@ class Downloadboob(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def download(self, pattern=None, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None, title_exclude=[], id_regexp=None):
|
def download(self, pattern=None, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None, title_exclude=[], id_regexp=None):
|
||||||
print "For backend %s, search for '%s'" % (backend_name, pattern)
|
print("For backend %s, search for '%s'" % (backend_name, pattern))
|
||||||
|
|
||||||
# create directory for links
|
# create directory for links
|
||||||
print " create link to %s" % self.links_directory
|
print(" create link to %s" % self.links_directory)
|
||||||
if not os.path.isdir(self.links_directory):
|
if not os.path.isdir(self.links_directory):
|
||||||
os.makedirs(self.links_directory)
|
os.makedirs(self.links_directory)
|
||||||
|
|
||||||
|
|
@ -101,17 +103,17 @@ class Downloadboob(object):
|
||||||
if not self.is_downloaded(video):
|
if not self.is_downloaded(video):
|
||||||
self.backend.fill_video(video, ('url','title', 'url', 'duration'))
|
self.backend.fill_video(video, ('url','title', 'url', 'duration'))
|
||||||
if not(self.is_excluded(video.title, title_exclude)) and self.id_regexp_matched(video.id, id_regexp):
|
if not(self.is_excluded(video.title, title_exclude)) and self.id_regexp_matched(video.id, id_regexp):
|
||||||
print " %s\n Id:%s\n Duration:%s" % (video.title, video.id, video.duration)
|
print(" %s\n Id:%s\n Duration:%s" % (video.title, video.id, video.duration))
|
||||||
videos.append(video)
|
videos.append(video)
|
||||||
else:
|
else:
|
||||||
print "Already downloaded, check %s" % video.id
|
print("Already downloaded, check %s" % video.id)
|
||||||
self.backend.fill_video(video, ('url','title', 'url', 'duration'))
|
self.backend.fill_video(video, ('url','title', 'url', 'duration'))
|
||||||
linkname = self.get_linkname(video)
|
linkname = self.get_linkname(video)
|
||||||
if not os.path.exists(linkname):
|
if not os.path.exists(linkname):
|
||||||
self.remove_download(video)
|
self.remove_download(video)
|
||||||
|
|
||||||
# download videos
|
# download videos
|
||||||
print "Downloading..."
|
print("Downloading...")
|
||||||
for video in videos:
|
for video in videos:
|
||||||
self.do_download(video)
|
self.do_download(video)
|
||||||
|
|
||||||
|
|
@ -164,7 +166,7 @@ class Downloadboob(object):
|
||||||
# already empty
|
# already empty
|
||||||
return
|
return
|
||||||
|
|
||||||
print 'Remove video %s' % video.title
|
print('Remove video %s' % video.title)
|
||||||
|
|
||||||
# Empty it to keep information we have already downloaded it.
|
# Empty it to keep information we have already downloaded it.
|
||||||
with open(path, 'w'):
|
with open(path, 'w'):
|
||||||
|
|
@ -175,23 +177,23 @@ class Downloadboob(object):
|
||||||
idname = self.get_filename(video, relative=True)
|
idname = self.get_filename(video, relative=True)
|
||||||
absolute_idname = self.get_filename(video, relative=False)
|
absolute_idname = self.get_filename(video, relative=False)
|
||||||
if not os.path.islink(linkname) and os.path.isfile(absolute_idname):
|
if not os.path.islink(linkname) and os.path.isfile(absolute_idname):
|
||||||
print "%s -> %s" % (linkname, idname)
|
print("%s -> %s" % (linkname, idname))
|
||||||
os.symlink(idname, linkname)
|
os.symlink(idname, linkname)
|
||||||
|
|
||||||
def do_download(self, video):
|
def do_download(self, video):
|
||||||
if not video:
|
if not video:
|
||||||
print >>sys.stderr, 'Video not found: %s' % video
|
print('Video not found: %s' % video, file=sys.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if not video.url:
|
if not video.url:
|
||||||
print >>sys.stderr, 'Error: the direct URL is not available.'
|
print('Error: the direct URL is not available.', file=sys.stderr)
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
def check_exec(executable):
|
def check_exec(executable):
|
||||||
with open('/dev/null', 'w') as devnull:
|
with open('/dev/null', 'w') as devnull:
|
||||||
process = subprocess.Popen(['which', executable], stdout=devnull)
|
process = subprocess.Popen(['which', executable], stdout=devnull)
|
||||||
if process.wait() != 0:
|
if process.wait() != 0:
|
||||||
print >>sys.stderr, 'Please install "%s"' % executable
|
print('Please install "%s"' % executable, file=sys.stderr)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -220,14 +222,14 @@ config.read(['/etc/downloadboob.conf', os.path.expanduser('~/downloadboob.conf')
|
||||||
try:
|
try:
|
||||||
links_directory=os.path.expanduser(config.get('main','directory', '.'))
|
links_directory=os.path.expanduser(config.get('main','directory', '.'))
|
||||||
except ConfigParser.NoSectionError:
|
except ConfigParser.NoSectionError:
|
||||||
print "Please create a documentation file (see the README file and the downloadboob.conf example file)"
|
print("Please create a documentation file (see the README file and the downloadboob.conf example file)")
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
links_directory=links_directory.decode('utf-8')
|
links_directory=links_directory.decode('utf-8')
|
||||||
|
|
||||||
download_directory=os.path.join(links_directory, DOWNLOAD_DIRECTORY)
|
download_directory=os.path.join(links_directory, DOWNLOAD_DIRECTORY)
|
||||||
|
|
||||||
print "Downloading to %s" % (links_directory)
|
print("Downloading to %s" % (links_directory))
|
||||||
|
|
||||||
for section in config.sections():
|
for section in config.sections():
|
||||||
if section != "main":
|
if section != "main":
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,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
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sqlite3 as sqlite
|
import sqlite3 as sqlite
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
|
|
@ -36,13 +38,13 @@ def main(filename):
|
||||||
try:
|
try:
|
||||||
hds = weboob.build_backend('hds')
|
hds = weboob.build_backend('hds')
|
||||||
except ModuleLoadError as e:
|
except ModuleLoadError as e:
|
||||||
print >>sys.stderr, 'Unable to load "hds" module: %s' % e
|
print('Unable to load "hds" module: %s' % e, file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = sqlite.connect(database=filename, timeout=10.0)
|
db = sqlite.connect(database=filename, timeout=10.0)
|
||||||
except sqlite.OperationalError as err:
|
except sqlite.OperationalError as err:
|
||||||
print >>sys.stderr, 'Unable to open %s database: %s' % (filename, err)
|
print('Unable to open %s database: %s' % (filename, err), file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
sys.stdout.write('Reading database... ')
|
sys.stdout.write('Reading database... ')
|
||||||
|
|
@ -50,7 +52,7 @@ def main(filename):
|
||||||
try:
|
try:
|
||||||
results = db.execute('SELECT id, author FROM stories')
|
results = db.execute('SELECT id, author FROM stories')
|
||||||
except sqlite.OperationalError as err:
|
except sqlite.OperationalError as err:
|
||||||
print >>sys.stderr, 'fail!\nUnable to read database: %s' % err
|
print('fail!\nUnable to read database: %s' % err, file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
stored = set()
|
stored = set()
|
||||||
|
|
@ -104,33 +106,33 @@ def main(filename):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print >>sys.stderr, 'Syntax: %s [--help] SQLITE_FILENAME' % sys.argv[0]
|
print('Syntax: %s [--help] SQLITE_FILENAME' % sys.argv[0], file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if sys.argv[1] in ('-h', '--help'):
|
if sys.argv[1] in ('-h', '--help'):
|
||||||
print 'Syntax: %s SQLITE_FILENAME' % sys.argv[0]
|
print('Syntax: %s SQLITE_FILENAME' % sys.argv[0])
|
||||||
print ''
|
print('')
|
||||||
print 'Before running this software, please create the database with'
|
print('Before running this software, please create the database with')
|
||||||
print 'this command:'
|
print('this command:')
|
||||||
print ' $ cat scheme.sql | sqlite3 hds.sql'
|
print(' $ cat scheme.sql | sqlite3 hds.sql')
|
||||||
print ''
|
print('')
|
||||||
print 'You can then run export.py with:'
|
print('You can then run export.py with:')
|
||||||
print ' $ %s hds.sql ' % sys.argv[0]
|
print(' $ %s hds.sql ' % sys.argv[0])
|
||||||
print ''
|
print('')
|
||||||
print 'It fill the database with stories and authors information'
|
print('It fill the database with stories and authors information')
|
||||||
print 'fetched from histoires-de-sexe.net'
|
print('fetched from histoires-de-sexe.net')
|
||||||
print ''
|
print('')
|
||||||
print 'You can next use SQL queries to find interesting stories, for'
|
print('You can next use SQL queries to find interesting stories, for')
|
||||||
print 'example:'
|
print('example:')
|
||||||
print ''
|
print('')
|
||||||
print '- To get all stories written by women'
|
print('- To get all stories written by women')
|
||||||
print ' sqlite> SELECT s.id, s.title, s.category, a.name'
|
print(' sqlite> SELECT s.id, s.title, s.category, a.name')
|
||||||
print ' FROM stories AS s LEFT JOIN authors AS a'
|
print(' FROM stories AS s LEFT JOIN authors AS a')
|
||||||
print ' WHERE a.name = s.author AND a.sex = 2;'
|
print(' WHERE a.name = s.author AND a.sex = 2;')
|
||||||
print '- To get all stories where it talks about bukkake'
|
print('- To get all stories where it talks about bukkake')
|
||||||
print ' sqlite> SELECT s.id, s.title, s.category, a.name'
|
print(' sqlite> SELECT s.id, s.title, s.category, a.name')
|
||||||
print ' FROM stories AS s LEFT JOIN authors AS a'
|
print(' FROM stories AS s LEFT JOIN authors AS a')
|
||||||
print ' WHERE a.name = s.author AND s.body LIKE \'%bukkake%\';'
|
print(' WHERE a.name = s.author AND s.body LIKE \'%bukkake%\';')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
sys.exit(main(sys.argv[1]))
|
sys.exit(main(sys.argv[1]))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import resources.lib.test.common_test as common_xbmc
|
import resources.lib.test.common_test as common_xbmc
|
||||||
|
|
@ -7,7 +8,7 @@ import resources.lib.constants as constants
|
||||||
|
|
||||||
from resources.lib.actions import actions
|
from resources.lib.actions import actions
|
||||||
|
|
||||||
print sys.argv
|
print(sys.argv)
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
actions[constants.DISPLAY_MENU]()._do()
|
actions[constants.DISPLAY_MENU]()._do()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
from . import constants
|
from . import constants
|
||||||
|
|
||||||
|
|
@ -52,7 +53,7 @@ class DisplayCollectionMenuAction(VideoobBaseAction):
|
||||||
common_xbmc.end_of_directory(False)
|
common_xbmc.end_of_directory(False)
|
||||||
|
|
||||||
def add_videos(self, _video, backend):
|
def add_videos(self, _video, backend):
|
||||||
print _video
|
print(_video)
|
||||||
video = self.videoobmc.get_video(_video, backend)
|
video = self.videoobmc.get_video(_video, backend)
|
||||||
if video:
|
if video:
|
||||||
MenuItemVideo(video).add_to_menu()
|
MenuItemVideo(video).add_to_menu()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
|
@ -41,7 +42,7 @@ def get_addon_dir():
|
||||||
|
|
||||||
def display_error(msg):
|
def display_error(msg):
|
||||||
xbmc.executebuiltin("XBMC.Notification(%s, %s)" % (get_translation('30200').decode('utf-8'), msg))
|
xbmc.executebuiltin("XBMC.Notification(%s, %s)" % (get_translation('30200').decode('utf-8'), msg))
|
||||||
print msg
|
print(msg)
|
||||||
print_exc(msg)
|
print_exc(msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from weboob.tools.application.base import Application
|
from weboob.tools.application.base import Application
|
||||||
import os
|
import os
|
||||||
|
|
@ -53,7 +54,7 @@ class Weboobmc(Application):
|
||||||
with open('/dev/null', 'w') as devnull:
|
with open('/dev/null', 'w') as devnull:
|
||||||
process = subprocess.Popen(['which', executable], stdout=devnull)
|
process = subprocess.Popen(['which', executable], stdout=devnull)
|
||||||
if process.wait() != 0:
|
if process.wait() != 0:
|
||||||
print 'Please install "%s"' % executable
|
print('Please install "%s"' % executable)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
@ -33,11 +34,11 @@ def get_settings(key):
|
||||||
|
|
||||||
|
|
||||||
def display_error(error):
|
def display_error(error):
|
||||||
print "%s: %s" % ("ERROR", error)
|
print("%s: %s" % ("ERROR", error))
|
||||||
|
|
||||||
|
|
||||||
def display_info(msg):
|
def display_info(msg):
|
||||||
print "%s: %s" % ("INFO", msg)
|
print("%s: %s" % ("INFO", msg))
|
||||||
|
|
||||||
|
|
||||||
def parse_params(paramStr):
|
def parse_params(paramStr):
|
||||||
|
|
@ -93,18 +94,18 @@ def create_param_url(paramsDic, quote_plus=False):
|
||||||
|
|
||||||
|
|
||||||
def add_menu_item(params={}):
|
def add_menu_item(params={}):
|
||||||
print '%s => "%s"' % (params.get('name'), create_param_url(params))
|
print('%s => "%s"' % (params.get('name'), create_param_url(params)))
|
||||||
|
|
||||||
|
|
||||||
def add_menu_link(params={}):
|
def add_menu_link(params={}):
|
||||||
print '[%s] %s (%s)' % (params.get('id'), params.get('name'), params.get('url'))
|
print('[%s] %s (%s)' % (params.get('id'), params.get('name'), params.get('url')))
|
||||||
#print params.get('itemInfoLabels')
|
#print params.get('itemInfoLabels')
|
||||||
#print params.get('c_items')
|
#print params.get('c_items')
|
||||||
|
|
||||||
|
|
||||||
def end_of_directory(update=False):
|
def end_of_directory(update=False):
|
||||||
print '******************************************************'
|
print('******************************************************')
|
||||||
|
|
||||||
|
|
||||||
def download_video(url, name, dir='./'):
|
def download_video(url, name, dir='./'):
|
||||||
print 'Downlaod a video %s from %s' % (name, url)
|
print('Downlaod a video %s from %s' % (name, url))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from .base.weboobmc2 import Weboobmc
|
from .base.weboobmc2 import Weboobmc
|
||||||
from weboob.capabilities.video import BaseVideo, CapVideo
|
from weboob.capabilities.video import BaseVideo, CapVideo
|
||||||
|
|
@ -22,7 +23,7 @@ class Videoobmc(Weboobmc):
|
||||||
for _backend, video in self.weboob.do(self._do_complete, self.count, fields, 'search_videos', **kwargs):
|
for _backend, video in self.weboob.do(self._do_complete, self.count, fields, 'search_videos', **kwargs):
|
||||||
yield video
|
yield video
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print e
|
print(e)
|
||||||
|
|
||||||
def get_video(self, video, _backend):
|
def get_video(self, video, _backend):
|
||||||
backend = self.weboob.get_backend(_backend)
|
backend = self.weboob.get_backend(_backend)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 os
|
import os
|
||||||
|
|
||||||
|
|
@ -79,8 +80,8 @@ class VideoobWeb(Application):
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
self.load_config()
|
self.load_config()
|
||||||
self.weboob.load_backends(CapVideo)
|
self.weboob.load_backends(CapVideo)
|
||||||
print 'Web server created. Listening on http://%s:%s' % (
|
print('Web server created. Listening on http://%s:%s' % (
|
||||||
self.config.get('host'), int(self.config.get('port')))
|
self.config.get('host'), int(self.config.get('port'))))
|
||||||
srv = make_server(self.config.get('host'), int(self.config.get('port')), self.make_app)
|
srv = make_server(self.config.get('host'), int(self.config.get('port')), self.make_app)
|
||||||
srv.serve_forever()
|
srv.serve_forever()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -92,13 +93,13 @@ class Tile(object):
|
||||||
self.map.append(pxls)
|
self.map.append(pxls)
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
print '-' * (len(self.map) * 2 + 2)
|
print('-' * (len(self.map) * 2 + 2))
|
||||||
for y in xrange(len(self.map[0])):
|
for y in xrange(len(self.map[0])):
|
||||||
sys.stdout.write('|')
|
sys.stdout.write('|')
|
||||||
for x in xrange(len(self.map)):
|
for x in xrange(len(self.map)):
|
||||||
sys.stdout.write('%s' % ('XX' if self.map[x][y] else ' '))
|
sys.stdout.write('%s' % ('XX' if self.map[x][y] else ' '))
|
||||||
print '|'
|
print('|')
|
||||||
print '-' * (len(self.map) * 2 + 2)
|
print('-' * (len(self.map) * 2 + 2))
|
||||||
|
|
||||||
def checksum(self):
|
def checksum(self):
|
||||||
s = ''
|
s = ''
|
||||||
|
|
@ -113,9 +114,9 @@ class Tile(object):
|
||||||
try:
|
try:
|
||||||
return self.hash[checksum]
|
return self.hash[checksum]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print 'Unable te resolve:'
|
print('Unable te resolve:')
|
||||||
self.display()
|
self.display()
|
||||||
print 'hash: %s' % checksum
|
print('hash: %s' % checksum)
|
||||||
raise CaptchaError()
|
raise CaptchaError()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -175,11 +176,11 @@ class Decoder(object):
|
||||||
checksum = tile.checksum()
|
checksum = tile.checksum()
|
||||||
|
|
||||||
if checksum in self.hash:
|
if checksum in self.hash:
|
||||||
print 'Skipping %s' % self.hash[checksum]
|
print('Skipping %s' % self.hash[checksum])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
tile.display()
|
tile.display()
|
||||||
print 'Checksum: %s' % checksum
|
print('Checksum: %s' % checksum)
|
||||||
ntry = 2
|
ntry = 2
|
||||||
while ntry:
|
while ntry:
|
||||||
sys.stdout.write('Enter the letter: ')
|
sys.stdout.write('Enter the letter: ')
|
||||||
|
|
@ -187,9 +188,9 @@ class Decoder(object):
|
||||||
|
|
||||||
ntry -= 1
|
ntry -= 1
|
||||||
if len(l) != 1:
|
if len(l) != 1:
|
||||||
print 'Error: please enter only one letter'
|
print('Error: please enter only one letter')
|
||||||
elif l in self.hash.itervalues():
|
elif l in self.hash.itervalues():
|
||||||
print 'Warning! This letter has already been catched!'
|
print('Warning! This letter has already been catched!')
|
||||||
else:
|
else:
|
||||||
ntry = 0
|
ntry = 0
|
||||||
|
|
||||||
|
|
@ -200,13 +201,13 @@ class Decoder(object):
|
||||||
while True:
|
while True:
|
||||||
self.process()
|
self.process()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print ''
|
print('')
|
||||||
print 'hash = {'
|
print('hash = {')
|
||||||
l = sorted(self.hash.iteritems(), key=lambda (k,v): (v,k))
|
l = sorted(self.hash.iteritems(), key=lambda (k,v): (v,k))
|
||||||
for hash, value in l:
|
for hash, value in l:
|
||||||
print ' \'%s\': %s' % (hash, value)
|
print(' \'%s\': %s' % (hash, value))
|
||||||
|
|
||||||
print '}'
|
print('}')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
d = Decoder()
|
d = Decoder()
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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
|
||||||
|
|
||||||
|
|
@ -93,7 +94,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
|
print(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,6 +17,7 @@
|
||||||
# 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 BrowserUnavailable
|
from weboob.tools.browser import BrowserUnavailable
|
||||||
from weboob.capabilities.dating import Optimization
|
from weboob.capabilities.dating import Optimization
|
||||||
|
|
@ -45,5 +46,5 @@ class Visibility(Optimization):
|
||||||
with self.browser:
|
with self.browser:
|
||||||
self.browser.login()
|
self.browser.login()
|
||||||
except BrowserUnavailable as e:
|
except BrowserUnavailable as e:
|
||||||
print str(e)
|
print(str(e))
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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
|
||||||
|
|
@ -121,4 +122,4 @@ class AuthenticationPage(Page):
|
||||||
|
|
||||||
def print_cookies(self):
|
def print_cookies(self):
|
||||||
for c in self.browser._ua_handlers["_cookies"].cookiejar:
|
for c in self.browser._ua_handlers["_cookies"].cookiejar:
|
||||||
print "%s : %s" % (c.name, c.value)
|
print("%s : %s" % (c.name, c.value))
|
||||||
|
|
|
||||||
|
|
@ -17,6 +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 re
|
import re
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
|
|
@ -217,8 +219,8 @@ class CardsPage(Page):
|
||||||
try:
|
try:
|
||||||
t.id = t.unique_id(seen)
|
t.id = t.unique_id(seen)
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
print t
|
print(t)
|
||||||
print t.label
|
print(t.label)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
yield t
|
yield t
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,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
|
||||||
|
|
||||||
from weboob.tools.mech import ClientForm
|
from weboob.tools.mech import ClientForm
|
||||||
ControlNotFoundError = ClientForm.ControlNotFoundError
|
ControlNotFoundError = ClientForm.ControlNotFoundError
|
||||||
|
|
||||||
|
|
@ -73,7 +75,7 @@ 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
|
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,6 +18,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 urllib
|
import urllib
|
||||||
|
|
||||||
from weboob.tools.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\
|
from weboob.tools.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\
|
||||||
|
|
@ -149,7 +151,7 @@ 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()"
|
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,6 +18,7 @@
|
||||||
# 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
|
||||||
|
|
@ -85,7 +86,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'
|
print('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,6 +18,7 @@
|
||||||
# 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
|
||||||
|
|
||||||
|
|
@ -66,7 +67,7 @@ class AccountsList(Page):
|
||||||
l.append(account)
|
l.append(account)
|
||||||
|
|
||||||
if len(l) == 0:
|
if len(l) == 0:
|
||||||
print 'no accounts'
|
print('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,6 +17,7 @@
|
||||||
# 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
|
||||||
|
|
||||||
|
|
@ -100,7 +101,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
|
print(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,6 +17,7 @@
|
||||||
# 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
|
||||||
|
|
||||||
|
|
@ -133,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()
|
print(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,6 +18,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 re
|
import re
|
||||||
|
|
||||||
from weboob.browser2.page import JsonPage, HTMLPage, method
|
from weboob.browser2.page import JsonPage, HTMLPage, method
|
||||||
|
|
@ -142,7 +144,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
|
print(form)
|
||||||
form.submit()
|
form.submit()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,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 argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
import datetime
|
import datetime
|
||||||
|
|
@ -50,11 +52,11 @@ def write(target, contents):
|
||||||
if not os.path.isdir(os.path.dirname(target)):
|
if not os.path.isdir(os.path.dirname(target)):
|
||||||
os.makedirs(os.path.dirname(target))
|
os.makedirs(os.path.dirname(target))
|
||||||
if os.path.exists(target):
|
if os.path.exists(target):
|
||||||
print >>sys.stderr, "%s already exists." % target
|
print("%s already exists." % target, file=sys.stderr)
|
||||||
sys.exit(4)
|
sys.exit(4)
|
||||||
with codecs.open(target, mode='w', encoding='utf-8') as f:
|
with codecs.open(target, mode='w', encoding='utf-8') as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
print 'Created %s' % target
|
print('Created %s' % target)
|
||||||
|
|
||||||
|
|
||||||
class Recipe(object):
|
class Recipe(object):
|
||||||
|
|
@ -156,7 +158,7 @@ class CapRecipe(Recipe):
|
||||||
self.error('Capability %r not found' % self.capname)
|
self.error('Capability %r not found' % self.capname)
|
||||||
|
|
||||||
def error(self, message):
|
def error(self, message):
|
||||||
print >>sys.stderr, message
|
print(message, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def methods_code(self, klass):
|
def methods_code(self, klass):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
from weboob.tools.browser import StandardBrowser
|
from weboob.tools.browser import StandardBrowser
|
||||||
|
|
||||||
print StandardBrowser()._certhash(sys.argv[1])
|
print(StandardBrowser()._certhash(sys.argv[1]))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
@ -15,7 +16,7 @@ for root, dirs, files in os.walk(sys.argv[1]):
|
||||||
try:
|
try:
|
||||||
exec(s)
|
exec(s)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print >>sys.stderr, str(e)
|
print(str(e), file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
m = eval(f[:-3])
|
m = eval(f[:-3])
|
||||||
for attrname in dir(m):
|
for attrname in dir(m):
|
||||||
|
|
@ -36,7 +37,7 @@ for f in selection:
|
||||||
for line in p.stdout.readlines():
|
for line in p.stdout.readlines():
|
||||||
dependencies.add(line.strip().split(':')[0])
|
dependencies.add(line.strip().split(':')[0])
|
||||||
else:
|
else:
|
||||||
print 'not found: %s' % f
|
print('not found: %s' % f)
|
||||||
|
|
||||||
for d in dependencies:
|
for d in dependencies:
|
||||||
print d
|
print(d)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
@ -10,26 +12,26 @@ if '--deps' in sys.argv:
|
||||||
else:
|
else:
|
||||||
deps = ['--nodeps']
|
deps = ['--nodeps']
|
||||||
|
|
||||||
print "Weboob local installer"
|
print("Weboob local installer")
|
||||||
print
|
print()
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print "This tool will install Weboob to be usuable without requiring"
|
print("This tool will install Weboob to be usuable without requiring")
|
||||||
print "messing with your system, which should only be touched by a package manager."
|
print("messing with your system, which should only be touched by a package manager.")
|
||||||
print
|
print()
|
||||||
print "Usage: %s DESTINATION [OPTIONS]" % sys.argv[0]
|
print("Usage: %s DESTINATION [OPTIONS]" % sys.argv[0])
|
||||||
print
|
print()
|
||||||
print "By default, no dependencies are installed, as you should try"
|
print("By default, no dependencies are installed, as you should try")
|
||||||
print "to install them from your package manager as much as possible."
|
print("to install them from your package manager as much as possible.")
|
||||||
print "To install all the missing dependencies, add the option --deps"
|
print("To install all the missing dependencies, add the option --deps")
|
||||||
print "at the end of the command line."
|
print("at the end of the command line.")
|
||||||
print
|
print()
|
||||||
print >>sys.stderr, "Error: Please provide a destination, " \
|
print("Error: Please provide a destination, " \
|
||||||
"for example ‘%s/bin’" % os.getenv('HOME')
|
"for example ‘%s/bin’" % os.getenv('HOME'), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
dest = os.path.expanduser(sys.argv[1])
|
dest = os.path.expanduser(sys.argv[1])
|
||||||
|
|
||||||
print "Installing weboob applications into ‘%s’." % dest
|
print("Installing weboob applications into ‘%s’." % dest)
|
||||||
|
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[sys.executable, 'setup.py',
|
[sys.executable, 'setup.py',
|
||||||
|
|
@ -38,11 +40,11 @@ subprocess.check_call(
|
||||||
|
|
||||||
subprocess.check_call([sys.executable, os.path.join(dest, 'weboob-config'), 'update'])
|
subprocess.check_call([sys.executable, os.path.join(dest, 'weboob-config'), 'update'])
|
||||||
|
|
||||||
print
|
print()
|
||||||
print "Installation done. Applications are available in ‘%s’." % dest
|
print("Installation done. Applications are available in ‘%s’." % dest)
|
||||||
print "You can remove the source files."
|
print("You can remove the source files.")
|
||||||
print
|
print()
|
||||||
print "To have easy access to the Weboob applications,"
|
print("To have easy access to the Weboob applications,")
|
||||||
print "you should add the following line to your ~/.bashrc or ~/.zshrc file:"
|
print("you should add the following line to your ~/.bashrc or ~/.zshrc file:")
|
||||||
print "export PATH=\"$PATH:%s\"" % dest
|
print("export PATH=\"$PATH:%s\"" % dest)
|
||||||
print "And then restart your shells."
|
print("And then restart your shells.")
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print "Usage: %s SCRIPTNAME [args]" % sys.argv[0]
|
print("Usage: %s SCRIPTNAME [args]" % sys.argv[0])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
script = sys.argv[1]
|
script = sys.argv[1]
|
||||||
|
|
@ -37,7 +39,7 @@ p = subprocess.Popen(
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
s = p.communicate()
|
s = p.communicate()
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
print s[0]
|
print(s[0])
|
||||||
sys.exit(p.returncode)
|
sys.exit(p.returncode)
|
||||||
|
|
||||||
if os.path.exists(script):
|
if os.path.exists(script):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
# Copyright(C) 2010-2011 Laurent Bachelier
|
# Copyright(C) 2010-2011 Laurent Bachelier
|
||||||
#
|
#
|
||||||
|
|
@ -120,10 +121,10 @@ def main():
|
||||||
try:
|
try:
|
||||||
script = imp.load_module("scripts.%s" % fname, f, tmpfile, desc)
|
script = imp.load_module("scripts.%s" % fname, f, tmpfile, desc)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print >>sys.stderr, "Unable to load the %s script (%s)" \
|
print("Unable to load the %s script (%s)" \
|
||||||
% (fname, e)
|
% (fname, e), file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
print "Loaded %s" % fname
|
print("Loaded %s" % fname)
|
||||||
# Find the applications we can handle
|
# Find the applications we can handle
|
||||||
for klass in script.__dict__.itervalues():
|
for klass in script.__dict__.itervalues():
|
||||||
if inspect.isclass(klass) and issubclass(klass, Application):
|
if inspect.isclass(klass) and issubclass(klass, Application):
|
||||||
|
|
@ -227,7 +228,7 @@ For full COPYRIGHT see COPYING file with weboob package.
|
||||||
with open(os.path.join(BASE_PATH, DEST_DIR, "%s.1" % script_name), 'w+') as manfile:
|
with open(os.path.join(BASE_PATH, DEST_DIR, "%s.1" % script_name), 'w+') as manfile:
|
||||||
for line in mantext.split('\n'):
|
for line in mantext.split('\n'):
|
||||||
manfile.write('%s\n' % line.lstrip().encode('utf-8'))
|
manfile.write('%s\n' % line.lstrip().encode('utf-8'))
|
||||||
print "wrote %s/%s.1" % (DEST_DIR, script_name)
|
print("wrote %s/%s.1" % (DEST_DIR, script_name))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
@ -17,4 +19,4 @@ for dirpath, dirnames, filenames in os.walk(root):
|
||||||
if not os.path.exists(os.path.join(dirpath, filename[:-1])):
|
if not os.path.exists(os.path.join(dirpath, filename[:-1])):
|
||||||
os.unlink(os.path.join(dirpath, filename))
|
os.unlink(os.path.join(dirpath, filename))
|
||||||
if verbose:
|
if verbose:
|
||||||
print os.path.join(dirpath, filename)
|
print(os.path.join(dirpath, filename))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
# Hint: use this script with file:///path/to/local/modules/ in sources.list
|
# Hint: use this script with file:///path/to/local/modules/ in sources.list
|
||||||
# if you want to correctly check all modules.
|
# if you want to correctly check all modules.
|
||||||
|
|
@ -22,6 +23,6 @@ for name, backend in weboob.modules_loader.loaded.iteritems():
|
||||||
backends_without_icons.append(name)
|
backends_without_icons.append(name)
|
||||||
|
|
||||||
if backends_without_tests:
|
if backends_without_tests:
|
||||||
print 'Modules without tests: %s' % backends_without_tests
|
print('Modules without tests: %s' % backends_without_tests)
|
||||||
if backends_without_icons:
|
if backends_without_icons:
|
||||||
print 'Modules without icons: %s' % backends_without_icons
|
print('Modules without icons: %s' % backends_without_icons)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
import re
|
import re
|
||||||
|
|
@ -119,7 +120,7 @@ class Event(object):
|
||||||
elif line.startswith('h3=. '):
|
elif line.startswith('h3=. '):
|
||||||
m = re.match('h3=. Event finished. Winner is "(.*)":/users/(\d+)\!', line)
|
m = re.match('h3=. Event finished. Winner is "(.*)":/users/(\d+)\!', line)
|
||||||
if not m:
|
if not m:
|
||||||
print >>self.stderr, 'Unable to parse h3=: %s' % line
|
print('Unable to parse h3=: %s' % line, file=self.stderr)
|
||||||
continue
|
continue
|
||||||
self.winner = Member(int(m.group(2)), m.group(1))
|
self.winner = Member(int(m.group(2)), m.group(1))
|
||||||
elif line.startswith('h2. '):
|
elif line.startswith('h2. '):
|
||||||
|
|
@ -127,7 +128,7 @@ class Event(object):
|
||||||
elif line.startswith('h3. '):
|
elif line.startswith('h3. '):
|
||||||
m = re.match('h3. "(.*)":/users/(\d+)', line)
|
m = re.match('h3. "(.*)":/users/(\d+)', line)
|
||||||
if not m:
|
if not m:
|
||||||
print >>self.stderr, 'Unable to parse user "%s"' % line
|
print('Unable to parse user "%s"' % line, file=self.stderr)
|
||||||
continue
|
continue
|
||||||
member = Member(int(m.group(2)), m.group(1))
|
member = Member(int(m.group(2)), m.group(1))
|
||||||
if member.id == self.my_id:
|
if member.id == self.my_id:
|
||||||
|
|
@ -166,7 +167,7 @@ class Event(object):
|
||||||
elif line.startswith('[['):
|
elif line.startswith('[['):
|
||||||
m = re.match('\[\[(\w+)\]\]\|\[\[(\w+)\]\]\|(.*)\|', line)
|
m = re.match('\[\[(\w+)\]\]\|\[\[(\w+)\]\]\|(.*)\|', line)
|
||||||
if not m:
|
if not m:
|
||||||
print >>self.stderr, 'Unable to parse task: "%s"' % line
|
print('Unable to parse task: "%s"' % line, file=self.stderr)
|
||||||
continue
|
continue
|
||||||
task = Task(m.group(1), m.group(2))
|
task = Task(m.group(1), m.group(2))
|
||||||
member.tasks.append(task)
|
member.tasks.append(task)
|
||||||
|
|
@ -292,7 +293,7 @@ class Boobathon(ReplApplication):
|
||||||
|
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
if len(argv) < 2:
|
if len(argv) < 2:
|
||||||
print >>self.stderr, 'Please give the name of the boobathon'
|
print('Please give the name of the boobathon', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
self.event = Event(argv[1], choice(self.weboob.backend_instances.values()))
|
self.event = Event(argv[1], choice(self.weboob.backend_instances.values()))
|
||||||
|
|
@ -372,9 +373,9 @@ class Boobathon(ReplApplication):
|
||||||
else:
|
else:
|
||||||
s += ' '
|
s += ' '
|
||||||
s += '|%s' % self.NC
|
s += '|%s' % self.NC
|
||||||
print s
|
print(s)
|
||||||
|
|
||||||
print ''
|
print('')
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
if self.event.begin > now:
|
if self.event.begin > now:
|
||||||
d = self.event.begin - now
|
d = self.event.begin - now
|
||||||
|
|
@ -394,13 +395,13 @@ class Boobathon(ReplApplication):
|
||||||
progress += '>'
|
progress += '>'
|
||||||
else:
|
else:
|
||||||
progress += ' '
|
progress += ' '
|
||||||
print 'Event started: %s |%s| %s' % (self.event.begin.strftime('%H:%M'),
|
print('Event started: %s |%s| %s' % (self.event.begin.strftime('%H:%M'),
|
||||||
progress,
|
progress,
|
||||||
self.event.end.strftime('%H:%M'))
|
self.event.end.strftime('%H:%M')))
|
||||||
d = self.event.end - now
|
d = self.event.end - now
|
||||||
msg = 'The event will be finished in %d days, %02d:%02d:%02d'
|
msg = 'The event will be finished in %d days, %02d:%02d:%02d'
|
||||||
|
|
||||||
print msg % (d.days, d.seconds/3600, d.seconds%3600/60, d.seconds%60)
|
print(msg % (d.days, d.seconds/3600, d.seconds%3600/60, d.seconds%60))
|
||||||
|
|
||||||
def do_tasks(self, line):
|
def do_tasks(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -468,10 +469,10 @@ class Boobathon(ReplApplication):
|
||||||
if member.name == name:
|
if member.name == name:
|
||||||
self.event.winner = member
|
self.event.winner = member
|
||||||
if self.save_event('Close event'):
|
if self.save_event('Close event'):
|
||||||
print 'Event is now closed. Winner is %s!' % self.event.winner.name
|
print('Event is now closed. Winner is %s!' % self.event.winner.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
print >>self.stderr, '"%s" not found' % name
|
print('"%s" not found' % name, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
def complete_edit(self, text, line, *ignored):
|
def complete_edit(self, text, line, *ignored):
|
||||||
|
|
@ -486,7 +487,7 @@ class Boobathon(ReplApplication):
|
||||||
Edit information about you or about event.
|
Edit information about you or about event.
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'Syntax: edit [event | me]'
|
print('Syntax: edit [event | me]', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
self.event.load()
|
self.event.load()
|
||||||
|
|
@ -496,12 +497,12 @@ class Boobathon(ReplApplication):
|
||||||
elif line == 'me':
|
elif line == 'me':
|
||||||
mem = self.event.get_me()
|
mem = self.event.get_me()
|
||||||
if not mem:
|
if not mem:
|
||||||
print >>self.stderr, 'You haven\'t joined the event.'
|
print('You haven\'t joined the event.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
self.edit_member(mem)
|
self.edit_member(mem)
|
||||||
self.save_event('Member edited')
|
self.save_event('Member edited')
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'Unable to edit "%s"' % line
|
print('Unable to edit "%s"' % line, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def do_info(self, line):
|
def do_info(self, line):
|
||||||
|
|
@ -511,19 +512,19 @@ class Boobathon(ReplApplication):
|
||||||
Display information about this event.
|
Display information about this event.
|
||||||
"""
|
"""
|
||||||
self.event.load()
|
self.event.load()
|
||||||
print self.event.title
|
print(self.event.title)
|
||||||
print '-' * len(self.event.title)
|
print('-' * len(self.event.title))
|
||||||
print self.event.description
|
print(self.event.description)
|
||||||
print ''
|
print('')
|
||||||
print 'Date:', self.event.date.strftime('%Y-%m-%d') if self.event.date else 'Unknown'
|
print('Date:', self.event.date.strftime('%Y-%m-%d') if self.event.date else 'Unknown')
|
||||||
print 'Begin:', self.event.begin.strftime('%H:%M') if self.event.begin else 'Unknown'
|
print('Begin:', self.event.begin.strftime('%H:%M') if self.event.begin else 'Unknown')
|
||||||
print 'End:', self.event.end.strftime('%H:%M') if self.event.end else 'Unknown'
|
print('End:', self.event.end.strftime('%H:%M') if self.event.end else 'Unknown')
|
||||||
print 'Duration:', self.event.format_duration() or 'Unknown'
|
print('Duration:', self.event.format_duration() or 'Unknown')
|
||||||
print 'Location:', self.event.location or 'Unknown'
|
print('Location:', self.event.location or 'Unknown')
|
||||||
print ''
|
print('')
|
||||||
print 'There are %d members, use the "members" command to list them' % len(self.event.members)
|
print('There are %d members, use the "members" command to list them' % len(self.event.members))
|
||||||
if self.event.get_me() is None:
|
if self.event.get_me() is None:
|
||||||
print 'To join this event, use the command "join".'
|
print('To join this event, use the command "join".')
|
||||||
|
|
||||||
def do_members(self, line):
|
def do_members(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -533,22 +534,22 @@ class Boobathon(ReplApplication):
|
||||||
"""
|
"""
|
||||||
self.event.load()
|
self.event.load()
|
||||||
for member in self.event.members.itervalues():
|
for member in self.event.members.itervalues():
|
||||||
print member.name
|
print(member.name)
|
||||||
print '-' * len(member.name)
|
print('-' * len(member.name))
|
||||||
print 'Repository:', member.repository
|
print('Repository:', member.repository)
|
||||||
if self.event.date is None:
|
if self.event.date is None:
|
||||||
print 'Availabilities:', member.availabilities
|
print('Availabilities:', member.availabilities)
|
||||||
print 'Hardware:', member.hardware
|
print('Hardware:', member.hardware)
|
||||||
accompl = 0
|
accompl = 0
|
||||||
for task in member.tasks:
|
for task in member.tasks:
|
||||||
if task.status == task.STATUS_DONE:
|
if task.status == task.STATUS_DONE:
|
||||||
accompl += 1
|
accompl += 1
|
||||||
print '%d tasks (%d accomplished)' % (len(member.tasks), accompl)
|
print('%d tasks (%d accomplished)' % (len(member.tasks), accompl))
|
||||||
if member is self.event.winner:
|
if member is self.event.winner:
|
||||||
print '=== %s is the winner!' % member.name
|
print('=== %s is the winner!' % member.name)
|
||||||
print ''
|
print('')
|
||||||
|
|
||||||
print 'Use the "tasks" command to display all tasks'
|
print('Use the "tasks" command to display all tasks')
|
||||||
|
|
||||||
def do_join(self, line):
|
def do_join(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -558,11 +559,11 @@ class Boobathon(ReplApplication):
|
||||||
"""
|
"""
|
||||||
self.event.load()
|
self.event.load()
|
||||||
if self.event.backend.browser.get_userid() in self.event.members:
|
if self.event.backend.browser.get_userid() in self.event.members:
|
||||||
print >>self.stderr, 'You have already joined this event.'
|
print('You have already joined this event.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if self.event.is_closed():
|
if self.event.is_closed():
|
||||||
print >>self.stderr, "Boobathon is closed."
|
print("Boobathon is closed.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
m = Member(self.event.backend.browser.get_userid(), None)
|
m = Member(self.event.backend.browser.get_userid(), None)
|
||||||
|
|
@ -579,17 +580,17 @@ class Boobathon(ReplApplication):
|
||||||
self.event.load()
|
self.event.load()
|
||||||
|
|
||||||
if self.event.currently_in_event():
|
if self.event.currently_in_event():
|
||||||
print >>self.stderr, 'Unable to leave during the event, loser!'
|
print('Unable to leave during the event, loser!', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if self.event.is_closed():
|
if self.event.is_closed():
|
||||||
print >>self.stderr, "Boobathon is closed."
|
print("Boobathon is closed.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.event.members.pop(self.event.backend.browser.get_userid())
|
self.event.members.pop(self.event.backend.browser.get_userid())
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print >>self.stderr, "You have not joined this event."
|
print("You have not joined this event.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
self.save_event('Left the event')
|
self.save_event('Left the event')
|
||||||
|
|
@ -603,26 +604,26 @@ class Boobathon(ReplApplication):
|
||||||
self.event.load()
|
self.event.load()
|
||||||
mem = self.event.get_me()
|
mem = self.event.get_me()
|
||||||
if not mem:
|
if not mem:
|
||||||
print >>self.stderr, "You have not joined this event."
|
print("You have not joined this event.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if self.event.is_closed():
|
if self.event.is_closed():
|
||||||
print >>self.stderr, "Boobathon is closed."
|
print("Boobathon is closed.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
task_id = int(line)
|
task_id = int(line)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print >>self.stderr, 'The task ID should be a number'
|
print('The task ID should be a number', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
task = mem.tasks.pop(task_id)
|
task = mem.tasks.pop(task_id)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print >>self.stderr, 'Unable to find task #%d' % task_id
|
print('Unable to find task #%d' % task_id, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
print 'Removing task #%d (%s,%s).' % (task_id, task.backend, task.capability)
|
print('Removing task #%d (%s,%s).' % (task_id, task.backend, task.capability))
|
||||||
self.save_event('Remove task')
|
self.save_event('Remove task')
|
||||||
|
|
||||||
def do_addtask(self, line):
|
def do_addtask(self, line):
|
||||||
|
|
@ -634,24 +635,24 @@ class Boobathon(ReplApplication):
|
||||||
self.event.load()
|
self.event.load()
|
||||||
mem = self.event.get_me()
|
mem = self.event.get_me()
|
||||||
if not mem:
|
if not mem:
|
||||||
print >>self.stderr, "You have not joined this event."
|
print("You have not joined this event.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if self.event.is_closed():
|
if self.event.is_closed():
|
||||||
print >>self.stderr, "Boobathon is closed."
|
print("Boobathon is closed.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
backend, capability = self.parse_command_args(line, 2, 2)
|
backend, capability = self.parse_command_args(line, 2, 2)
|
||||||
if not backend[0].isupper():
|
if not backend[0].isupper():
|
||||||
print >>self.stderr, 'The backend name "%s" needs to start with a capital.' % backend
|
print('The backend name "%s" needs to start with a capital.' % backend, file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
if not capability.startswith('Cap') or not capability[3].isupper():
|
if not capability.startswith('Cap') or not capability[3].isupper():
|
||||||
print >>self.stderr, '"%s" is not a proper capability name (must start with Cap).' % capability
|
print('"%s" is not a proper capability name (must start with Cap).' % capability, file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
for task in mem.tasks:
|
for task in mem.tasks:
|
||||||
if (task.backend,task.capability) == (backend,capability):
|
if (task.backend,task.capability) == (backend,capability):
|
||||||
print >>self.stderr, "A task already exists for that."
|
print("A task already exists for that.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
task = Task(backend, capability)
|
task = Task(backend, capability)
|
||||||
|
|
@ -668,15 +669,15 @@ class Boobathon(ReplApplication):
|
||||||
self.event.load()
|
self.event.load()
|
||||||
mem = self.event.get_me()
|
mem = self.event.get_me()
|
||||||
if not mem:
|
if not mem:
|
||||||
print >>self.stderr, "You have not joined this event."
|
print("You have not joined this event.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if len(mem.tasks) == 0:
|
if len(mem.tasks) == 0:
|
||||||
print >>self.stderr, "You don't have any task to do."
|
print("You don't have any task to do.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if not self.event.currently_in_event():
|
if not self.event.currently_in_event():
|
||||||
print >>self.stderr, "You can't start a task, we are not in event."
|
print("You can't start a task, we are not in event.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if line.isdigit():
|
if line.isdigit():
|
||||||
|
|
@ -690,16 +691,16 @@ class Boobathon(ReplApplication):
|
||||||
last_done = i
|
last_done = i
|
||||||
elif task.status == task.STATUS_PROGRESS:
|
elif task.status == task.STATUS_PROGRESS:
|
||||||
task.status = task.STATUS_NONE
|
task.status = task.STATUS_NONE
|
||||||
print 'Task #%s (%s,%s) canceled.' % (i, task.backend, task.capability)
|
print('Task #%s (%s,%s) canceled.' % (i, task.backend, task.capability))
|
||||||
|
|
||||||
if (i == task_id or task_id < 0) and task.status == task.STATUS_NONE:
|
if (i == task_id or task_id < 0) and task.status == task.STATUS_NONE:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'Task not found.'
|
print('Task not found.', file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if task.status == task.STATUS_DONE:
|
if task.status == task.STATUS_DONE:
|
||||||
print >>self.stderr, 'Task is already done.'
|
print('Task is already done.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
task.status = task.STATUS_PROGRESS
|
task.status = task.STATUS_PROGRESS
|
||||||
|
|
@ -716,16 +717,16 @@ class Boobathon(ReplApplication):
|
||||||
self.event.load()
|
self.event.load()
|
||||||
mem = self.event.get_me()
|
mem = self.event.get_me()
|
||||||
if not mem:
|
if not mem:
|
||||||
print >>self.stderr, "You have not joined this event."
|
print("You have not joined this event.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if self.event.is_closed():
|
if self.event.is_closed():
|
||||||
print >>self.stderr, "Boobathon is closed."
|
print("Boobathon is closed.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for i, task in enumerate(mem.tasks):
|
for i, task in enumerate(mem.tasks):
|
||||||
if task.status == task.STATUS_PROGRESS:
|
if task.status == task.STATUS_PROGRESS:
|
||||||
print 'Task (%s,%s) done! (%d%%)' % (task.backend, task.capability, (i+1)*100/len(mem.tasks))
|
print('Task (%s,%s) done! (%d%%)' % (task.backend, task.capability, (i+1)*100/len(mem.tasks)))
|
||||||
if self.event.currently_in_event():
|
if self.event.currently_in_event():
|
||||||
task.status = task.STATUS_DONE
|
task.status = task.STATUS_DONE
|
||||||
task.date = datetime.now()
|
task.date = datetime.now()
|
||||||
|
|
@ -733,12 +734,12 @@ class Boobathon(ReplApplication):
|
||||||
self.save_event('Task accomplished')
|
self.save_event('Task accomplished')
|
||||||
else:
|
else:
|
||||||
task.status = task.STATUS_NONE
|
task.status = task.STATUS_NONE
|
||||||
print >>self.stderr, 'Oops, you are out of event. Canceling the task...'
|
print('Oops, you are out of event. Canceling the task...', file=self.stderr)
|
||||||
self.save_event('Cancel task')
|
self.save_event('Cancel task')
|
||||||
return 1
|
return 1
|
||||||
return
|
return
|
||||||
|
|
||||||
print >>self.stderr, "There isn't any task in progress."
|
print("There isn't any task in progress.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def do_cancel(self, line):
|
def do_cancel(self, line):
|
||||||
|
|
@ -750,21 +751,21 @@ class Boobathon(ReplApplication):
|
||||||
self.event.load()
|
self.event.load()
|
||||||
mem = self.event.get_me()
|
mem = self.event.get_me()
|
||||||
if not mem:
|
if not mem:
|
||||||
print >>self.stderr, "You have not joined this event."
|
print("You have not joined this event.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if self.event.is_closed():
|
if self.event.is_closed():
|
||||||
print >>self.stderr, "Boobathon is closed."
|
print("Boobathon is closed.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for task in mem.tasks:
|
for task in mem.tasks:
|
||||||
if task.status == task.STATUS_PROGRESS:
|
if task.status == task.STATUS_PROGRESS:
|
||||||
print 'Task (%s,%s) canceled.' % (task.backend, task.capability)
|
print('Task (%s,%s) canceled.' % (task.backend, task.capability))
|
||||||
task.status = task.STATUS_NONE
|
task.status = task.STATUS_NONE
|
||||||
self.save_event('Cancel task')
|
self.save_event('Cancel task')
|
||||||
return
|
return
|
||||||
|
|
||||||
print >>self.stderr, "There isn't any task in progress."
|
print("There isn't any task in progress.", file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def load_default_backends(self):
|
def load_default_backends(self):
|
||||||
|
|
@ -780,7 +781,7 @@ class Boobathon(ReplApplication):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.check_loaded_backends({'url': 'https://symlink.me'}):
|
if not self.check_loaded_backends({'url': 'https://symlink.me'}):
|
||||||
print "Ok, so leave now, fag."
|
print("Ok, so leave now, fag.")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def is_module_loadable(self, module):
|
def is_module_loadable(self, module):
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright(C) 2013 Bezleputh
|
# Copyright(C) 2013 Bezleputh
|
||||||
|
|
|
||||||
|
|
@ -17,6 +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
|
||||||
|
|
||||||
from datetime import time, datetime
|
from datetime import time, datetime
|
||||||
|
|
||||||
from weboob.tools.date import parse_date
|
from weboob.tools.date import parse_date
|
||||||
|
|
@ -178,10 +180,10 @@ class Boobcoming(ReplApplication):
|
||||||
r = 'notempty'
|
r = 'notempty'
|
||||||
while r != '':
|
while r != '':
|
||||||
for category in CATEGORIES.values:
|
for category in CATEGORIES.values:
|
||||||
print ' %s%2d)%s [%s] %s' % (self.BOLD,
|
print(' %s%2d)%s [%s] %s' % (self.BOLD,
|
||||||
CATEGORIES.index[category] + 1,
|
CATEGORIES.index[category] + 1,
|
||||||
self.NC,
|
self.NC,
|
||||||
'x' if category in query.categories else ' ', category)
|
'x' if category in query.categories else ' ', category))
|
||||||
r = self.ask(' Select category (or empty to stop)', regexp='(\d+|)', default='')
|
r = self.ask(' Select category (or empty to stop)', regexp='(\d+|)', default='')
|
||||||
if not r.isdigit():
|
if not r.isdigit():
|
||||||
continue
|
continue
|
||||||
|
|
@ -230,7 +232,7 @@ class Boobcoming(ReplApplication):
|
||||||
if line:
|
if line:
|
||||||
_date = parse_date(line)
|
_date = parse_date(line)
|
||||||
if not _date:
|
if not _date:
|
||||||
print >>self.stderr, 'Invalid argument: %s' % self.get_command_help('list')
|
print('Invalid argument: %s' % self.get_command_help('list'), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
date_from = datetime.combine(_date, time.min)
|
date_from = datetime.combine(_date, time.min)
|
||||||
|
|
@ -255,13 +257,13 @@ class Boobcoming(ReplApplication):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not _id:
|
if not _id:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
event = self.get_object(_id, 'get_event')
|
event = self.get_object(_id, 'get_event')
|
||||||
|
|
||||||
if not event:
|
if not event:
|
||||||
print >>self.stderr, 'Upcoming event not found: %s' % _id
|
print('Upcoming event not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
@ -278,7 +280,7 @@ class Boobcoming(ReplApplication):
|
||||||
Export event in ICALENDAR format
|
Export event in ICALENDAR format
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'This command takes at leat one argument: %s' % self.get_command_help('export')
|
print('This command takes at leat one argument: %s' % self.get_command_help('export'), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
_file, args = self.parse_command_args(line, 2, req_n=1)
|
_file, args = self.parse_command_args(line, 2, req_n=1)
|
||||||
|
|
@ -306,7 +308,7 @@ class Boobcoming(ReplApplication):
|
||||||
event = self.get_object(_id, 'get_event')
|
event = self.get_object(_id, 'get_event')
|
||||||
|
|
||||||
if not event:
|
if not event:
|
||||||
print >>self.stderr, 'Upcoming event not found: %s' % _id
|
print('Upcoming event not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
l.append(event)
|
l.append(event)
|
||||||
|
|
@ -328,7 +330,7 @@ class Boobcoming(ReplApplication):
|
||||||
ID is the identifier of the event.
|
ID is the identifier of the event.
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'This command takes at leat one argument: %s' % self.get_command_help('attends')
|
print('This command takes at leat one argument: %s' % self.get_command_help('attends'), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
args = self.parse_command_args(line, 1, req_n=1)
|
args = self.parse_command_args(line, 1, req_n=1)
|
||||||
|
|
@ -346,7 +348,7 @@ class Boobcoming(ReplApplication):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'This command takes at leat one argument: %s' % self.get_command_help('unattends')
|
print('This command takes at leat one argument: %s' % self.get_command_help('unattends'), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
args = self.parse_command_args(line, 1, req_n=1)
|
args = self.parse_command_args(line, 1, req_n=1)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
|
||||||
|
|
||||||
# Copyright(C) 2011 Laurent Bachelier
|
# Copyright(C) 2011 Laurent Bachelier
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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
|
||||||
|
|
||||||
|
|
@ -86,9 +87,9 @@ class Boobill(ReplApplication):
|
||||||
self.bcall_error_handler(backend, error, backtrace)
|
self.bcall_error_handler(backend, error, backtrace)
|
||||||
|
|
||||||
if len(more_results) > 0:
|
if len(more_results) > 0:
|
||||||
print >>self.stderr, 'Hint: There are more results available for %s (use option -n or count command)' % (', '.join(more_results))
|
print('Hint: There are more results available for %s (use option -n or count command)' % (', '.join(more_results)), file=self.stderr)
|
||||||
for backend in not_implemented:
|
for backend in not_implemented:
|
||||||
print >>self.stderr, u'Error(%s): This feature is not supported yet by this backend.' % backend.name
|
print(u'Error(%s): This feature is not supported yet by this backend.' % backend.name, file=self.stderr)
|
||||||
|
|
||||||
def do_subscriptions(self, line):
|
def do_subscriptions(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -183,7 +184,7 @@ class Boobill(ReplApplication):
|
||||||
id, dest = self.parse_command_args(line, 2, 1)
|
id, dest = self.parse_command_args(line, 2, 1)
|
||||||
id, backend_name = self.parse_id(id)
|
id, backend_name = self.parse_id(id)
|
||||||
if not id:
|
if not id:
|
||||||
print >>self.stderr, 'Error: please give a bill ID (hint: use bills command)'
|
print('Error: please give a bill ID (hint: use bills command)', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
names = (backend_name,) if backend_name is not None else None
|
names = (backend_name,) if backend_name is not None else None
|
||||||
|
|
@ -204,13 +205,13 @@ class Boobill(ReplApplication):
|
||||||
for backend, buf in self.do('download_bill', id, backends=names):
|
for backend, buf in self.do('download_bill', id, backends=names):
|
||||||
if buf:
|
if buf:
|
||||||
if dest == "-":
|
if dest == "-":
|
||||||
print buf
|
print(buf)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(dest, 'w') as f:
|
with open(dest, 'w') as f:
|
||||||
f.write(buf)
|
f.write(buf)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write bill in "%s": %s' % (dest, e)
|
print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -221,13 +222,13 @@ class Boobill(ReplApplication):
|
||||||
for backend2, buf in self.do('download_bill', bill.id, backends=names):
|
for backend2, buf in self.do('download_bill', bill.id, backends=names):
|
||||||
if buf:
|
if buf:
|
||||||
if dest == "-":
|
if dest == "-":
|
||||||
print buf
|
print(buf)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(dest, 'w') as f:
|
with open(dest, 'w') as f:
|
||||||
f.write(buf)
|
f.write(buf)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write bill in "%s": %s' % (dest, e)
|
print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@
|
||||||
# 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.capabilities.lyrics import CapLyrics
|
from weboob.capabilities.lyrics import CapLyrics
|
||||||
from weboob.capabilities.base import empty
|
from weboob.capabilities.base import empty
|
||||||
|
|
@ -84,7 +83,7 @@ class Booblyrics(ReplApplication):
|
||||||
|
|
||||||
songlyrics = self.get_object(id, 'get_lyrics')
|
songlyrics = self.get_object(id, 'get_lyrics')
|
||||||
if not songlyrics:
|
if not songlyrics:
|
||||||
print >>self.stderr, 'Song lyrics not found: %s' % id
|
print('Song lyrics not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
|
|
@ -288,14 +289,14 @@ class Boobmsg(ReplApplication):
|
||||||
results[backend.name] = [field]
|
results[backend.name] = [field]
|
||||||
|
|
||||||
for name, fields in results.iteritems():
|
for name, fields in results.iteritems():
|
||||||
print ':: %s ::' % name
|
print(':: %s ::' % name)
|
||||||
for f in fields:
|
for f in fields:
|
||||||
if f.flags & f.FIELD_HTML:
|
if f.flags & f.FIELD_HTML:
|
||||||
value = html2text(f.value)
|
value = html2text(f.value)
|
||||||
else:
|
else:
|
||||||
value = f.value
|
value = f.value
|
||||||
print '%s: %s' % (f.label, value)
|
print('%s: %s' % (f.label, value))
|
||||||
print ''
|
print('')
|
||||||
|
|
||||||
def do_post(self, line):
|
def do_post(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -347,7 +348,7 @@ class Boobmsg(ReplApplication):
|
||||||
self.bcall_errors_handler(errors)
|
self.bcall_errors_handler(errors)
|
||||||
else:
|
else:
|
||||||
if self.interactive:
|
if self.interactive:
|
||||||
print 'Message sent sucessfully to %s' % receiver
|
print('Message sent sucessfully to %s' % receiver)
|
||||||
|
|
||||||
threads = []
|
threads = []
|
||||||
messages = []
|
messages = []
|
||||||
|
|
@ -430,7 +431,7 @@ class Boobmsg(ReplApplication):
|
||||||
"""
|
"""
|
||||||
message = None
|
message = None
|
||||||
if len(arg) == 0:
|
if len(arg) == 0:
|
||||||
print >>self.stderr, 'Please give a message ID.'
|
print('Please give a message ID.', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -447,7 +448,7 @@ class Boobmsg(ReplApplication):
|
||||||
self.weboob.do('set_message_read', message, backends=message.backend)
|
self.weboob.do('set_message_read', message, backends=message.backend)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'Message not found'
|
print('Message not found', file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
def do_profile(self, id):
|
def do_profile(self, id):
|
||||||
|
|
@ -475,7 +476,7 @@ class Boobmsg(ReplApplication):
|
||||||
"""
|
"""
|
||||||
photo_cmd = self.config.get('photo_viewer')
|
photo_cmd = self.config.get('photo_viewer')
|
||||||
if photo_cmd is None:
|
if photo_cmd is None:
|
||||||
print >>self.stderr, "Configuration error: photo_viewer is undefined"
|
print("Configuration error: photo_viewer is undefined", file=self.stderr)
|
||||||
return
|
return
|
||||||
|
|
||||||
_id, backend_name = self.parse_id(id, unique_backend=True)
|
_id, backend_name = self.parse_id(id, unique_backend=True)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +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
|
||||||
|
|
||||||
from weboob.capabilities.library import CapBook, Book
|
from weboob.capabilities.library import CapBook, Book
|
||||||
from weboob.tools.application.repl import ReplApplication
|
from weboob.tools.application.repl import ReplApplication
|
||||||
from weboob.tools.application.formatters.iformatter import PrettyFormatter
|
from weboob.tools.application.formatters.iformatter import PrettyFormatter
|
||||||
|
|
@ -62,7 +64,7 @@ class Boobooks(ReplApplication):
|
||||||
|
|
||||||
id, backend_name = self.parse_id(id)
|
id, backend_name = self.parse_id(id)
|
||||||
if not id:
|
if not id:
|
||||||
print >>self.stderr, 'Error: please give a book ID (hint: use ls command)'
|
print('Error: please give a book ID (hint: use ls command)', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
names = (backend_name,) if backend_name is not None else None
|
names = (backend_name,) if backend_name is not None else None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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.capabilities.base import empty
|
from weboob.capabilities.base import empty
|
||||||
from weboob.capabilities.gauge import CapGauge, SensorNotFound
|
from weboob.capabilities.gauge import CapGauge, SensorNotFound
|
||||||
|
|
@ -110,7 +111,7 @@ class Boobsize(ReplApplication):
|
||||||
def bcall_error_handler(self, backend, error, backtrace):
|
def bcall_error_handler(self, backend, error, backtrace):
|
||||||
if isinstance(error, SensorNotFound):
|
if isinstance(error, SensorNotFound):
|
||||||
msg = unicode(error) or 'Sensor not found (hint: try details command)'
|
msg = unicode(error) or 'Sensor not found (hint: try details command)'
|
||||||
print >>self.stderr, 'Error(%s): %s' % (backend.name, msg)
|
print('Error(%s): %s' % (backend.name, msg), file=self.stderr)
|
||||||
else:
|
else:
|
||||||
return ReplApplication.bcall_error_handler(self, backend, error, backtrace)
|
return ReplApplication.bcall_error_handler(self, backend, error, backtrace)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 datetime import timedelta
|
from datetime import timedelta
|
||||||
from email import message_from_string, message_from_file
|
from email import message_from_string, message_from_file
|
||||||
|
|
@ -156,7 +157,7 @@ class BoobTracker(ReplApplication):
|
||||||
elif len(path) > 0:
|
elif len(path) > 0:
|
||||||
query.project = path[0]
|
query.project = path[0]
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'Please enter a project name'
|
print('Please enter a project name', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
query.author = self.options.author
|
query.author = self.options.author
|
||||||
|
|
@ -183,12 +184,12 @@ class BoobTracker(ReplApplication):
|
||||||
Get an issue and display it.
|
Get an issue and display it.
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('get', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('get', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
issue = self.get_object(line, 'get_issue')
|
issue = self.get_object(line, 'get_issue')
|
||||||
if not issue:
|
if not issue:
|
||||||
print >>self.stderr, 'Issue not found: %s' % line
|
print('Issue not found: %s' % line, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
self.format(issue)
|
self.format(issue)
|
||||||
|
|
||||||
|
|
@ -226,7 +227,7 @@ class BoobTracker(ReplApplication):
|
||||||
try:
|
try:
|
||||||
hours = float(hours)
|
hours = float(hours)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print >>self.stderr, 'Error: HOURS parameter may be a float'
|
print('Error: HOURS parameter may be a float', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
id, backend_name = self.parse_id(id, unique_backend=True)
|
id, backend_name = self.parse_id(id, unique_backend=True)
|
||||||
|
|
@ -398,8 +399,8 @@ class BoobTracker(ReplApplication):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
issue = backend.post_issue(issue)
|
issue = backend.post_issue(issue)
|
||||||
print 'Issue %s %s' % (self.formatter.colored(issue.fullid, 'red', 'bold'),
|
print('Issue %s %s' % (self.formatter.colored(issue.fullid, 'red', 'bold'),
|
||||||
'updated' if edit else 'created')
|
'updated' if edit else 'created'))
|
||||||
if edit:
|
if edit:
|
||||||
self.format(issue)
|
self.format(issue)
|
||||||
elif email_to:
|
elif email_to:
|
||||||
|
|
@ -447,7 +448,7 @@ Weboob Team
|
||||||
--status STATUS
|
--status STATUS
|
||||||
"""
|
"""
|
||||||
if not line.strip():
|
if not line.strip():
|
||||||
print 'Please give the project name'
|
print('Please give the project name')
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
project, backend_name = self.parse_id(line, unique_backend=True)
|
project, backend_name = self.parse_id(line, unique_backend=True)
|
||||||
|
|
@ -481,7 +482,7 @@ Weboob Team
|
||||||
_id, key, value = self.parse_command_args(line, 3, 1)
|
_id, key, value = self.parse_command_args(line, 3, 1)
|
||||||
issue = self.get_object(_id, 'get_issue')
|
issue = self.get_object(_id, 'get_issue')
|
||||||
if not issue:
|
if not issue:
|
||||||
print >>self.stderr, 'Issue not found: %s' % _id
|
print('Issue not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
return self.edit_issue(issue, edit=True)
|
return self.edit_issue(issue, edit=True)
|
||||||
|
|
@ -499,4 +500,4 @@ Weboob Team
|
||||||
|
|
||||||
Attach a file to an issue (Not implemented yet).
|
Attach a file to an issue (Not implemented yet).
|
||||||
"""
|
"""
|
||||||
print >>self.stderr, 'Not implemented yet.'
|
print('Not implemented yet.', file=self.stderr)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# 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 datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
@ -230,11 +230,11 @@ class Cineoob(ReplApplication):
|
||||||
|
|
||||||
person1 = self.get_object(id1, 'get_person', caps=CapCinema)
|
person1 = self.get_object(id1, 'get_person', caps=CapCinema)
|
||||||
if not person1:
|
if not person1:
|
||||||
print >>self.stderr, 'Person not found: %s' % id1
|
print('Person not found: %s' % id1, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
person2 = self.get_object(id2, 'get_person', caps=CapCinema)
|
person2 = self.get_object(id2, 'get_person', caps=CapCinema)
|
||||||
if not person2:
|
if not person2:
|
||||||
print >>self.stderr, 'Person not found: %s' % id2
|
print('Person not found: %s' % id2, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
initial_count = self.options.count
|
initial_count = self.options.count
|
||||||
|
|
@ -263,11 +263,11 @@ class Cineoob(ReplApplication):
|
||||||
|
|
||||||
movie1 = self.get_object(id1, 'get_movie', caps=CapCinema)
|
movie1 = self.get_object(id1, 'get_movie', caps=CapCinema)
|
||||||
if not movie1:
|
if not movie1:
|
||||||
print >>self.stderr, 'Movie not found: %s' % id1
|
print('Movie not found: %s' % id1, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
movie2 = self.get_object(id2, 'get_movie', caps=CapCinema)
|
movie2 = self.get_object(id2, 'get_movie', caps=CapCinema)
|
||||||
if not movie2:
|
if not movie2:
|
||||||
print >>self.stderr, 'Movie not found: %s' % id2
|
print('Movie not found: %s' % id2, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
initial_count = self.options.count
|
initial_count = self.options.count
|
||||||
|
|
@ -294,7 +294,7 @@ class Cineoob(ReplApplication):
|
||||||
movie = self.get_object(id, 'get_movie', caps=CapCinema)
|
movie = self.get_object(id, 'get_movie', caps=CapCinema)
|
||||||
|
|
||||||
if not movie:
|
if not movie:
|
||||||
print >>self.stderr, 'Movie not found: %s' % id
|
print('Movie not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
@ -309,7 +309,7 @@ class Cineoob(ReplApplication):
|
||||||
person = self.get_object(id, 'get_person', caps=CapCinema)
|
person = self.get_object(id, 'get_person', caps=CapCinema)
|
||||||
|
|
||||||
if not person:
|
if not person:
|
||||||
print >>self.stderr, 'Person not found: %s' % id
|
print('Person not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
@ -356,7 +356,7 @@ class Cineoob(ReplApplication):
|
||||||
|
|
||||||
movie = self.get_object(movie_id, 'get_movie', caps=CapCinema)
|
movie = self.get_object(movie_id, 'get_movie', caps=CapCinema)
|
||||||
if not movie:
|
if not movie:
|
||||||
print >>self.stderr, 'Movie not found: %s' % id
|
print('Movie not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
for backend, person in self.do('iter_movie_persons', movie.id, role, backends=movie.backend, caps=CapCinema):
|
for backend, person in self.do('iter_movie_persons', movie.id, role, backends=movie.backend, caps=CapCinema):
|
||||||
|
|
@ -373,7 +373,7 @@ class Cineoob(ReplApplication):
|
||||||
|
|
||||||
person = self.get_object(person_id, 'get_person', caps=CapCinema)
|
person = self.get_object(person_id, 'get_person', caps=CapCinema)
|
||||||
if not person:
|
if not person:
|
||||||
print >>self.stderr, 'Person not found: %s' % id
|
print('Person not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
for backend, movie in self.do('iter_person_movies', person.id, role, backends=person.backend, caps=CapCinema):
|
for backend, movie in self.do('iter_person_movies', person.id, role, backends=person.backend, caps=CapCinema):
|
||||||
|
|
@ -387,7 +387,7 @@ class Cineoob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
person = self.get_object(person_id, 'get_person', ('name', 'biography'), caps=CapCinema)
|
person = self.get_object(person_id, 'get_person', ('name', 'biography'), caps=CapCinema)
|
||||||
if not person:
|
if not person:
|
||||||
print >>self.stderr, 'Person not found: %s' % person_id
|
print('Person not found: %s' % person_id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
@ -411,7 +411,7 @@ class Cineoob(ReplApplication):
|
||||||
|
|
||||||
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
|
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
|
||||||
if not movie:
|
if not movie:
|
||||||
print >>self.stderr, 'Movie not found: %s' % id
|
print('Movie not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
# i would like to clarify with fillobj but how could i fill the movie AND choose the country ?
|
# i would like to clarify with fillobj but how could i fill the movie AND choose the country ?
|
||||||
|
|
@ -419,7 +419,7 @@ class Cineoob(ReplApplication):
|
||||||
if not empty(release):
|
if not empty(release):
|
||||||
movie.all_release_dates = u'%s' % (release)
|
movie.all_release_dates = u'%s' % (release)
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'Movie releases not found for %s' % movie.original_title
|
print('Movie releases not found for %s' % movie.original_title, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
self.start_format()
|
self.start_format()
|
||||||
self.format(movie)
|
self.format(movie)
|
||||||
|
|
@ -440,7 +440,7 @@ class Cineoob(ReplApplication):
|
||||||
|
|
||||||
torrent = self.get_object(id, 'get_torrent', caps=CapTorrent)
|
torrent = self.get_object(id, 'get_torrent', caps=CapTorrent)
|
||||||
if not torrent:
|
if not torrent:
|
||||||
print >>self.stderr, 'Torrent not found: %s' % id
|
print('Torrent not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
@ -472,26 +472,26 @@ class Cineoob(ReplApplication):
|
||||||
for backend, buf in self.do('get_torrent_file', _id, backends=backend_name, caps=CapTorrent):
|
for backend, buf in self.do('get_torrent_file', _id, backends=backend_name, caps=CapTorrent):
|
||||||
if buf:
|
if buf:
|
||||||
if dest == '-':
|
if dest == '-':
|
||||||
print buf
|
print(buf)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(dest, 'w') as f:
|
with open(dest, 'w') as f:
|
||||||
f.write(buf)
|
f.write(buf)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write .torrent in "%s": %s' % (dest, e)
|
print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
return
|
return
|
||||||
except CallErrors as errors:
|
except CallErrors as errors:
|
||||||
for backend, error, backtrace in errors:
|
for backend, error, backtrace in errors:
|
||||||
if isinstance(error, MagnetOnly):
|
if isinstance(error, MagnetOnly):
|
||||||
print >>self.stderr, u'Error(%s): No direct URL available, ' \
|
print(u'Error(%s): No direct URL available, ' \
|
||||||
u'please provide this magnet URL ' \
|
u'please provide this magnet URL ' \
|
||||||
u'to your client:\n%s' % (backend, error.magnet)
|
u'to your client:\n%s' % (backend, error.magnet), file=self.stderr)
|
||||||
return 4
|
return 4
|
||||||
else:
|
else:
|
||||||
self.bcall_error_handler(backend, error, backtrace)
|
self.bcall_error_handler(backend, error, backtrace)
|
||||||
|
|
||||||
print >>self.stderr, 'Torrent "%s" not found' % id
|
print('Torrent "%s" not found' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
@defaultcount(10)
|
@defaultcount(10)
|
||||||
|
|
@ -518,7 +518,7 @@ class Cineoob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
|
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
|
||||||
if not movie:
|
if not movie:
|
||||||
print >>self.stderr, 'Movie not found: %s' % id
|
print('Movie not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
pattern = movie.original_title
|
pattern = movie.original_title
|
||||||
|
|
@ -547,7 +547,7 @@ class Cineoob(ReplApplication):
|
||||||
|
|
||||||
subtitle = self.get_object(id, 'get_subtitle', caps=CapCinema)
|
subtitle = self.get_object(id, 'get_subtitle', caps=CapCinema)
|
||||||
if not subtitle:
|
if not subtitle:
|
||||||
print >>self.stderr, 'Subtitle not found: %s' % id
|
print('Subtitle not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
@ -578,17 +578,17 @@ class Cineoob(ReplApplication):
|
||||||
for backend, buf in self.do('get_subtitle_file', _id, backends=backend_name, caps=CapSubtitle):
|
for backend, buf in self.do('get_subtitle_file', _id, backends=backend_name, caps=CapSubtitle):
|
||||||
if buf:
|
if buf:
|
||||||
if dest == '-':
|
if dest == '-':
|
||||||
print buf
|
print(buf)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(dest, 'w') as f:
|
with open(dest, 'w') as f:
|
||||||
f.write(buf)
|
f.write(buf)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write file in "%s": %s' % (dest, e)
|
print('Unable to write file in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
return
|
return
|
||||||
|
|
||||||
print >>self.stderr, 'Subtitle "%s" not found' % id
|
print('Subtitle "%s" not found' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
@defaultcount(10)
|
@defaultcount(10)
|
||||||
|
|
@ -657,7 +657,7 @@ class Cineoob(ReplApplication):
|
||||||
language, id = self.parse_command_args(line, 2, 2)
|
language, id = self.parse_command_args(line, 2, 2)
|
||||||
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
|
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
|
||||||
if not movie:
|
if not movie:
|
||||||
print >>self.stderr, 'Movie not found: %s' % id
|
print('Movie not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
pattern = movie.original_title
|
pattern = movie.original_title
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
|
||||||
|
|
||||||
|
|
||||||
from .comparoob import Comparoob
|
from .comparoob import Comparoob
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,7 @@
|
||||||
# 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.capabilities.pricecomparison import CapPriceComparison
|
from weboob.capabilities.pricecomparison import CapPriceComparison
|
||||||
from weboob.tools.html import html2text
|
from weboob.tools.html import html2text
|
||||||
|
|
@ -108,18 +106,18 @@ class Comparoob(ReplApplication):
|
||||||
|
|
||||||
product = None
|
product = None
|
||||||
if len(products) == 0:
|
if len(products) == 0:
|
||||||
print >>self.stderr, 'Error: no product found with this pattern'
|
print('Error: no product found with this pattern', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
elif len(products) == 1:
|
elif len(products) == 1:
|
||||||
product = products[0]
|
product = products[0]
|
||||||
else:
|
else:
|
||||||
print 'What product do you want to compare?'
|
print('What product do you want to compare?')
|
||||||
for i, p in enumerate(products):
|
for i, p in enumerate(products):
|
||||||
print ' %s%2d)%s %s' % (self.BOLD, i+1, self.NC, p.name)
|
print(' %s%2d)%s %s' % (self.BOLD, i+1, self.NC, p.name))
|
||||||
r = int(self.ask(' Select a product', regexp='\d+'))
|
r = int(self.ask(' Select a product', regexp='\d+'))
|
||||||
while product is None:
|
while product is None:
|
||||||
if r <= 0 or r > len(products):
|
if r <= 0 or r > len(products):
|
||||||
print 'Error: Please enter a valid ID'
|
print('Error: Please enter a valid ID')
|
||||||
continue
|
continue
|
||||||
product = products[r-1]
|
product = products[r-1]
|
||||||
|
|
||||||
|
|
@ -146,12 +144,12 @@ class Comparoob(ReplApplication):
|
||||||
Get information about a product.
|
Get information about a product.
|
||||||
"""
|
"""
|
||||||
if not _id:
|
if not _id:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
price = self.get_object(_id, 'get_price')
|
price = self.get_object(_id, 'get_price')
|
||||||
if not price:
|
if not price:
|
||||||
print >>self.stderr, 'Price not found: %s' % _id
|
print('Price not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# 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 codecs
|
import codecs
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ class Cookboob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
recipe = self.get_object(id, 'get_recipe')
|
recipe = self.get_object(id, 'get_recipe')
|
||||||
if not recipe:
|
if not recipe:
|
||||||
print >>self.stderr, 'Recipe not found: %s' % id
|
print('Recipe not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
@ -132,7 +132,7 @@ class Cookboob(ReplApplication):
|
||||||
if recipe:
|
if recipe:
|
||||||
xmlstring = recipe.toKrecipesXml(backend_name or None)
|
xmlstring = recipe.toKrecipesXml(backend_name or None)
|
||||||
if dest == '-':
|
if dest == '-':
|
||||||
print xmlstring
|
print(xmlstring)
|
||||||
else:
|
else:
|
||||||
if not dest.endswith('.kreml'):
|
if not dest.endswith('.kreml'):
|
||||||
dest += '.kreml'
|
dest += '.kreml'
|
||||||
|
|
@ -140,10 +140,10 @@ class Cookboob(ReplApplication):
|
||||||
with codecs.open(dest, 'w', 'utf-8') as f:
|
with codecs.open(dest, 'w', 'utf-8') as f:
|
||||||
f.write(xmlstring)
|
f.write(xmlstring)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write .kreml in "%s": %s' % (dest, e)
|
print('Unable to write .kreml in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
return
|
return
|
||||||
print >>self.stderr, 'Recipe "%s" not found' % id
|
print('Recipe "%s" not found' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
@defaultcount(10)
|
@defaultcount(10)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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.capabilities.housing import CapHousing, Query
|
from weboob.capabilities.housing import CapHousing, Query
|
||||||
from weboob.tools.application.repl import ReplApplication, defaultcount
|
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||||
|
|
@ -104,7 +105,7 @@ class Flatboob(ReplApplication):
|
||||||
query.cities = []
|
query.cities = []
|
||||||
while pattern:
|
while pattern:
|
||||||
if len(query.cities) > 0:
|
if len(query.cities) > 0:
|
||||||
print '\n%sSelected cities:%s %s' % (self.BOLD, self.NC, ', '.join([c.name for c in query.cities]))
|
print('\n%sSelected cities:%s %s' % (self.BOLD, self.NC, ', '.join([c.name for c in query.cities])))
|
||||||
pattern = self.ask('Enter a city pattern (or empty to stop)', default='')
|
pattern = self.ask('Enter a city pattern (or empty to stop)', default='')
|
||||||
if not pattern:
|
if not pattern:
|
||||||
break
|
break
|
||||||
|
|
@ -114,7 +115,7 @@ class Flatboob(ReplApplication):
|
||||||
cities.append(city)
|
cities.append(city)
|
||||||
|
|
||||||
if len(cities) == 0:
|
if len(cities) == 0:
|
||||||
print ' Not found!'
|
print(' Not found!')
|
||||||
continue
|
continue
|
||||||
if len(cities) == 1:
|
if len(cities) == 1:
|
||||||
if city in query.cities:
|
if city in query.cities:
|
||||||
|
|
@ -126,7 +127,7 @@ class Flatboob(ReplApplication):
|
||||||
r = 'notempty'
|
r = 'notempty'
|
||||||
while r != '':
|
while r != '':
|
||||||
for i, city in enumerate(cities):
|
for i, city in enumerate(cities):
|
||||||
print ' %s%2d)%s [%s] %s' % (self.BOLD, i+1, self.NC, 'x' if city in query.cities else ' ', city.name)
|
print(' %s%2d)%s [%s] %s' % (self.BOLD, i+1, self.NC, 'x' if city in query.cities else ' ', city.name))
|
||||||
r = self.ask(' Select cities (or empty to stop)', regexp='(\d+|)', default='')
|
r = self.ask(' Select cities (or empty to stop)', regexp='(\d+|)', default='')
|
||||||
if not r.isdigit():
|
if not r.isdigit():
|
||||||
continue
|
continue
|
||||||
|
|
@ -142,10 +143,10 @@ class Flatboob(ReplApplication):
|
||||||
r = 'notempty'
|
r = 'notempty'
|
||||||
while r != '':
|
while r != '':
|
||||||
for good in Query.HOUSE_TYPES.values:
|
for good in Query.HOUSE_TYPES.values:
|
||||||
print ' %s%2d)%s [%s] %s' % (self.BOLD,
|
print(' %s%2d)%s [%s] %s' % (self.BOLD,
|
||||||
Query.HOUSE_TYPES.index[good] + 1,
|
Query.HOUSE_TYPES.index[good] + 1,
|
||||||
self.NC,
|
self.NC,
|
||||||
'x' if good in query.house_types else ' ', good)
|
'x' if good in query.house_types else ' ', good))
|
||||||
r = self.ask(' Select type of house (or empty to stop)', regexp='(\d+|)', default='')
|
r = self.ask(' Select type of house (or empty to stop)', regexp='(\d+|)', default='')
|
||||||
if not r.isdigit():
|
if not r.isdigit():
|
||||||
continue
|
continue
|
||||||
|
|
@ -160,14 +161,14 @@ class Flatboob(ReplApplication):
|
||||||
|
|
||||||
_type = None
|
_type = None
|
||||||
while _type not in [query.TYPE_RENT, query.TYPE_SALE]:
|
while _type not in [query.TYPE_RENT, query.TYPE_SALE]:
|
||||||
print ' %s%2d)%s %s' % (self.BOLD,
|
print(' %s%2d)%s %s' % (self.BOLD,
|
||||||
query.TYPE_RENT,
|
query.TYPE_RENT,
|
||||||
self.NC,
|
self.NC,
|
||||||
"Rent")
|
"Rent"))
|
||||||
print ' %s%2d)%s %s' % (self.BOLD,
|
print(' %s%2d)%s %s' % (self.BOLD,
|
||||||
query.TYPE_SALE,
|
query.TYPE_SALE,
|
||||||
self.NC,
|
self.NC,
|
||||||
"Sale")
|
"Sale"))
|
||||||
_type = self.ask_int('Type of query')
|
_type = self.ask_int('Type of query')
|
||||||
|
|
||||||
query.type = _type
|
query.type = _type
|
||||||
|
|
@ -207,20 +208,20 @@ class Flatboob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
queries = self.config.get('queries')
|
queries = self.config.get('queries')
|
||||||
if not queries:
|
if not queries:
|
||||||
print >>self.stderr, 'There is no saved queries'
|
print('There is no saved queries', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
if not query_name:
|
if not query_name:
|
||||||
for name in queries.keys():
|
for name in queries.keys():
|
||||||
print ' %s* %s %s' % (self.BOLD,
|
print(' %s* %s %s' % (self.BOLD,
|
||||||
self.NC,
|
self.NC,
|
||||||
name)
|
name))
|
||||||
query_name = self.ask('Which one')
|
query_name = self.ask('Which one')
|
||||||
|
|
||||||
if query_name in queries:
|
if query_name in queries:
|
||||||
self.complete_search(queries.get(query_name))
|
self.complete_search(queries.get(query_name))
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'Unknown query'
|
print('Unknown query', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
def complete_info(self, text, line, *ignored):
|
def complete_info(self, text, line, *ignored):
|
||||||
|
|
@ -235,12 +236,12 @@ class Flatboob(ReplApplication):
|
||||||
Get information about a housing.
|
Get information about a housing.
|
||||||
"""
|
"""
|
||||||
if not _id:
|
if not _id:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
housing = self.get_object(_id, 'get_housing')
|
housing = self.get_object(_id, 'get_housing')
|
||||||
if not housing:
|
if not housing:
|
||||||
print >>self.stderr, 'Housing not found: %s' % _id
|
print('Housing not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# 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 os
|
import os
|
||||||
from re import search, sub
|
from re import search, sub
|
||||||
|
|
@ -67,7 +67,7 @@ class Galleroob(ReplApplication):
|
||||||
List galleries matching a PATTERN.
|
List galleries matching a PATTERN.
|
||||||
"""
|
"""
|
||||||
if not pattern:
|
if not pattern:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('search', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('search', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
self.start_format(pattern=pattern)
|
self.start_format(pattern=pattern)
|
||||||
|
|
@ -97,14 +97,14 @@ class Galleroob(ReplApplication):
|
||||||
gallery = result
|
gallery = result
|
||||||
|
|
||||||
if not gallery:
|
if not gallery:
|
||||||
print >>self.stderr, 'Gallery not found: %s' % _id
|
print('Gallery not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
backend.fillobj(gallery, ('title',))
|
backend.fillobj(gallery, ('title',))
|
||||||
if dest is None:
|
if dest is None:
|
||||||
dest = sub('/', ' ', gallery.title)
|
dest = sub('/', ' ', gallery.title)
|
||||||
|
|
||||||
print "Downloading to %s" % dest
|
print("Downloading to %s" % dest)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.mkdir(dest)
|
os.mkdir(dest)
|
||||||
|
|
@ -122,7 +122,7 @@ class Galleroob(ReplApplication):
|
||||||
if img.data is None:
|
if img.data is None:
|
||||||
backend.fillobj(img, ('url', 'data'))
|
backend.fillobj(img, ('url', 'data'))
|
||||||
if img.data is None:
|
if img.data is None:
|
||||||
print >>self.stderr, "Couldn't get page %d, exiting" % i
|
print("Couldn't get page %d, exiting" % i, file=self.stderr)
|
||||||
break
|
break
|
||||||
|
|
||||||
ext = search(r"\.([^\.]{1,5})$", img.url)
|
ext = search(r"\.([^\.]{1,5})$", img.url)
|
||||||
|
|
@ -132,7 +132,7 @@ class Galleroob(ReplApplication):
|
||||||
ext = "jpg"
|
ext = "jpg"
|
||||||
|
|
||||||
name = '%03d.%s' % (i, ext)
|
name = '%03d.%s' % (i, ext)
|
||||||
print 'Writing file %s' % name
|
print('Writing file %s' % name)
|
||||||
|
|
||||||
with open(name, 'w') as f:
|
with open(name, 'w') as f:
|
||||||
f.write(img.data)
|
f.write(img.data)
|
||||||
|
|
@ -149,7 +149,7 @@ class Galleroob(ReplApplication):
|
||||||
|
|
||||||
gallery = self.get_object(_id, 'get_gallery')
|
gallery = self.get_object(_id, 'get_gallery')
|
||||||
if not gallery:
|
if not gallery:
|
||||||
print >>self.stderr, 'Gallery not found: %s' % _id
|
print('Gallery not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
|
||||||
|
|
||||||
# Copyright(C) 2010-2011 Romain Bignon
|
# Copyright(C) 2010-2011 Romain Bignon
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# 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.capabilities.geolocip import CapGeolocIp
|
from weboob.capabilities.geolocip import CapGeolocIp
|
||||||
from weboob.tools.application.repl import ReplApplication
|
from weboob.tools.application.repl import ReplApplication
|
||||||
|
|
@ -36,7 +36,7 @@ class Geolooc(ReplApplication):
|
||||||
|
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
if len(argv) < 2:
|
if len(argv) < 2:
|
||||||
print >>self.stderr, 'Syntax: %s ipaddr' % argv[0]
|
print('Syntax: %s ipaddr' % argv[0], file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
for backend, location in self.do('get_location', argv[1]):
|
for backend, location in self.do('get_location', argv[1]):
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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.capabilities.job import CapJob
|
from weboob.capabilities.job import CapJob
|
||||||
from weboob.tools.application.repl import ReplApplication, defaultcount
|
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||||
|
|
@ -122,13 +123,13 @@ class Handjoob(ReplApplication):
|
||||||
Get information about an advert.
|
Get information about an advert.
|
||||||
"""
|
"""
|
||||||
if not _id:
|
if not _id:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
job_advert = self.get_object(_id, 'get_job_advert')
|
job_advert = self.get_object(_id, 'get_job_advert')
|
||||||
|
|
||||||
if not job_advert:
|
if not job_advert:
|
||||||
print >>self.stderr, 'Job advert not found: %s' % _id
|
print('Job advert not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 copy import copy
|
from copy import copy
|
||||||
|
|
||||||
|
|
@ -87,11 +88,11 @@ class HaveDate(Boobmsg):
|
||||||
_id, backend_name = self.parse_id(id, unique_backend=True)
|
_id, backend_name = self.parse_id(id, unique_backend=True)
|
||||||
|
|
||||||
for backend, query in self.do('send_query', _id, backends=backend_name):
|
for backend, query in self.do('send_query', _id, backends=backend_name):
|
||||||
print '%s' % query.message
|
print('%s' % query.message)
|
||||||
|
|
||||||
def edit_optims(self, backend_names, optims_names, stop=False):
|
def edit_optims(self, backend_names, optims_names, stop=False):
|
||||||
if optims_names is None:
|
if optims_names is None:
|
||||||
print >>self.stderr, 'Error: missing parameters.'
|
print('Error: missing parameters.', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
for optim_name in optims_names.split():
|
for optim_name in optims_names.split():
|
||||||
|
|
@ -101,29 +102,29 @@ class HaveDate(Boobmsg):
|
||||||
backends_optims[backend.name] = optim
|
backends_optims[backend.name] = optim
|
||||||
for backend_name, optim in backends_optims.iteritems():
|
for backend_name, optim in backends_optims.iteritems():
|
||||||
if len(optim.CONFIG) == 0:
|
if len(optim.CONFIG) == 0:
|
||||||
print '%s.%s does not require configuration.' % (backend_name, optim_name)
|
print('%s.%s does not require configuration.' % (backend_name, optim_name))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
was_running = optim.is_running()
|
was_running = optim.is_running()
|
||||||
if stop and was_running:
|
if stop and was_running:
|
||||||
print 'Stopping %s: %s' % (optim_name, backend_name)
|
print('Stopping %s: %s' % (optim_name, backend_name))
|
||||||
optim.stop()
|
optim.stop()
|
||||||
params = optim.get_config()
|
params = optim.get_config()
|
||||||
if params is None:
|
if params is None:
|
||||||
params = {}
|
params = {}
|
||||||
print 'Configuration of %s.%s' % (backend_name, optim_name)
|
print('Configuration of %s.%s' % (backend_name, optim_name))
|
||||||
print '-----------------%s-%s' % ('-' * len(backend_name), '-' * len(optim_name))
|
print('-----------------%s-%s' % ('-' * len(backend_name), '-' * len(optim_name)))
|
||||||
for key, value in optim.CONFIG.iteritems():
|
for key, value in optim.CONFIG.iteritems():
|
||||||
params[key] = self.ask(value, default=params[key] if (key in params) else value.default)
|
params[key] = self.ask(value, default=params[key] if (key in params) else value.default)
|
||||||
|
|
||||||
optim.set_config(params)
|
optim.set_config(params)
|
||||||
if stop and was_running:
|
if stop and was_running:
|
||||||
print 'Starting %s: %s' % (optim_name, backend_name)
|
print('Starting %s: %s' % (optim_name, backend_name))
|
||||||
optim.start()
|
optim.start()
|
||||||
|
|
||||||
def optims(self, function, backend_names, optims, store=True):
|
def optims(self, function, backend_names, optims, store=True):
|
||||||
if optims is None:
|
if optims is None:
|
||||||
print >>self.stderr, 'Error: missing parameters.'
|
print('Error: missing parameters.', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
for optim_name in optims.split():
|
for optim_name in optims.split():
|
||||||
|
|
@ -205,7 +206,7 @@ class HaveDate(Boobmsg):
|
||||||
if backend_name == '*':
|
if backend_name == '*':
|
||||||
backend_name = None
|
backend_name = None
|
||||||
elif backend_name is not None and not backend_name in [b.name for b in self.enabled_backends]:
|
elif backend_name is not None and not backend_name in [b.name for b in self.enabled_backends]:
|
||||||
print >>self.stderr, 'Error: No such backend "%s"' % backend_name
|
print('Error: No such backend "%s"' % backend_name, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if cmd == 'start':
|
if cmd == 'start':
|
||||||
|
|
@ -245,7 +246,7 @@ class HaveDate(Boobmsg):
|
||||||
line.append((b, status))
|
line.append((b, status))
|
||||||
self.format(tuple(line))
|
self.format(tuple(line))
|
||||||
return
|
return
|
||||||
print >>self.stderr, "No such command '%s'" % cmd
|
print("No such command '%s'" % cmd, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def do_events(self, line):
|
def do_events(self, line):
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
|
||||||
|
|
||||||
# Copyright(C) 2010-2011 Romain Bignon
|
# Copyright(C) 2010-2011 Romain Bignon
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from smtplib import SMTP
|
from smtplib import SMTP
|
||||||
|
|
@ -118,7 +119,7 @@ class Monboob(ReplApplication):
|
||||||
if self.config.get('interval') < 1:
|
if self.config.get('interval') < 1:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print >>self.stderr, 'Configuration error: interval must be an integer >0.'
|
print('Configuration error: interval must be an integer >0.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -126,7 +127,7 @@ class Monboob(ReplApplication):
|
||||||
if self.config.get('html') not in (0, 1):
|
if self.config.get('html') not in (0, 1):
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print >>self.stderr, 'Configuration error: html must be 0 or 1.'
|
print('Configuration error: html must be 0 or 1.', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
return ReplApplication.main(self, argv)
|
return ReplApplication.main(self, argv)
|
||||||
|
|
@ -189,7 +190,7 @@ class Monboob(ReplApplication):
|
||||||
break
|
break
|
||||||
|
|
||||||
if len(content) == 0:
|
if len(content) == 0:
|
||||||
print >>self.stderr, 'Unable to send an empty message'
|
print('Unable to send an empty message', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# remove signature
|
# remove signature
|
||||||
|
|
@ -209,7 +210,7 @@ class Monboob(ReplApplication):
|
||||||
bname, id = reply_to.split('.', 1)
|
bname, id = reply_to.split('.', 1)
|
||||||
thread_id, parent_id = id.rsplit('.', 1)
|
thread_id, parent_id = id.rsplit('.', 1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print >>self.stderr, 'In-Reply-To header might be in form <backend.thread_id.message_id>'
|
print('In-Reply-To header might be in form <backend.thread_id.message_id>', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# Default use the To header field to know the backend to use.
|
# Default use the To header field to know the backend to use.
|
||||||
|
|
@ -219,11 +220,11 @@ class Monboob(ReplApplication):
|
||||||
try:
|
try:
|
||||||
backend = self.weboob.backend_instances[bname]
|
backend = self.weboob.backend_instances[bname]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print >>self.stderr, 'Backend %s not found' % bname
|
print('Backend %s not found' % bname, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if not backend.has_caps(CapMessagesPost):
|
if not backend.has_caps(CapMessagesPost):
|
||||||
print >>self.stderr, 'The backend %s does not implement CapMessagesPost' % bname
|
print('The backend %s does not implement CapMessagesPost' % bname, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
thread = Thread(thread_id)
|
thread = Thread(thread_id)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# 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.capabilities.base import empty
|
from weboob.capabilities.base import empty
|
||||||
from weboob.capabilities.parcel import CapParcel, Parcel, ParcelNotFound
|
from weboob.capabilities.parcel import CapParcel, Parcel, ParcelNotFound
|
||||||
|
|
@ -105,7 +105,7 @@ class Parceloob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
parcel = self.get_object(line, 'get_parcel_tracking')
|
parcel = self.get_object(line, 'get_parcel_tracking')
|
||||||
if not parcel:
|
if not parcel:
|
||||||
print >>self.stderr, 'Error: the parcel "%s" is not found' % line
|
print('Error: the parcel "%s" is not found' % line, file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
parcels = set(self.storage.get('tracking', default=[]))
|
parcels = set(self.storage.get('tracking', default=[]))
|
||||||
|
|
@ -113,7 +113,7 @@ class Parceloob(ReplApplication):
|
||||||
self.storage.set('tracking', list(parcels))
|
self.storage.set('tracking', list(parcels))
|
||||||
self.storage.save()
|
self.storage.save()
|
||||||
|
|
||||||
print 'Parcel "%s" has been tracked.' % parcel.fullid
|
print('Parcel "%s" has been tracked.' % parcel.fullid)
|
||||||
|
|
||||||
def do_untrack(self, line):
|
def do_untrack(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -137,22 +137,22 @@ class Parceloob(ReplApplication):
|
||||||
parcel = False
|
parcel = False
|
||||||
|
|
||||||
if not parcel:
|
if not parcel:
|
||||||
print >>self.stderr, 'Error: the parcel "%s" is not found. Did you provide the full id@backend parameter?' % line
|
print('Error: the parcel "%s" is not found. Did you provide the full id@backend parameter?' % line, file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parcels.remove(parcel.fullid)
|
parcels.remove(parcel.fullid)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print >>self.stderr, "Error: parcel \"%s\" wasn't tracked" % parcel.fullid
|
print("Error: parcel \"%s\" wasn't tracked" % parcel.fullid, file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
self.storage.set('tracking', list(parcels))
|
self.storage.set('tracking', list(parcels))
|
||||||
self.storage.save()
|
self.storage.save()
|
||||||
|
|
||||||
if removed:
|
if removed:
|
||||||
print "Parcel \"%s\" isn't tracked anymore." % line
|
print("Parcel \"%s\" isn't tracked anymore." % line)
|
||||||
else:
|
else:
|
||||||
print "Parcel \"%s\" isn't tracked anymore." % parcel.fullid
|
print("Parcel \"%s\" isn't tracked anymore." % parcel.fullid)
|
||||||
|
|
||||||
def do_status(self, line):
|
def do_status(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -184,7 +184,7 @@ class Parceloob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
parcel = self.get_object(id, 'get_parcel_tracking', [])
|
parcel = self.get_object(id, 'get_parcel_tracking', [])
|
||||||
if not parcel:
|
if not parcel:
|
||||||
print >>self.stderr, 'Error: parcel not found'
|
print('Error: parcel not found', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
|
||||||
|
|
||||||
# Copyright(C) 2011 Laurent Bachelier
|
# Copyright(C) 2011 Laurent Bachelier
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 os
|
import os
|
||||||
import codecs
|
import codecs
|
||||||
|
|
@ -49,14 +50,14 @@ class Pastoob(ReplApplication):
|
||||||
Get information about pastes.
|
Get information about pastes.
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
for _id in line.split(' '):
|
for _id in line.split(' '):
|
||||||
paste = self.get_object(_id, 'get_paste', ['id', 'title', 'language', 'public', 'contents'])
|
paste = self.get_object(_id, 'get_paste', ['id', 'title', 'language', 'public', 'contents'])
|
||||||
if not paste:
|
if not paste:
|
||||||
print >>self.stderr, 'Paste not found: %s' % _id
|
print('Paste not found: %s' % _id, file=self.stderr)
|
||||||
|
|
||||||
self.format(paste)
|
self.format(paste)
|
||||||
|
|
||||||
|
|
@ -80,22 +81,22 @@ class Pastoob(ReplApplication):
|
||||||
|
|
||||||
def _get_op(self, _id, binary, command='get'):
|
def _get_op(self, _id, binary, command='get'):
|
||||||
if not _id:
|
if not _id:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help(command, short=True)
|
print('This command takes an argument: %s' % self.get_command_help(command, short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
paste = self.get_object(_id, 'get_paste', ['contents'])
|
paste = self.get_object(_id, 'get_paste', ['contents'])
|
||||||
except PasteNotFound:
|
except PasteNotFound:
|
||||||
print >>self.stderr, 'Paste not found: %s' % _id
|
print('Paste not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
if not paste:
|
if not paste:
|
||||||
print >>self.stderr, 'Unable to handle paste: %s' % _id
|
print('Unable to handle paste: %s' % _id, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if binary:
|
if binary:
|
||||||
if self.interactive:
|
if self.interactive:
|
||||||
if not self.ask('The console may become messed up. Are you sure you want to show a binary file on your terminal?', default=False):
|
if not self.ask('The console may become messed up. Are you sure you want to show a binary file on your terminal?', default=False):
|
||||||
print >>self.stderr, 'Aborting.'
|
print('Aborting.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
output = self.stdout
|
output = self.stdout
|
||||||
output.write(paste.contents.decode('base64'))
|
output.write(paste.contents.decode('base64'))
|
||||||
|
|
@ -135,7 +136,7 @@ class Pastoob(ReplApplication):
|
||||||
else:
|
else:
|
||||||
contents = self.acquire_input()
|
contents = self.acquire_input()
|
||||||
if not len(contents):
|
if not len(contents):
|
||||||
print >>self.stderr, 'Empty paste, aborting.'
|
print('Empty paste, aborting.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
@ -147,7 +148,7 @@ class Pastoob(ReplApplication):
|
||||||
with m as fp:
|
with m as fp:
|
||||||
contents = fp.read()
|
contents = fp.read()
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to open file "%s": %s' % (filename, e.strerror)
|
print('Unable to open file "%s": %s' % (filename, e.strerror), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if binary:
|
if binary:
|
||||||
|
|
@ -164,7 +165,7 @@ class Pastoob(ReplApplication):
|
||||||
if len(backends):
|
if len(backends):
|
||||||
backend = choice(backends[max(backends.keys())])
|
backend = choice(backends[max(backends.keys())])
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'No suitable backend found.'
|
print('No suitable backend found.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
p = backend.new_paste(_id=None)
|
p = backend.new_paste(_id=None)
|
||||||
|
|
@ -175,7 +176,7 @@ class Pastoob(ReplApplication):
|
||||||
p.title = os.path.basename(filename)
|
p.title = os.path.basename(filename)
|
||||||
p.contents = contents
|
p.contents = contents
|
||||||
backend.post_paste(p, max_age=params['max_age'])
|
backend.post_paste(p, max_age=params['max_age'])
|
||||||
print 'Successfuly posted paste: %s' % p.page_url
|
print('Successfuly posted paste: %s' % p.page_url)
|
||||||
|
|
||||||
def get_params(self):
|
def get_params(self):
|
||||||
return {'public': self.options.public,
|
return {'public': self.options.public,
|
||||||
|
|
|
||||||
|
|
@ -17,6 +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 time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
@ -208,7 +210,7 @@ class MessagesManager(QWidget):
|
||||||
self.ui.profileButton.hide()
|
self.ui.profileButton.hide()
|
||||||
|
|
||||||
def _profilePressed(self):
|
def _profilePressed(self):
|
||||||
print self.thread.id
|
print(self.thread.id)
|
||||||
self.emit(SIGNAL('display_contact'), self.thread.id)
|
self.emit(SIGNAL('display_contact'), self.thread.id)
|
||||||
|
|
||||||
def displayReply(self):
|
def displayReply(self):
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 PyQt4.QtCore import Qt, SIGNAL
|
from PyQt4.QtCore import Qt, SIGNAL
|
||||||
from PyQt4.QtGui import QFrame, QFileDialog
|
from PyQt4.QtGui import QFrame, QFileDialog
|
||||||
|
|
@ -82,6 +83,6 @@ class Subtitle(QFrame):
|
||||||
with open(dest, 'w') as f:
|
with open(dest, 'w') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write subtitle file in "%s": %s' % (dest, e)
|
print('Unable to write subtitle file in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 PyQt4.QtCore import Qt, SIGNAL
|
from PyQt4.QtCore import Qt, SIGNAL
|
||||||
from PyQt4.QtGui import QFrame, QFileDialog
|
from PyQt4.QtGui import QFrame, QFileDialog
|
||||||
|
|
@ -86,6 +87,6 @@ class Torrent(QFrame):
|
||||||
with open(unicode(dest), 'w') as f:
|
with open(unicode(dest), 'w') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write .torrent in "%s": %s' % (dest, e)
|
print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -17,6 +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 urllib
|
import urllib
|
||||||
import codecs
|
import codecs
|
||||||
|
|
||||||
|
|
@ -107,6 +109,6 @@ class Recipe(QFrame):
|
||||||
with codecs.open(dest, 'w', 'utf-8') as f:
|
with codecs.open(dest, 'w', 'utf-8') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write Krecipe file in "%s": %s' % (dest, e)
|
print('Unable to write Krecipe file in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -17,6 +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
|
||||||
|
|
||||||
from PyQt4.QtGui import QWidget, QTreeWidgetItem, QImage, QIcon, QPixmap
|
from PyQt4.QtGui import QWidget, QTreeWidgetItem, QImage, QIcon, QPixmap
|
||||||
from PyQt4.QtCore import SIGNAL, Qt
|
from PyQt4.QtCore import SIGNAL, Qt
|
||||||
|
|
||||||
|
|
@ -101,7 +103,7 @@ class EventsWidget(QWidget):
|
||||||
if s == event.type:
|
if s == event.type:
|
||||||
found = True
|
found = True
|
||||||
if not found:
|
if not found:
|
||||||
print event.type
|
print(event.type)
|
||||||
self.ui.typeBox.addItem(event.type.capitalize(), event.type)
|
self.ui.typeBox.addItem(event.type.capitalize(), event.type)
|
||||||
if event.type == self.event_filter:
|
if event.type == self.event_filter:
|
||||||
self.ui.typeBox.setCurrentIndex(self.ui.typeBox.count()-1)
|
self.ui.typeBox.setCurrentIndex(self.ui.typeBox.count()-1)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
|
||||||
|
|
||||||
# Copyright(C) 2010-2011 Romain Bignon
|
# Copyright(C) 2010-2011 Romain Bignon
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -17,6 +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 subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
@ -166,18 +168,18 @@ class Radioob(ReplApplication):
|
||||||
_id, dest = self.parse_command_args(line, 2, 1)
|
_id, dest = self.parse_command_args(line, 2, 1)
|
||||||
audio = self.get_object(_id, 'get_audio', ['url'])
|
audio = self.get_object(_id, 'get_audio', ['url'])
|
||||||
if not audio:
|
if not audio:
|
||||||
print >>self.stderr, 'Audio file not found: %s' % _id
|
print('Audio file not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if not audio.url:
|
if not audio.url:
|
||||||
print >>self.stderr, 'Error: the direct URL is not available.'
|
print('Error: the direct URL is not available.', file=self.stderr)
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
def check_exec(executable):
|
def check_exec(executable):
|
||||||
with open('/dev/null', 'w') as devnull:
|
with open('/dev/null', 'w') as devnull:
|
||||||
process = subprocess.Popen(['which', executable], stdout=devnull)
|
process = subprocess.Popen(['which', executable], stdout=devnull)
|
||||||
if process.wait() != 0:
|
if process.wait() != 0:
|
||||||
print >>self.stderr, 'Please install "%s"' % executable
|
print('Please install "%s"' % executable, file=self.stderr)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -224,7 +226,7 @@ class Radioob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
_id, stream_id = self.parse_command_args(line, 2, 1)
|
_id, stream_id = self.parse_command_args(line, 2, 1)
|
||||||
if not _id:
|
if not _id:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('play', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('play', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -235,14 +237,14 @@ class Radioob(ReplApplication):
|
||||||
obj = self.retrieve_obj(_id)
|
obj = self.retrieve_obj(_id)
|
||||||
|
|
||||||
if obj is None:
|
if obj is None:
|
||||||
print >>self.stderr, 'No object matches with this id:', _id
|
print('No object matches with this id:', _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if isinstance(obj, Radio):
|
if isinstance(obj, Radio):
|
||||||
try:
|
try:
|
||||||
streams = [obj.streams[stream_id]]
|
streams = [obj.streams[stream_id]]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print >>self.stderr, 'Stream %d not found' % stream_id
|
print('Stream %d not found' % stream_id, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
elif isinstance(obj, BaseAudio):
|
elif isinstance(obj, BaseAudio):
|
||||||
streams = [obj]
|
streams = [obj]
|
||||||
|
|
@ -251,7 +253,7 @@ class Radioob(ReplApplication):
|
||||||
streams = obj.tracks_list
|
streams = obj.tracks_list
|
||||||
|
|
||||||
if len(streams) == 0:
|
if len(streams) == 0:
|
||||||
print >>self.stderr, 'Radio or Audio file not found:', _id
|
print('Radio or Audio file not found:', _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -289,7 +291,7 @@ class Radioob(ReplApplication):
|
||||||
self.player.play(stream, player_name=player_name, player_args=media_player_args)
|
self.player.play(stream, player_name=player_name, player_args=media_player_args)
|
||||||
|
|
||||||
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
|
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
|
||||||
print '%s\nRadio URL: %s' % (e, stream.url)
|
print('%s\nRadio URL: %s' % (e, stream.url))
|
||||||
|
|
||||||
def retrieve_obj(self, _id):
|
def retrieve_obj(self, _id):
|
||||||
obj = None
|
obj = None
|
||||||
|
|
@ -316,7 +318,7 @@ class Radioob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('playlist')
|
print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
cmd, args = self.parse_command_args(line, 2, req_n=1)
|
cmd, args = self.parse_command_args(line, 2, req_n=1)
|
||||||
|
|
@ -326,11 +328,11 @@ class Radioob(ReplApplication):
|
||||||
audio = self.get_object(_id, 'get_audio')
|
audio = self.get_object(_id, 'get_audio')
|
||||||
|
|
||||||
if not audio:
|
if not audio:
|
||||||
print >>self.stderr, 'Audio file not found: %s' % _id
|
print('Audio file not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if not audio.url:
|
if not audio.url:
|
||||||
print >>self.stderr, 'Error: the direct URL is not available.'
|
print('Error: the direct URL is not available.', file=self.stderr)
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
self.PLAYLIST.append(audio)
|
self.PLAYLIST.append(audio)
|
||||||
|
|
@ -342,11 +344,11 @@ class Radioob(ReplApplication):
|
||||||
audio_to_remove = self.get_object(_id, 'get_audio')
|
audio_to_remove = self.get_object(_id, 'get_audio')
|
||||||
|
|
||||||
if not audio_to_remove:
|
if not audio_to_remove:
|
||||||
print >>self.stderr, 'Audio file not found: %s' % _id
|
print('Audio file not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if not audio_to_remove.url:
|
if not audio_to_remove.url:
|
||||||
print >>self.stderr, 'Error: the direct URL is not available.'
|
print('Error: the direct URL is not available.', file=self.stderr)
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
for audio in self.PLAYLIST:
|
for audio in self.PLAYLIST:
|
||||||
|
|
@ -369,7 +371,7 @@ class Radioob(ReplApplication):
|
||||||
self.cached_format(audio)
|
self.cached_format(audio)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'Playlist command only support "add", "remove", "display" and "export" arguments.'
|
print('Playlist command only support "add", "remove", "display" and "export" arguments.', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
def complete_info(self, text, line, *ignored):
|
def complete_info(self, text, line, *ignored):
|
||||||
|
|
@ -384,7 +386,7 @@ class Radioob(ReplApplication):
|
||||||
Get information about a radio or an audio file.
|
Get information about a radio or an audio file.
|
||||||
"""
|
"""
|
||||||
if not _id:
|
if not _id:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
obj = self.retrieve_obj(_id)
|
obj = self.retrieve_obj(_id)
|
||||||
|
|
@ -395,7 +397,7 @@ class Radioob(ReplApplication):
|
||||||
self.set_formatter('playlist_tracks_list_info')
|
self.set_formatter('playlist_tracks_list_info')
|
||||||
|
|
||||||
if obj is None:
|
if obj is None:
|
||||||
print >>self.stderr, 'No object matches with this id:', _id
|
print('No object matches with this id:', _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.format(obj)
|
self.format(obj)
|
||||||
|
|
@ -411,7 +413,7 @@ class Radioob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not pattern:
|
if not pattern:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('playlist')
|
print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
cmd, args = self.parse_command_args(pattern, 2, req_n=1)
|
cmd, args = self.parse_command_args(pattern, 2, req_n=1)
|
||||||
|
|
@ -446,7 +448,7 @@ class Radioob(ReplApplication):
|
||||||
self.format(playlist)
|
self.format(playlist)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'Search command only supports "radio", "song", "album" and "playlist" arguments.'
|
print('Search command only supports "radio", "song", "album" and "playlist" arguments.', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
def do_ls(self, line):
|
def do_ls(self, line):
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@
|
||||||
# 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.capabilities.subtitle import CapSubtitle
|
from weboob.capabilities.subtitle import CapSubtitle
|
||||||
from weboob.capabilities.base import empty
|
from weboob.capabilities.base import empty
|
||||||
|
|
@ -113,7 +112,7 @@ class Suboob(ReplApplication):
|
||||||
|
|
||||||
subtitle = self.get_object(id, 'get_subtitle')
|
subtitle = self.get_object(id, 'get_subtitle')
|
||||||
if not subtitle:
|
if not subtitle:
|
||||||
print >>self.stderr, 'Subtitle not found: %s' % id
|
print('Subtitle not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
@ -138,7 +137,7 @@ class Suboob(ReplApplication):
|
||||||
|
|
||||||
subtitle = self.get_object(id, 'get_subtitle')
|
subtitle = self.get_object(id, 'get_subtitle')
|
||||||
if not subtitle:
|
if not subtitle:
|
||||||
print >>self.stderr, 'Subtitle not found: %s' % id
|
print('Subtitle not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if dest is None:
|
if dest is None:
|
||||||
|
|
@ -156,10 +155,10 @@ class Suboob(ReplApplication):
|
||||||
with open(dest, 'w') as f:
|
with open(dest, 'w') as f:
|
||||||
f.write(buf)
|
f.write(buf)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write file in "%s": %s' % (dest, e)
|
print('Unable to write file in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
print 'Saved to %s' % dest
|
print('Saved to %s' % dest)
|
||||||
return
|
return
|
||||||
|
|
||||||
@defaultcount(10)
|
@defaultcount(10)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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.capabilities.translate import CapTranslate, TranslationFail, LanguageNotSupported
|
from weboob.capabilities.translate import CapTranslate, TranslationFail, LanguageNotSupported
|
||||||
from weboob.tools.application.repl import ReplApplication
|
from weboob.tools.application.repl import ReplApplication
|
||||||
|
|
@ -114,5 +115,5 @@ class Translaboob(ReplApplication):
|
||||||
for backend, translation in self.do('translate', self.LANGUAGE[lan_from], self.LANGUAGE[lan_to], text):
|
for backend, translation in self.do('translate', self.LANGUAGE[lan_from], self.LANGUAGE[lan_to], text):
|
||||||
self.format(translation)
|
self.format(translation)
|
||||||
except (TranslationFail, LanguageNotSupported) as error:
|
except (TranslationFail, LanguageNotSupported) as error:
|
||||||
print >>self.stderr, error
|
print(error, file=self.stderr)
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
|
|
||||||
|
|
||||||
# Copyright(C) 2010-2011 Romain Bignon
|
# Copyright(C) 2010-2011 Romain Bignon
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 datetime
|
import datetime
|
||||||
|
|
||||||
|
|
@ -104,7 +105,7 @@ class Traveloob(ReplApplication):
|
||||||
if arrival:
|
if arrival:
|
||||||
arrival_id, backend_name2 = self.parse_id(arrival)
|
arrival_id, backend_name2 = self.parse_id(arrival)
|
||||||
if backend_name and backend_name2 and backend_name != backend_name2:
|
if backend_name and backend_name2 and backend_name != backend_name2:
|
||||||
print >>self.stderr, 'Departure and arrival aren\'t on the same backend'
|
print('Departure and arrival aren\'t on the same backend', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
arrival_id = backend_name2 = None
|
arrival_id = backend_name2 = None
|
||||||
|
|
@ -120,8 +121,8 @@ class Traveloob(ReplApplication):
|
||||||
try:
|
try:
|
||||||
date = self.parse_datetime(date)
|
date = self.parse_datetime(date)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
print >>self.stderr, 'Invalid datetime value: %s' % e
|
print('Invalid datetime value: %s' % e, file=self.stderr)
|
||||||
print >>self.stderr, 'Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".'
|
print('Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for backend, departure in self.do('iter_station_departures', station_id, arrival_id, date, backends=backends):
|
for backend, departure in self.do('iter_station_departures', station_id, arrival_id, date, backends=backends):
|
||||||
|
|
@ -149,8 +150,8 @@ class Traveloob(ReplApplication):
|
||||||
filters.departure_time = self.parse_datetime(self.options.departure_time)
|
filters.departure_time = self.parse_datetime(self.options.departure_time)
|
||||||
filters.arrival_time = self.parse_datetime(self.options.arrival_time)
|
filters.arrival_time = self.parse_datetime(self.options.arrival_time)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
print >>self.stderr, 'Invalid datetime value: %s' % e
|
print('Invalid datetime value: %s' % e, file=self.stderr)
|
||||||
print >>self.stderr, 'Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".'
|
print('Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for backend, route in self.do('iter_roadmap', departure, arrival, filters):
|
for backend, route in self.do('iter_roadmap', departure, arrival, filters):
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
@ -76,14 +77,14 @@ class Videoob(ReplApplication):
|
||||||
|
|
||||||
def download(self, video, dest, default=None):
|
def download(self, video, dest, default=None):
|
||||||
if not video.url:
|
if not video.url:
|
||||||
print >>self.stderr, 'Error: the direct URL is not available.'
|
print('Error: the direct URL is not available.', file=self.stderr)
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
def check_exec(executable):
|
def check_exec(executable):
|
||||||
with open('/dev/null', 'w') as devnull:
|
with open('/dev/null', 'w') as devnull:
|
||||||
process = subprocess.Popen(['which', executable], stdout=devnull)
|
process = subprocess.Popen(['which', executable], stdout=devnull)
|
||||||
if process.wait() != 0:
|
if process.wait() != 0:
|
||||||
print >>self.stderr, 'Please install "%s"' % executable
|
print('Please install "%s"' % executable, file=self.stderr)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -146,7 +147,7 @@ class Videoob(ReplApplication):
|
||||||
_id, dest = self.parse_command_args(line, 2, 1)
|
_id, dest = self.parse_command_args(line, 2, 1)
|
||||||
video = self.get_object(_id, 'get_video', ['url'])
|
video = self.get_object(_id, 'get_video', ['url'])
|
||||||
if not video:
|
if not video:
|
||||||
print >>self.stderr, 'Video not found: %s' % _id
|
print('Video not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
return self.download(video, dest)
|
return self.download(video, dest)
|
||||||
|
|
@ -163,7 +164,7 @@ class Videoob(ReplApplication):
|
||||||
Play a video with a found player.
|
Play a video with a found player.
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('play', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('play', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
ret = 0
|
ret = 0
|
||||||
|
|
@ -177,10 +178,10 @@ class Videoob(ReplApplication):
|
||||||
|
|
||||||
def play(self, video, _id):
|
def play(self, video, _id):
|
||||||
if not video:
|
if not video:
|
||||||
print >>self.stderr, 'Video not found: %s' % _id
|
print('Video not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
if not video.url:
|
if not video.url:
|
||||||
print >>self.stderr, 'Error: the direct URL is not available.'
|
print('Error: the direct URL is not available.', file=self.stderr)
|
||||||
return 4
|
return 4
|
||||||
try:
|
try:
|
||||||
player_name = self.config.get('media_player')
|
player_name = self.config.get('media_player')
|
||||||
|
|
@ -190,7 +191,7 @@ class Videoob(ReplApplication):
|
||||||
'configuration file.')
|
'configuration file.')
|
||||||
self.player.play(video, player_name=player_name, player_args=media_player_args)
|
self.player.play(video, player_name=player_name, player_args=media_player_args)
|
||||||
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
|
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
|
||||||
print '%s\nVideo URL: %s' % (e, video.url)
|
print('%s\nVideo URL: %s' % (e, video.url))
|
||||||
|
|
||||||
def complete_info(self, text, line, *ignored):
|
def complete_info(self, text, line, *ignored):
|
||||||
args = line.split(' ')
|
args = line.split(' ')
|
||||||
|
|
@ -204,14 +205,14 @@ class Videoob(ReplApplication):
|
||||||
Get information about a video.
|
Get information about a video.
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
for _id in line.split(' '):
|
for _id in line.split(' '):
|
||||||
video = self.get_object(_id, 'get_video')
|
video = self.get_object(_id, 'get_video')
|
||||||
if not video:
|
if not video:
|
||||||
print >>self.stderr, 'Video not found: %s' % _id
|
print('Video not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.format(video)
|
self.format(video)
|
||||||
|
|
@ -239,11 +240,11 @@ class Videoob(ReplApplication):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not self.interactive:
|
if not self.interactive:
|
||||||
print >>self.stderr, 'This command can be used only in interactive mode.'
|
print('This command can be used only in interactive mode.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('playlist')
|
print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
cmd, args = self.parse_command_args(line, 2, req_n=1)
|
cmd, args = self.parse_command_args(line, 2, req_n=1)
|
||||||
|
|
@ -253,11 +254,11 @@ class Videoob(ReplApplication):
|
||||||
video = self.get_object(_id, 'get_video')
|
video = self.get_object(_id, 'get_video')
|
||||||
|
|
||||||
if not video:
|
if not video:
|
||||||
print >>self.stderr, 'Video not found: %s' % _id
|
print('Video not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if not video.url:
|
if not video.url:
|
||||||
print >>self.stderr, 'Error: the direct URL is not available.'
|
print('Error: the direct URL is not available.', file=self.stderr)
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
self.PLAYLIST.append(video)
|
self.PLAYLIST.append(video)
|
||||||
|
|
@ -267,11 +268,11 @@ class Videoob(ReplApplication):
|
||||||
video_to_remove = self.get_object(_id, 'get_video')
|
video_to_remove = self.get_object(_id, 'get_video')
|
||||||
|
|
||||||
if not video_to_remove:
|
if not video_to_remove:
|
||||||
print >>self.stderr, 'Video not found: %s' % _id
|
print('Video not found: %s' % _id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if not video_to_remove.url:
|
if not video_to_remove.url:
|
||||||
print >>self.stderr, 'Error: the direct URL is not available.'
|
print('Error: the direct URL is not available.', file=self.stderr)
|
||||||
return 4
|
return 4
|
||||||
|
|
||||||
for video in self.PLAYLIST:
|
for video in self.PLAYLIST:
|
||||||
|
|
@ -297,7 +298,7 @@ class Videoob(ReplApplication):
|
||||||
for video in self.PLAYLIST:
|
for video in self.PLAYLIST:
|
||||||
self.play(video, video.id)
|
self.play(video, video.id)
|
||||||
else:
|
else:
|
||||||
print >>self.stderr, 'Playlist command only support "add", "remove", "display", "download" and "export" arguments.'
|
print('Playlist command only support "add", "remove", "display", "download" and "export" arguments.', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
def complete_nsfw(self, text, line, begidx, endidx):
|
def complete_nsfw(self, text, line, begidx, endidx):
|
||||||
|
|
@ -318,10 +319,10 @@ class Videoob(ReplApplication):
|
||||||
elif line == 'off':
|
elif line == 'off':
|
||||||
self.nsfw = False
|
self.nsfw = False
|
||||||
else:
|
else:
|
||||||
print 'Invalid argument "%s".' % line
|
print('Invalid argument "%s".' % line)
|
||||||
return 2
|
return 2
|
||||||
else:
|
else:
|
||||||
print "on" if self.nsfw else "off"
|
print("on" if self.nsfw else "off")
|
||||||
|
|
||||||
@defaultcount()
|
@defaultcount()
|
||||||
def do_search(self, pattern):
|
def do_search(self, pattern):
|
||||||
|
|
@ -331,7 +332,7 @@ class Videoob(ReplApplication):
|
||||||
Search for videos matching a PATTERN.
|
Search for videos matching a PATTERN.
|
||||||
"""
|
"""
|
||||||
if not pattern:
|
if not pattern:
|
||||||
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('search', short=True)
|
print('This command takes an argument: %s' % self.get_command_help('search', short=True), file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
self.change_path([u'search'])
|
self.change_path([u'search'])
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
@ -53,7 +54,7 @@ class WebContentEdit(ReplApplication):
|
||||||
contents += [content for backend, content in self.do('get_content', _id, backends=backend_names) if content]
|
contents += [content for backend, content in self.do('get_content', _id, backends=backend_names) if content]
|
||||||
|
|
||||||
if len(contents) == 0:
|
if len(contents) == 0:
|
||||||
print >>self.stderr, 'No contents found'
|
print('No contents found', file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
if self.stdin.isatty():
|
if self.stdin.isatty():
|
||||||
|
|
@ -92,10 +93,10 @@ class WebContentEdit(ReplApplication):
|
||||||
contents.remove(content)
|
contents.remove(content)
|
||||||
|
|
||||||
if len(contents) == 0:
|
if len(contents) == 0:
|
||||||
print >>self.stderr, 'No changes. Abort.'
|
print('No changes. Abort.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
print 'Contents changed:\n%s' % ('\n'.join(' * %s' % content.id for content in contents))
|
print('Contents changed:\n%s' % ('\n'.join(' * %s' % content.id for content in contents)))
|
||||||
|
|
||||||
message = self.ask('Enter a commit message', default='')
|
message = self.ask('Enter a commit message', default='')
|
||||||
minor = self.ask('Is this a minor edit?', default=False)
|
minor = self.ask('Is this a minor edit?', default=False)
|
||||||
|
|
@ -119,7 +120,7 @@ class WebContentEdit(ReplApplication):
|
||||||
# stdin is not a tty
|
# stdin is not a tty
|
||||||
|
|
||||||
if len(contents) != 1:
|
if len(contents) != 1:
|
||||||
print >>self.stderr, "Multiple ids not supported with pipe"
|
print("Multiple ids not supported with pipe", file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
message, minor = '', False
|
message, minor = '', False
|
||||||
|
|
@ -149,7 +150,7 @@ class WebContentEdit(ReplApplication):
|
||||||
Display log of a page
|
Display log of a page
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'Error: please give a page ID'
|
print('Error: please give a page ID', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
_id, backend_name = self.parse_id(line)
|
_id, backend_name = self.parse_id(line)
|
||||||
|
|
@ -168,7 +169,7 @@ class WebContentEdit(ReplApplication):
|
||||||
Get page contents
|
Get page contents
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'Error: please give a page ID'
|
print('Error: please give a page ID', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
_part_line = line.strip().split(' ')
|
_part_line = line.strip().split(' ')
|
||||||
|
|
@ -181,7 +182,7 @@ class WebContentEdit(ReplApplication):
|
||||||
_part_line.remove('-r')
|
_part_line.remove('-r')
|
||||||
|
|
||||||
if not _part_line:
|
if not _part_line:
|
||||||
print >>self.stderr, 'Error: please give a page ID'
|
print('Error: please give a page ID', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
_id, backend_name = self.parse_id(" ".join(_part_line))
|
_id, backend_name = self.parse_id(" ".join(_part_line))
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
@ -52,7 +53,7 @@ class WeboobCfg(ReplApplication):
|
||||||
Add a backend.
|
Add a backend.
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'You must specify a module name. Hint: use the "modules" command.'
|
print('You must specify a module name. Hint: use the "modules" command.', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
name, options = self.parse_command_args(line, 2, 1)
|
name, options = self.parse_command_args(line, 2, 1)
|
||||||
if options:
|
if options:
|
||||||
|
|
@ -66,7 +67,7 @@ class WeboobCfg(ReplApplication):
|
||||||
try:
|
try:
|
||||||
key, value = option.split('=', 1)
|
key, value = option.split('=', 1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print >>self.stderr, 'Parameters have to be formatted "key=value"'
|
print('Parameters have to be formatted "key=value"', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
params[key] = value
|
params[key] = value
|
||||||
|
|
||||||
|
|
@ -96,16 +97,16 @@ class WeboobCfg(ReplApplication):
|
||||||
try:
|
try:
|
||||||
backend = self.weboob.get_backend(backend_name)
|
backend = self.weboob.get_backend(backend_name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print >>self.stderr, 'Error: backend "%s" not found.' % backend_name
|
print('Error: backend "%s" not found.' % backend_name, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if not backend.has_caps(CapAccount):
|
if not backend.has_caps(CapAccount):
|
||||||
print >>self.stderr, 'Error: backend "%s" does not support accounts management' % backend_name
|
print('Error: backend "%s" does not support accounts management' % backend_name, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
mail = self.acquire_input()
|
mail = self.acquire_input()
|
||||||
if not backend.confirm_account(mail):
|
if not backend.confirm_account(mail):
|
||||||
print >>self.stderr, 'Error: Unable to confirm account creation'
|
print('Error: Unable to confirm account creation', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
@ -141,14 +142,14 @@ class WeboobCfg(ReplApplication):
|
||||||
Remove a backend.
|
Remove a backend.
|
||||||
"""
|
"""
|
||||||
if not self.weboob.backends_config.remove_backend(instance_name):
|
if not self.weboob.backends_config.remove_backend(instance_name):
|
||||||
print >>self.stderr, 'Backend instance "%s" does not exist' % instance_name
|
print('Backend instance "%s" does not exist' % instance_name, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def _do_toggle(self, name, state):
|
def _do_toggle(self, name, state):
|
||||||
try:
|
try:
|
||||||
bname, items = self.weboob.backends_config.get_backend(name)
|
bname, items = self.weboob.backends_config.get_backend(name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print >>self.stderr, 'Backend instance "%s" does not exist' % name
|
print('Backend instance "%s" does not exist' % name, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
self.weboob.backends_config.edit_backend(name, bname, {'_enabled': state})
|
self.weboob.backends_config.edit_backend(name, bname, {'_enabled': state})
|
||||||
|
|
||||||
|
|
@ -177,7 +178,7 @@ class WeboobCfg(ReplApplication):
|
||||||
try:
|
try:
|
||||||
self.edit_backend(line)
|
self.edit_backend(line)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print >>self.stderr, 'Error: backend "%s" not found' % line
|
print('Error: backend "%s" not found' % line, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def do_modules(self, line):
|
def do_modules(self, line):
|
||||||
|
|
@ -201,12 +202,12 @@ class WeboobCfg(ReplApplication):
|
||||||
Display information about a module.
|
Display information about a module.
|
||||||
"""
|
"""
|
||||||
if not line:
|
if not line:
|
||||||
print >>self.stderr, 'You must specify a module name. Hint: use the "modules" command.'
|
print('You must specify a module name. Hint: use the "modules" command.', file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
minfo = self.weboob.repositories.get_module_info(line)
|
minfo = self.weboob.repositories.get_module_info(line)
|
||||||
if not minfo:
|
if not minfo:
|
||||||
print >>self.stderr, 'Module "%s" does not exist.' % line
|
print('Module "%s" does not exist.' % line, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -214,16 +215,16 @@ class WeboobCfg(ReplApplication):
|
||||||
except ModuleLoadError:
|
except ModuleLoadError:
|
||||||
module = None
|
module = None
|
||||||
|
|
||||||
print '.------------------------------------------------------------------------------.'
|
print('.------------------------------------------------------------------------------.')
|
||||||
print '| Module %-69s |' % minfo.name
|
print('| Module %-69s |' % minfo.name)
|
||||||
print "+-----------------.------------------------------------------------------------'"
|
print("+-----------------.------------------------------------------------------------'")
|
||||||
print '| Version | %s' % minfo.version
|
print('| Version | %s' % minfo.version)
|
||||||
print '| Maintainer | %s' % minfo.maintainer
|
print('| Maintainer | %s' % minfo.maintainer)
|
||||||
print '| License | %s' % minfo.license
|
print('| License | %s' % minfo.license)
|
||||||
print '| Description | %s' % minfo.description
|
print('| Description | %s' % minfo.description)
|
||||||
print '| Capabilities | %s' % ', '.join(minfo.capabilities)
|
print('| Capabilities | %s' % ', '.join(minfo.capabilities))
|
||||||
print '| Installed | %s%s' % (('yes' if module else 'no'), ' (new version available)' if self.weboob.repositories.versions.get(minfo.name) > minfo.version else '')
|
print('| Installed | %s%s' % (('yes' if module else 'no'), ' (new version available)' if self.weboob.repositories.versions.get(minfo.name) > minfo.version else ''))
|
||||||
print '| Location | %s' % (minfo.url or os.path.join(minfo.path, minfo.name))
|
print('| Location | %s' % (minfo.url or os.path.join(minfo.path, minfo.name)))
|
||||||
if module:
|
if module:
|
||||||
first = True
|
first = True
|
||||||
for key, field in module.config.iteritems():
|
for key, field in module.config.iteritems():
|
||||||
|
|
@ -231,12 +232,12 @@ class WeboobCfg(ReplApplication):
|
||||||
if not field.default is None:
|
if not field.default is None:
|
||||||
value += ' (default: %s)' % field.default
|
value += ' (default: %s)' % field.default
|
||||||
if first:
|
if first:
|
||||||
print '| | '
|
print('| | ')
|
||||||
print '| Configuration | %s: %s' % (key, value)
|
print('| Configuration | %s: %s' % (key, value))
|
||||||
first = False
|
first = False
|
||||||
else:
|
else:
|
||||||
print '| | %s: %s' % (key, value)
|
print('| | %s: %s' % (key, value))
|
||||||
print "'-----------------'"
|
print("'-----------------'")
|
||||||
|
|
||||||
def do_applications(self, line):
|
def do_applications(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -252,7 +253,7 @@ class WeboobCfg(ReplApplication):
|
||||||
m = regexp.match(root)
|
m = regexp.match(root)
|
||||||
if m and '__init__.py' in files:
|
if m and '__init__.py' in files:
|
||||||
applications.add(m.group(1))
|
applications.add(m.group(1))
|
||||||
print ' '.join(sorted(applications)).encode('utf-8')
|
print(' '.join(sorted(applications)).encode('utf-8'))
|
||||||
|
|
||||||
def do_update(self, line):
|
def do_update(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# 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.application.repl import ReplApplication
|
from weboob.tools.application.repl import ReplApplication
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ class WeboobCli(ReplApplication):
|
||||||
|
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
if len(argv) < 3:
|
if len(argv) < 3:
|
||||||
print >>self.stderr, "Syntax: %s capability method [args ..]" % argv[0]
|
print("Syntax: %s capability method [args ..]" % argv[0], file=self.stderr)
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
cap_s = argv[1]
|
cap_s = argv[1]
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# 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 optparse import OptionGroup
|
from optparse import OptionGroup
|
||||||
|
|
||||||
|
|
@ -48,12 +49,12 @@ class WeboobDebug(Application):
|
||||||
try:
|
try:
|
||||||
backend_name = argv[1]
|
backend_name = argv[1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print >>self.stderr, 'Usage: %s BACKEND' % argv[0]
|
print('Usage: %s BACKEND' % argv[0], file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
try:
|
try:
|
||||||
backend = self.weboob.load_backends(names=[backend_name])[backend_name]
|
backend = self.weboob.load_backends(names=[backend_name])[backend_name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print >>self.stderr, u'Unable to load backend "%s"' % backend_name
|
print(u'Unable to load backend "%s"' % backend_name, file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
locs = dict(backend=backend, browser=backend.browser, application=self, weboob=self.weboob)
|
locs = dict(backend=backend, browser=backend.browser, application=self, weboob=self.weboob)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# 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 datetime import datetime
|
from datetime import datetime
|
||||||
from time import mktime, strptime
|
from time import mktime, strptime
|
||||||
|
|
@ -69,14 +69,14 @@ class WeboobRepos(ReplApplication):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
elif not os.path.isdir(path):
|
elif not os.path.isdir(path):
|
||||||
print u'"%s" is not a directory' % path
|
print(u'"%s" is not a directory' % path)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
r = Repository('http://')
|
r = Repository('http://')
|
||||||
r.name = name
|
r.name = name
|
||||||
r.maintainer = self.ask('Enter maintainer of the repository')
|
r.maintainer = self.ask('Enter maintainer of the repository')
|
||||||
r.save(os.path.join(path, r.INDEX))
|
r.save(os.path.join(path, r.INDEX))
|
||||||
print u'Repository "%s" created.' % path
|
print(u'Repository "%s" created.' % path)
|
||||||
|
|
||||||
def do_build(self, line):
|
def do_build(self, line):
|
||||||
"""
|
"""
|
||||||
|
|
@ -95,8 +95,8 @@ class WeboobRepos(ReplApplication):
|
||||||
with open(index_file, 'r') as fp:
|
with open(index_file, 'r') as fp:
|
||||||
r.parse_index(fp)
|
r.parse_index(fp)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to open repository: %s' % e
|
print('Unable to open repository: %s' % e, file=self.stderr)
|
||||||
print >>self.stderr, 'Use the "create" command before.'
|
print('Use the "create" command before.', file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
r.build_index(source_path, index_file)
|
r.build_index(source_path, index_file)
|
||||||
|
|
@ -110,13 +110,13 @@ class WeboobRepos(ReplApplication):
|
||||||
if os.path.exists(krname):
|
if os.path.exists(krname):
|
||||||
kr_mtime = int(datetime.fromtimestamp(os.path.getmtime(krname)).strftime('%Y%m%d%H%M'))
|
kr_mtime = int(datetime.fromtimestamp(os.path.getmtime(krname)).strftime('%Y%m%d%H%M'))
|
||||||
if not os.path.exists(krname) or kr_mtime < r.key_update:
|
if not os.path.exists(krname) or kr_mtime < r.key_update:
|
||||||
print 'Generate keyring'
|
print('Generate keyring')
|
||||||
# Remove all existing keys
|
# Remove all existing keys
|
||||||
if os.path.exists(krname):
|
if os.path.exists(krname):
|
||||||
os.remove(krname)
|
os.remove(krname)
|
||||||
# Add all valid keys
|
# Add all valid keys
|
||||||
for keyfile in os.listdir(os.path.join(source_path, r.KEYDIR)):
|
for keyfile in os.listdir(os.path.join(source_path, r.KEYDIR)):
|
||||||
print 'Adding key %s' % keyfile
|
print('Adding key %s' % keyfile)
|
||||||
keypath = os.path.join(source_path, r.KEYDIR, keyfile)
|
keypath = os.path.join(source_path, r.KEYDIR, keyfile)
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
gpg,
|
gpg,
|
||||||
|
|
@ -134,7 +134,7 @@ class WeboobRepos(ReplApplication):
|
||||||
os.chmod(krname, 0o644)
|
os.chmod(krname, 0o644)
|
||||||
os.utime(krname, (kr_mtime, kr_mtime))
|
os.utime(krname, (kr_mtime, kr_mtime))
|
||||||
else:
|
else:
|
||||||
print 'Keyring is up to date'
|
print('Keyring is up to date')
|
||||||
|
|
||||||
for name, module in r.modules.iteritems():
|
for name, module in r.modules.iteritems():
|
||||||
tarname = os.path.join(repo_path, '%s.tar.gz' % name)
|
tarname = os.path.join(repo_path, '%s.tar.gz' % name)
|
||||||
|
|
@ -146,7 +146,7 @@ class WeboobRepos(ReplApplication):
|
||||||
if tar_mtime >= module.version:
|
if tar_mtime >= module.version:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print 'Create archive for %s' % name
|
print('Create archive for %s' % name)
|
||||||
with closing(tarfile.open(tarname, 'w:gz')) as tar:
|
with closing(tarfile.open(tarname, 'w:gz')) as tar:
|
||||||
tar.add(module_path, arcname=name, exclude=self._archive_excludes)
|
tar.add(module_path, arcname=name, exclude=self._archive_excludes)
|
||||||
tar_mtime = mktime(strptime(str(module.version), '%Y%m%d%H%M'))
|
tar_mtime = mktime(strptime(str(module.version), '%Y%m%d%H%M'))
|
||||||
|
|
@ -195,7 +195,7 @@ class WeboobRepos(ReplApplication):
|
||||||
if os.path.exists(sigpath):
|
if os.path.exists(sigpath):
|
||||||
sig_mtime = int(os.path.getmtime(sigpath))
|
sig_mtime = int(os.path.getmtime(sigpath))
|
||||||
if not os.path.exists(sigpath) or sig_mtime < file_mtime:
|
if not os.path.exists(sigpath) or sig_mtime < file_mtime:
|
||||||
print 'Signing %s' % filename
|
print('Signing %s' % filename)
|
||||||
if os.path.exists(sigpath):
|
if os.path.exists(sigpath):
|
||||||
os.remove(sigpath)
|
os.remove(sigpath)
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
|
|
@ -207,7 +207,7 @@ class WeboobRepos(ReplApplication):
|
||||||
'--output', sigpath,
|
'--output', sigpath,
|
||||||
'--sign', filepath])
|
'--sign', filepath])
|
||||||
os.utime(sigpath, (file_mtime, file_mtime))
|
os.utime(sigpath, (file_mtime, file_mtime))
|
||||||
print 'Signatures are up to date'
|
print('Signatures are up to date')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _find_gpg():
|
def _find_gpg():
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# 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.capabilities.torrent import CapTorrent, MagnetOnly
|
from weboob.capabilities.torrent import CapTorrent, MagnetOnly
|
||||||
from weboob.tools.application.repl import ReplApplication, defaultcount
|
from weboob.tools.application.repl import ReplApplication, defaultcount
|
||||||
|
|
@ -116,7 +116,7 @@ class Weboorrents(ReplApplication):
|
||||||
"""
|
"""
|
||||||
torrent = self.get_object(id, 'get_torrent', ('description', 'files'))
|
torrent = self.get_object(id, 'get_torrent', ('description', 'files'))
|
||||||
if not torrent:
|
if not torrent:
|
||||||
print >>self.stderr, 'Torrent not found: %s' % id
|
print('Torrent not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
self.start_format()
|
self.start_format()
|
||||||
|
|
@ -141,7 +141,7 @@ class Weboorrents(ReplApplication):
|
||||||
|
|
||||||
torrent = self.get_object(id, 'get_torrent', ('description', 'files'))
|
torrent = self.get_object(id, 'get_torrent', ('description', 'files'))
|
||||||
if not torrent:
|
if not torrent:
|
||||||
print >>self.stderr, 'Torrent not found: %s' % id
|
print('Torrent not found: %s' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
dest = self.obj_to_filename(torrent, dest, '{id}-{name}.torrent')
|
dest = self.obj_to_filename(torrent, dest, '{id}-{name}.torrent')
|
||||||
|
|
@ -150,26 +150,26 @@ class Weboorrents(ReplApplication):
|
||||||
for backend, buf in self.do('get_torrent_file', torrent.id, backends=torrent.backend):
|
for backend, buf in self.do('get_torrent_file', torrent.id, backends=torrent.backend):
|
||||||
if buf:
|
if buf:
|
||||||
if dest == '-':
|
if dest == '-':
|
||||||
print buf
|
print(buf)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(dest, 'w') as f:
|
with open(dest, 'w') as f:
|
||||||
f.write(buf)
|
f.write(buf)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print >>self.stderr, 'Unable to write .torrent in "%s": %s' % (dest, e)
|
print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr)
|
||||||
return 1
|
return 1
|
||||||
return
|
return
|
||||||
except CallErrors as errors:
|
except CallErrors as errors:
|
||||||
for backend, error, backtrace in errors:
|
for backend, error, backtrace in errors:
|
||||||
if isinstance(error, MagnetOnly):
|
if isinstance(error, MagnetOnly):
|
||||||
print >>self.stderr, u'Error(%s): No direct URL available, ' \
|
print(u'Error(%s): No direct URL available, ' \
|
||||||
u'please provide this magnet URL ' \
|
u'please provide this magnet URL ' \
|
||||||
u'to your client:\n%s' % (backend, error.magnet)
|
u'to your client:\n%s' % (backend, error.magnet), file=self.stderr)
|
||||||
return 4
|
return 4
|
||||||
else:
|
else:
|
||||||
self.bcall_error_handler(backend, error, backtrace)
|
self.bcall_error_handler(backend, error, backtrace)
|
||||||
|
|
||||||
print >>self.stderr, 'Torrent "%s" not found' % id
|
print('Torrent "%s" not found' % id, file=self.stderr)
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
@defaultcount(10)
|
@defaultcount(10)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue