qtcreator.py 2.38 KB
Newer Older
1
2
3
4
import platform;
import shutil;
import os;
import glob;
5
import atexit;
6
import codecs;
7
8
9
import subprocess;
import errno;
from datetime import datetime,timedelta;
10

11
srcPath = ''
12
SettingsPath = ''
13
tmpSettingsDir = ''
14
15
testSettings.logScreenshotOnFail = True

16
source("../../shared/utils.py")
17
source("../../shared/build_utils.py")
18
source("../../shared/mainwin.py")
19
source("../../shared/qtquick.py")
20
source("../../shared/editor_utils.py")
21

22
def waitForCleanShutdown(timeOut=10):
23
    appCtxt = currentApplicationContext()
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
    shutdownDone = False
    if platform.system() in ('Windows','Microsoft'):
        endtime = datetime.utcnow() + timedelta(seconds=timeOut)
        while not shutdownDone:
            # following work-around because os.kill() works for win not until python 2.7
            tasks = subprocess.Popen("tasklist /FI \"PID eq %d\"" % appCtxt.pid, shell=True,stdout=subprocess.PIPE)
            output = tasks.communicate()[0]
            tasks.stdout.close()
            if (output=="INFO: No tasks are running which match the specified criteria."
                or output=="" or output.find("ERROR")==0):
                shutdownDone=True
            if not shutdownDone and datetime.utcnow() > endtime:
                break
    else:
        endtime = datetime.utcnow() + timedelta(seconds=timeOut)
        while not shutdownDone:
            try:
                os.kill(appCtxt.pid,0)
            except OSError, err:
                if err.errno == errno.EPERM or err.errno == errno.ESRCH:
                    shutdownDone=True
            if not shutdownDone and datetime.utcnow() > endtime:
                break

def __removeTmpSettingsDir__():
    waitForCleanShutdown()
50
51
    deleteDirIfExists(os.path.dirname(tmpSettingsDir))

52
if platform.system() in ('Windows', 'Microsoft'):
53
    sdkPath = "C:\\QtSDK"
54
    cwd = os.getcwd()       # current dir is directory holding qtcreator.py
55
    cwd+="\\..\\..\\settings\\windows"
56
else:
57
    sdkPath = os.path.expanduser("~/QtSDK")
58
59
    cwd = os.getcwd()       # current dir is directory holding qtcreator.py
    cwd+="/../../settings/unix"
60
srcPath = sdkPath + "/src"
61
62
63
64
65
66

cwd = os.path.abspath(cwd)
tmpSettingsDir = tempDir()
tmpSettingsDir = os.path.abspath(tmpSettingsDir+"/settings")
shutil.copytree(cwd, tmpSettingsDir)
# the following only doesn't work if the test ends in an exception
67
atexit.register(__removeTmpSettingsDir__)
68
SettingsPath = " -settingspath %s" % tmpSettingsDir
69