The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit 779ed946 authored by Laurent Bachelier's avatar Laurent Bachelier 🐧 Committed by Romain Bignon

weboob script: Don't capture input if not interactive

parent 9debafde
...@@ -54,7 +54,9 @@ class Weboob(ConsoleApplication): ...@@ -54,7 +54,9 @@ class Weboob(ConsoleApplication):
UPDATE_DAYS_DELAY = 20 UPDATE_DAYS_DELAY = 20
def main(self): def main(self):
self.update() interactive = sys.stdout.isatty()
if interactive:
self.update()
capApplicationDict = self.init_CapApplicationDict() capApplicationDict = self.init_CapApplicationDict()
...@@ -69,11 +71,17 @@ class Weboob(ConsoleApplication): ...@@ -69,11 +71,17 @@ class Weboob(ConsoleApplication):
cap = sys.argv.pop(1) cap = sys.argv.pop(1)
if cap not in capApplicationDict: if cap not in capApplicationDict:
print('Unknown capability, please choose one in the following list') if interactive:
cap = self.choose_capability(capApplicationDict) print('Unknown capability, please choose one in the following list')
cap = self.choose_capability(capApplicationDict)
else:
cap = None
else: else:
cap = self.choose_capability(capApplicationDict) if interactive:
cap = self.choose_capability(capApplicationDict)
else:
cap = None
def appsortkey(app): def appsortkey(app):
if issubclass(app, QtApplication): if issubclass(app, QtApplication):
...@@ -81,10 +89,14 @@ class Weboob(ConsoleApplication): ...@@ -81,10 +89,14 @@ class Weboob(ConsoleApplication):
else: else:
return '0' + app.APPNAME return '0' + app.APPNAME
applications = capApplicationDict[cap] if cap:
applications = sorted(set(applications), key=appsortkey) applications = capApplicationDict[cap]
application = applications[0] if len(applications) == 1 else self.choose_application(applications) applications = sorted(set(applications), key=appsortkey)
application.run() application = applications[0] if len(applications) == 1 else self.choose_application(applications)
application.run()
else:
print('Please provide a capability.')
def cmd_update(self): def cmd_update(self):
self.weboob.update() self.weboob.update()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment