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$'
31 from processing.core.ProcessingLog
import ProcessingLog
32 from processing.core.ProcessingConfig
import ProcessingConfig
33 from processing.tools.system
import isWindows, isMac, userFolder
37 PKTOOLS_FOLDER =
"PKTOOLS_FOLDER"
41 folder = ProcessingConfig.getSetting(pktoolsUtils.PKTOOLS_FOLDER)
43 if folder
is None or folder ==
'':
45 testfolder = os.path.join(os.path.dirname(QgsApplication.prefixPath()),
'pktools')
46 testfolder = os.path.join(testfolder,
'bin')
47 if os.path.exists(os.path.join(testfolder,
'pkinfo')):
51 testfolder =
"/usr/bin"
52 if os.path.exists(os.path.join(testfolder,
"pkinfo")):
55 testfolder =
"/usr/local/bin"
56 if os.path.exists(os.path.join(testfolder,
"pkinfo")):
62 def runpktools(commands, progress):
63 settings = QSettings()
65 loglines.append(
"pktools execution console output")
66 loglines.append(commands)
67 progress.setInfo(
'pktools command:')
68 commandline =
" ".join(commands)
69 progress.setCommand(commandline)
70 proc = subprocess.Popen(
73 stdout=subprocess.PIPE,
74 stdin=open(os.devnull),
75 stderr=subprocess.STDOUT,
76 universal_newlines=
True,
78 progress.setInfo(
'pktools command output:')
80 for line
in iter(proc.readline,
""):
81 progress.setConsoleInfo(line)
83 ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
85 ProcessingLog.addToLog(ProcessingLog.LOG_INFO, commandline)
86 pktoolsUtils.consoleOutput = loglines