-
Notifications
You must be signed in to change notification settings - Fork 0
/
preparetest.py
71 lines (63 loc) · 2.05 KB
/
preparetest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'''
Enable client-side test preparation
'''
import os
import subprocess
from subprocess import PIPE, Popen
from downloadfile import downloadfile
class TestParpare():
def testtooldownload(self, url, toolname, homepath):
'''
download test tool
'''
testtool = os.path.join(homepath, 'testtool')
testtool = self.mktooldir(testtool)
filepath = downloadfile(testtool, url, toolname)
return filepath
def baseddependency(*args):
'''
Check test tool based on
'''
deletioncmdlist = []
for arg in args:
testcmd = Popen('which %s' % arg, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True)
testcmd.wait()
exitcode = testcmd.poll()
if exitcode != 0:
deletioncmdlist.append(arg)
return deletioncmdlist
def joinpath(fun):
def add_mkdir(self, default, sep, *args):
try:
default = os.path.join(default, sep.join(args))
os.makedirs(default)
except OSError:
print 'joinpath filed'
return fun(self, default, sep, *args)
return add_mkdir
@joinpath
def mkdirectory(self, default, sep, *args):
'''
Test results directory processing
'''
return os.path.abspath(default)
def mkinstalldir(self, installdir):
if os.path.exists(installdir) is False:
return self.mkdirectory(installdir, '')
else:
return installdir
def mktooldir(self, testtool):
if os.path.exists(testtool) is False:
return self.mkdirectory(testtool, '')
else:
return testtool
# testcase
# a=TestParpare()
# TestParpare.mktooldir()
# a.testtooldownload('', '')
# b=a.mkdirectory('tmp', ' ')
# print a.baseddependency('make', 'gcc', 'g++', 'java', 'hello', 'ls')
# testtool = a.mkdirectory('testtool', '' )
# print testtool
# a.testtooldownload('http://dl.360safe.com/360ap', '360FreeAP_Setup.exe')