diff --git a/plugins/import/skrooge_import_backend/org.kde.skrooge-import-backend-aqbanking.desktop b/plugins/import/skrooge_import_backend/org.kde.skrooge-import-backend-aqbanking.desktop --- a/plugins/import/skrooge_import_backend/org.kde.skrooge-import-backend-aqbanking.desktop +++ b/plugins/import/skrooge_import_backend/org.kde.skrooge-import-backend-aqbanking.desktop @@ -17,7 +17,7 @@ Name[tr]=AqBanking Arka Ucu Name[uk]=Модуль AqBanking Name[x-test]=xxAqBanking backendxx -Comment=An import backend for Skrooge using AqBanking.\n You must install AqBanking (aqbanking-cli and aqhbci-tool4) and setup all accounts manually before using this backend.\n\nAt least AqBanking version 5.6.10 or later is required. +Comment=An import backend for Skrooge using AqBanking.\n You must install AqBanking (aqbanking-cli and aqhbci-tool4) and setup all accounts manually before using this backend.\n\nAt least AqBanking version 5.6.10 or later is required.\n\nThis backend starts an AqBanking user-interactive session in the default terminal emulator.\nIf you experience issues please switch to the "xterm" terminal emulator by setting the parameters to:\naqbanking(--terminal-emulator '"xterm -e"') [Note: The single and double quotes are important!] Comment[ca]=Un dorsal d'importació per a l'Skrooge que usa AqBanking.\n Cal instal·lar AqBanking (aqbanking-cli i aqhbci-tool4) i configurar manualment tots els comptes abans d'usar aquest dorsal.\n\nEs requereix com a mínim la versió 5.6.10 o superior d'AqBanking. Comment[ca@valencia]=Un dorsal d'importació per a l'Skrooge que usa AqBanking.\n Cal instal·lar AqBanking (aqbanking-cli i aqhbci-tool4) i configurar manualment tots els comptes abans d'usar aquest dorsal.\n\nEs requereix com a mínim la versió 5.6.10 o superior d'AqBanking. Comment[en_GB]=An import backend for Skrooge using AqBanking.\n You must install AqBanking (aqbanking-cli and aqhbci-tool4) and setup all accounts manually before using this backend.\n\nAt least AqBanking version 5.6.10 or later is required. @@ -49,5 +49,5 @@ X-SKROOGE-getaccounts=skrooge-sabb.py listaccounts X-SKROOGE-getaccountid="(.*)" -X-SKROOGE-getbulk=skrooge-sabb.py bulkdownload --output_folder "%1" +X-SKROOGE-getbulk=skrooge-sabb.py bulkdownload --output_folder "%1" %parameter1 X-SKROOGE-csvcolumns=date|mode|comment|payee|amount diff --git a/plugins/import/skrooge_import_backend/skrooge-sabb.py b/plugins/import/skrooge_import_backend/skrooge-sabb.py --- a/plugins/import/skrooge_import_backend/skrooge-sabb.py +++ b/plugins/import/skrooge_import_backend/skrooge-sabb.py @@ -6,23 +6,32 @@ #* it under the terms of the GNU General Public License as published by #* the Free Software Foundation, either version 3 of the License, or #* (at your option) any later version. -#* +#* #* This program is distributed in the hope that it will be useful, #* but WITHOUT ANY WARRANTY; without even the implied warranty of #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #* GNU General Public License for more details. -#* +#* #* You should have received a copy of the GNU General Public License #* along with this program. If not, see #************************************************************************** """ Skrooge AqBanking Bridge (SABB) ------------------------------- -Authors: +Authors: * Bernhard Scheirle -""" + +Changelog: + +1.1.0 - 2018.05.21 + * Added command line parameter --terminal-emulator + +1.0.0 - 2017.07.29 + * Initial release + +""" import argparse import contextlib @@ -37,7 +46,7 @@ import tempfile from distutils.version import LooseVersion -__VERSION__ = "1.0.0" +__VERSION__ = "1.1.0" class Account(object): def __init__(self): @@ -145,7 +154,7 @@ ReturnValue_NormalExit = 0 ReturnValue_InvalidVersion = 1 - + def __init__(self): self.accounts = Accounts() @@ -278,7 +287,7 @@ writer.writerow(row) return output.getvalue() - def download(self, output_folder_path, balance, openTerminal): + def download(self, output_folder_path, balance, terminal_emulator): if not self.check_version(): return self.ReturnValue_InvalidVersion with TemporaryContextFile() as context_file_path: @@ -290,15 +299,10 @@ ] if balance: args.append('--balance') - - command = self.build_command(self.AqBanking, args) - if openTerminal: - shell_command = ['x-terminal-emulator', '-e'] - shell_command.extend(command) - command = shell_command - process = subprocess.Popen(command) - process.wait() - + + command = str.split(terminal_emulator) + command.extend(self.build_command(self.AqBanking, args)) + subprocess.run(command) output_folder_path = os.path.abspath(output_folder_path) if not os.path.exists(output_folder_path): @@ -347,13 +351,20 @@ parser_download.add_argument('--output_folder', required=True, help='The folder to store the csv files.') parser_download.add_argument('--balance', required=False, action='store_true', help='Additionally also download the current balance of all accounts and stores it in a "balance.csv" file in the output folder.') + parser_download.add_argument('--terminal-emulator', required=False, + default="x-terminal-emulator -e", + help='The terminal emulator command string that gets used to run the aqbanking user-interactive session. ' + 'Use an empty value »""« to not start a new terminal, but reuse the terminal running this command. ' + 'Example: "xterm -e". ' + '(Default: "x-terminal-emulator -e")' + ) args = parser.parse_args() if (args.command == "listaccounts"): return SABB().get_accounts() elif (args.command == "bulkdownload"): - return SABB().download(args.output_folder, args.balance, True) + return SABB().download(args.output_folder, args.balance, args.terminal_emulator) else: parser.print_help() return 1