4 ***************************************************************************
8 Copyright : (C) 2015 by Pieter Kempeneers
9 Email : kempenep at gmail dot com
10 ***************************************************************************
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
17 ***************************************************************************
20 __author__ =
'Pieter Kempeneers'
21 __date__ =
'April 2015'
22 __copyright__ =
'(C) 2015, Pieter Kempeneers'
24 __revision__ =
'$Format:%H$'
30 from processing.core.ProcessingLog
import ProcessingLog
31 from processing.core.ProcessingConfig
import ProcessingConfig
35 PKTOOLS_FOLDER =
"PKTOOLS_FOLDER"
39 folder = ProcessingConfig.getSetting(pktoolsUtils.PKTOOLS_FOLDER)
41 folder = unicode(
'/usr/local/bin')
42 return os.path.abspath(folder)
45 def runpktools(commands, progress):
46 settings = QSettings()
48 loglines.append(
"pktools execution console output")
49 loglines.append(commands)
50 progress.setInfo(
'pktools command:')
51 commandline =
" ".join(commands)
52 progress.setCommand(commandline)
53 proc = subprocess.Popen(
56 stdout=subprocess.PIPE,
57 stdin=open(os.devnull),
58 stderr=subprocess.STDOUT,
59 universal_newlines=
True,
61 progress.setInfo(
'pktools command output:')
69 for line
in iter(proc.readline,
""):
70 progress.setConsoleInfo(line)
72 ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
78 ProcessingLog.addToLog(ProcessingLog.LOG_INFO, commandline)
79 pktoolsUtils.consoleOutput = loglines