import os, time
from common import getResult as GR
from common import interfaceTest as INTF
from common import readTestCase as RT
import readConfig as config

caselist = []  #用于存放获取的测试用例
result = GR.getResult()  #创建生成结果的对象
con = config.Readconfig()  #创建读取配置文件的对象
testcase = RT.readTestCase()  #创建读取测试用例的对象
interface = INTF.interfaceTest()  #创建执行测试的对象

username = con.get_email("testuser")  #读取config文件中的testuser参数

path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
casePath = '%s/testCase/testcase.xls' % path

caselist = testcase.getCase(casePath)  #获取文件的测试用例
res_flag, fail_tips, testtime = interface.interfaceTest(caselist)  #执行测试用例
result_path = result.copy_execl(casePath, res_flag, fail_tips)  #生成测试结果的excel文件
caselist1 = testcase.getCase(result_path)
report_path = '%s/result/%s_report.html' % (path, time.strftime('%Y%m%d%H%M'))
titles = "%s_接口測試報告" % time.strftime('%Y%m%d')


def getnum():
    passNum = 0
    failNum = 0
    casenum = len(caselist1)
    for i in range(casenum):
        if caselist1[i][7] == 'pass':
#coding=utf-8
#author='Shichao-Dong'

import os
import readConfig
from logs import log

conf = readConfig.Readconfig()
log = log()


class devices:
    def __init__(self):
        self.get_device = conf.getcmdValue('viewPhone')
        self.get_Version = conf.getcmdValue('viewAndroid')
        self.startServer = conf.getcmdValue('startServer')

    def get_deviceName(self):
        values = os.popen(self.get_device).readlines()
        dev = values[1].split()[0]
        if len(values) - 2 == 1:
            print dev
            log.info('手机设备为:' + dev)
            return dev
        else:
            log.warn('暂未获取到手机设备')
            print 'No device found'

    def get_platformVersion(self):
        values = os.popen(self.get_Version).readlines()