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'
23# This will get replaced with a git SHA1 when you do a git archive
24__revision__ = '$Format:%H$'
26from PyQt4.QtCore import *
27from PyQt4.QtGui import *
30from qgis.core import QgsApplication
31from processing.core.ProcessingLog import ProcessingLog
32from processing.core.ProcessingConfig import ProcessingConfig
33from 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