# coding=utf-8
__author__ = '875747'


import yaml
import os
import sys
import string
import random
import re
import paramiko
import time
import pexpect
import sys
import paramiko
import socket

class MyLibrary():
    def helloLibrary(self):
        '''
        示例调用:print 'hello Library'
        '''
        print 'hello Library'
        print os.listdir(os.path.split(os.path.realpath( sys.argv[0]))[0])
        print os.listdir(os.getcwd())

    def getIDStr(self,givenStr=""):
        '''
        如果有传入值则返回传入值+5位随机字符,无传入值则返回15位随机数
        '''
        if(givenStr!=""):
            randomStr= givenStr+"_"+string.join(random.sample('ABCDEFGHIGKLMNOPQRSTUVWXYZzyxwvutsrqponmlkjihgfedcba1234567890',5)).replace(' ','')
        else:
            randomStr= string.join(random.sample('ABCDEFGHIGKLMNOPQRSTUVWXYZzyxwvutsrqponmlkjihgfedcba1234567890',15)).replace(' ','')
        randomStr= randomStr.replace(' ','')
        return randomStr
    def joinStr(self,str1,str2):
        return str1+str2
    def joinStrPro(self,*args):
        str=""
        for i in args:
            str = str+i
        return str
    def regexStr(self,regex,str,defaultData = ""):
        '''
        :param regex: 正则表达式
        选择左右边界,把要替换的字符串替换为(.*);
        无左边界开头用^,无右边界结尾用$。
        :param str: 要提取的字符串
        :param defaultData: 提取不到的默认值
        :return: 提取到的子串
        '''
        match = re.search(regex, str)
        if match:
            result = match.group(1)
        else:
            result = defaultData
        return result
    def getMobileRegisterCode(self,mobile):
        '''
        注册手机验证码
        :param mobile: 注册手机号:
        :return: 验证码
        '''
        reload(sys)
        sys.setdefaultencoding('utf-8')
        # 验证码
        # cat business.log | grep 13246600009 | grep 注册验证码 | tail -n1 | sed 's/.*验证码为\(.*\),有效期.*/\1/g'
        # 日期
        # cat business.log | grep 13246600009 | grep 注册验证码 | tail -n1 | awk -F 'print $1'
        codeCmd = "cat /app/applogs/member/business/business.log | grep "+mobile+" | grep 注册验证码 | tail -n1 | sed 's/.*验证码为\(.*\),有效期.*/\\1/g'"
        codeCmd = codeCmd.decode('utf-8')
        # print codeCmd
        dateCmd = "cat /app/applogs/member/business/business.log | grep "+mobile+" | grep 注册验证码 | tail -n1 | awk -F '[' '{print $4}' | tr -d ']'"
        dateCmd = dateCmd.decode('utf-8')
        # print dateCmd
        codeList = self._shhServer('10.202.18.27',22,'appdeploy','sf123456',codeCmd)
        dateList = self._shhServer('10.202.18.27',22,'appdeploy','sf123456',dateCmd)
        codeList1 = self._shhServer('10.202.18.28',22,'appdeploy','sf123456',codeCmd)
        dateList1 = self._shhServer('10.202.18.28',22,'appdeploy','sf123456',dateCmd)
        # print codeList,codeList1,dateList,dateList1
        if len(codeList) == 0 and len(codeList1) != 0:
            return codeList1[0]
        elif len(codeList1) == 0 and len(codeList) != 0:
            return codeList[0]
        elif len(codeList) != 0 and len(codeList1) != 0:
            a = (dateList[len(dateList)-1]).split(',')[0]
            b = (((dateList[len(dateList)-1]).split(',')[1]).replace('\n','')).replace(' ','')
            t= time.mktime(time.strptime(a,'%Y-%m-%d %H:%M:%S')) + float(b)/1000
            a1 = (dateList1[len(dateList1)-1]).split(',')[0]
            b1 = (((dateList1[len(dateList1)-1]).split(',')[1]).replace('\n','')).replace(' ','')
            t1= time.mktime(time.strptime(a1,'%Y-%m-%d %H:%M:%S')) + float(b1)/1000
            if t > t1:
                return  codeList[0]
            else:
                return  codeList1[0]
    def _shhServer(self,ip,port,username,password,cmd):
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        try:
            ssh.connect(ip,port,username,password)
            stdin,stdout,stderr = ssh.exec_command(cmd)
            returnList = stdout.readlines()
            ssh.close()
            return returnList
        except socket.error:
            print 'error'
    def getMobileNumber(self,mobileHeader = '132'):
        a = str(int(time.time()))[-8:]
        return mobileHeader+a
    def getLoginCode(self,mobile):
        '''
        个人用户手机验证码登录验证码
        :param mobile: 手机号
        :return: 验证码
        '''
        reload(sys)
        sys.setdefaultencoding('utf-8')
        # 验证码
        # cat business.log | grep 13246600009 | grep 手机验证码 | tail -n1 | sed 's/.*验证码为\(.*\),有效期.*/\1/g'
        # 日期
        # cat business.log | grep 13246600009 | grep 手机验证码 | tail -n1 | awk -F 'print $1'
        codeCmd = "cat /app/applogs/member/business/business.log | grep "+mobile+" | grep 手机验证码 | tail -n1 | sed 's/.*验证码为\(.*\),有效期.*/\\1/g'"
        codeCmd = codeCmd.decode('utf-8')
        # print codeCmd
        dateCmd = "cat /app/applogs/member/business/business.log | grep "+mobile+" | grep 手机验证码 | tail -n1 | awk -F '[' '{print $4}' | tr -d ']'"
        dateCmd = dateCmd.decode('utf-8')
        # print dateCmd
        codeList = self._shhServer('10.202.18.27',22,'appdeploy','sf123456',codeCmd)
        dateList = self._shhServer('10.202.18.27',22,'appdeploy','sf123456',dateCmd)
        codeList1 = self._shhServer('10.202.18.28',22,'appdeploy','sf123456',codeCmd)
        dateList1 = self._shhServer('10.202.18.28',22,'appdeploy','sf123456',dateCmd)
        # print codeList,codeList1,dateList,dateList1
        if len(codeList) == 0 and len(codeList1) != 0:
            return codeList1[0]
        elif len(codeList1) == 0 and len(codeList) != 0:
            return codeList[0]
        elif len(codeList) != 0 and len(codeList1) != 0:
            a = (dateList[len(dateList)-1]).split(',')[0]
            b = (((dateList[len(dateList)-1]).split(',')[1]).replace('\n','')).replace(' ','')
            t= time.mktime(time.strptime(a,'%Y-%m-%d %H:%M:%S')) + float(b)/1000
            a1 = (dateList1[len(dateList1)-1]).split(',')[0]
            b1 = (((dateList1[len(dateList1)-1]).split(',')[1]).replace('\n','')).replace(' ','')
            t1= time.mktime(time.strptime(a1,'%Y-%m-%d %H:%M:%S')) + float(b1)/1000
            if t > t1:
                return  codeList[0]
            else:
                return  codeList1[0]
    def IsnPictureCode(self):
        '''
        邮箱验证图片验证码
        :return:
        '''
    #     验证码cat /app/applogs/member/business/business.log | grep "+mobile+" | grep 手机号验证码 | tail -n1 | awk -F '[' '{print $4}' | tr -d ']'"
    #     cat /app/applogs/member/user/user.log | grep 随机验证码 | tail -n1 |awk -F '[' '{print $7}' |tr -d ']'|sed 's/^随机验证码:\(....$\)/\1/g'
    #     时间
    #     cat /app/applogs/member/user/user.log | grep 随机验证码 | tail -n1 | awk -F '[' '{print $4}' | tr -d ']'
        reload(sys)
        sys.setdefaultencoding('utf-8')
        codeCmd = "cat /app/applogs/member/user/user.log | grep 随机验证码 | tail -n1 | sed 's/.*随机验证码:\(.*\), session id.*/\\1/g'"
        dateCmd = "cat /app/applogs/member/user/user.log | grep 随机验证码 | tail -n1 | awk -F '[' '{print $4}' | tr -d ']'"
        codeCmd = codeCmd.decode('utf-8')
        dateCmd = codeCmd.decode('utf-8')
        # print codeCmd
        # print dateCmd
        codeList = self._shhServer('10.202.84.47',22,'appdeploy','sf123456',codeCmd)
        dateList = self._shhServer('10.202.84.47',22,'appdeploy','sf123456',dateCmd)
        codeList1 = self._shhServer('10.202.84.48',22,'appdeploy','sf123456',codeCmd)
        dateList1 = self._shhServer('10.202.84.48',22,'appdeploy','sf123456',dateCmd)
        # print codeList,dateList,codeList1,dateList1
        if codeList1<>'error' and dateList1<>'error':
            return  self._compareDate(codeList,dateList,codeList1,dateList1)
        else:
            return codeList[0]
    def IsnRegistPictureCode(self):
        '''
        图片验证码
        :return:
        '''
    #     验证码cat /app/applogs/member/business/business.log | grep "+mobile+" | grep 手机号验证码 | tail -n1 | awk -F '[' '{print $4}' | tr -d ']'"
    #     cat /app/applogs/member/user/user.log | grep 随机验证码 | tail -n1 |awk -F '[' '{print $7}' |tr -d ']'|sed 's/^随机验证码:\(....$\)/\1/g'
    #     时间
    #     cat /app/applogs/member/user/user.log | grep 随机验证码 | tail -n1 | awk -F '[' '{print $4}' | tr -d ']'
        reload(sys)
        sys.setdefaultencoding('utf-8')
        codeCmd = "cat /app/applogs/member/user/user.log | grep 图片验证码 | tail -n1 | sed 's/.*图片验证码:\(.*\)\].*/\\1/g'"
        dateCmd = "cat /app/applogs/member/user/user.log | grep 图片验证码 | tail -n1 | awk -F '[' '{print $4}' | tr -d ']'"
        codeCmd = codeCmd.decode('utf-8')
        dateCmd = codeCmd.decode('utf-8')
        # print codeCmd
        # print dateCmd
        codeList = self._shhServer('10.202.84.47',22,'appdeploy','sf123456',codeCmd)
        dateList = self._shhServer('10.202.84.47',22,'appdeploy','sf123456',dateCmd)
        codeList1 = self._shhServer('10.202.84.48',22,'appdeploy','sf123456',codeCmd)
        dateList1 = self._shhServer('10.202.84.48',22,'appdeploy','sf123456',dateCmd)
        # print codeList,dateList,codeList1,dateList1
        if codeList1<>'error' and dateList1<>'error':
            return  self._compareDate(codeList,dateList,codeList1,dateList1)
        else:
            return codeList[0]
    def _compareDate(self,codeList,dateList,codeList1,dateList1):
        if len(codeList) == 0 and len(codeList1) != 0:
            return codeList1[0]
        elif len(codeList1) == 0 and len(codeList) != 0:
            return codeList[0]
        elif len(codeList) != 0 and len(codeList1) != 0:
            a = (dateList[len(dateList)-1]).split(',')[0]
            b = (((dateList[len(dateList)-1]).split(',')[1]).replace('\n','')).replace(' ','')
            t= time.mktime(time.strptime(a,'%Y-%m-%d %H:%M:%S')) + float(b)/1000
            a1 = (dateList1[len(dateList1)-1]).split(',')[0]
            b1 = (((dateList1[len(dateList1)-1]).split(',')[1]).replace('\n','')).replace(' ','')
            t1= time.mktime(time.strptime(a1,'%Y-%m-%d %H:%M:%S')) + float(b1)/1000
            if t > t1:
                return  codeList[0]
            else:
                return  codeList1[0]
    def changeMailHref(self,email):
        reload(sys)
        sys.setdefaultencoding('utf-8')
        # cat /app/applogs/member/email_bind/email_bind.log |grep -A 23 123@qq.com |tail -n1|awk -F '[<>]' '{print $5}'
        # cat /app/applogs/member/email_bind/email_bind.log |grep 123@qq.com |tail -n1 |awk -F '[' '{print $5}' | tr -d ']'
        codeCmd = "cat /app/applogs/member/email_bind/email_bind.log |grep -A 23 "+email+" |tail -n1|awk -F '[<>]' '{print $5}'"
        dateCmd = "cat /app/applogs/member/email_bind/email_bind.log |grep "+email+"|tail -n1 |awk -F '[' '{print $4}' | tr -d ']'"
        codeCmd = codeCmd.decode('utf-8')
        dateCmd = dateCmd.decode('utf-8')
        # print codeCmd
        # print dateCmd
        codeList = self._shhServer('10.202.18.27',22,'appdeploy','sf123456',codeCmd)
        dateList = self._shhServer('10.202.18.27',22,'appdeploy','sf123456',dateCmd)
        codeList1 = self._shhServer('10.202.18.28',22,'appdeploy','sf123456',codeCmd)
        dateList1 = self._shhServer('10.202.18.28',22,'appdeploy','sf123456',dateCmd)
        # print codeList,dateList,codeList1,dateList1
        return self._compareDate(codeList,dateList,codeList1,dateList1)
    def exeCmd(self,codeCmd,dateCmd,ip1='10.202.18.27',ip2='10.202.18.28'):
        reload(sys)
        sys.setdefaultencoding('utf-8')
        codeCmd = codeCmd.decode('utf-8')
        dateCmd = dateCmd.decode('utf-8')
        codeList = self._shhServer(ip1,22,'appdeploy','sf123456',codeCmd)
        dateList = self._shhServer(ip1,22,'appdeploy','sf123456',dateCmd)
        codeList1 = self._shhServer(ip2,22,'appdeploy','sf123456',codeCmd)
        dateList1 = self._shhServer(ip2,22,'appdeploy','sf123456',dateCmd)
        return self._compareDate(codeList,dateList,codeList1,dateList1)

    def splitStr(self,sStr1,sStr2,sInt):
        '''
        字符串拆分
        '''
        sInt = int(sInt)
        sStr1 = sStr1.split(sStr2)[sInt]
        return sStr1

    def openStr(self,strCode,int1,int2):
        '''
        字符串截取
        '''
        int1 = int(int1)
        int2 = int(int2)
        strCode = strCode[int1:int2]
        strCode = str(strCode)
        return strCode

    def get_result(self,arg1,arg2):
        '''
        获取测试结果判断并返回
        '''    
        arg1 = str(arg1)
        arg2 = str(arg2)
        if arg1 == arg2:
            return 'LOG'
        else:
            return 'FAIL'

    def est_Str(self,str1,str2):
        '''
        判断字符1 是否包含字符2
        '''
        str1 = unicode(str1)
        str2 = unicode(str2)
        if str2 in str1:
            return 'PASS'
        else:
            return 'FAIL'    
            
    #coding=utf-8
    def add(a,b):
        return a+b
        
    if _name_=='_main_':
        a = add(4,5)
        print a
            
            
    def getMobileRandPwd(self,mobile):
        '''
        企业子账户注册,随机密码获取
        :param mobile: 注册手机号:
        :return: 随机密码
        '''
        reload(sys)
        sys.setdefaultencoding('utf-8')
        # 验证码
        # cat business.log | grep 13246600009 | grep 注册验证码 | tail -n1 | sed 's/.*验证码为\(.*\),有效期.*/\1/g'
        # 日期
        # cat business.log | grep 13246600009 | grep 注册验证码 | tail -n1 | awk -F 'print $1'
        codeCmd = "cat /app/applogs/member/business/business.log | grep "+mobile+" | grep 邀请您为子用户 | tail -n1 | sed 's/.*初始密码:\(.*\),请在.*/\\1/g'"
        codeCmd = codeCmd.decode('utf-8')
        # print codeCmd
        dateCmd = "cat /app/applogs/member/business/business.log | grep "+mobile+" | grep 邀请您为子用户 | tail -n1 | awk -F '[' '{print $4}' | tr -d ']'"
        dateCmd = dateCmd.decode('utf-8')
        # print dateCmd
        codeList = self._shhServer('10.202.18.27',22,'appdeploy','sf123456',codeCmd)
        dateList = self._shhServer('10.202.18.27',22,'appdeploy','sf123456',dateCmd)
        codeList1 = self._shhServer('10.202.18.28',22,'appdeploy','sf123456',codeCmd)
        dateList1 = self._shhServer('10.202.18.28',22,'appdeploy','sf123456',dateCmd)
        # print codeList,codeList1,dateList,dateList1
        if len(codeList) == 0 and len(codeList1) != 0:
            return codeList1[0].strip()
        elif len(codeList1) == 0 and len(codeList) != 0:
            return codeList[0].strip()
        elif len(codeList) != 0 and len(codeList1) != 0:
            a = (dateList[len(dateList)-1]).split(',')[0]
            b = (((dateList[len(dateList)-1]).split(',')[1]).replace('\n','')).replace(' ','')
            t= time.mktime(time.strptime(a,'%Y-%m-%d %H:%M:%S')) + float(b)/1000
            a1 = (dateList[len(dateList1)-1]).split(',')[0]
            b1 = (((dateList[len(dateList1)-1]).split(',')[1]).replace('\n','')).replace(' ','')
            t1= time.mktime(time.strptime(a,'%Y-%m-%d %H:%M:%S')) + float(b)/1000
            if t > t1:
                return  codeList[0].strip()
            else:
                return  codeList1[0].strip()



    def getRanNum(self,a):
        a = int(a)
        return str(int(time.time()))[-a:]

    #coding=utf-8
    def getRndName(self):
        '''
        生成随机姓名
        :return:
        '''
        firstName = u'赵钱孙李周吴郑王烦褚谓沈韩杨朱秦尤许何吕施张孔曹严华轿陶狡谢邹喻柏水窦章云苏潘葛奚范彭郎挛昌旅凤花方俞任袁柳酆鲍史唐费廉岑薛篮倪屉殷罗毕郝邬安常乐于时傅皮卞齐昙伏成戴谈宋茅庞熊纪舒屈项祝董梁度蓝阆季麻强贾路娄江童颜郭梅盛林刁邱夏蔡田解应宗樊胡凌霍虞万支柯旯卢目房裘缪丁宣贲邓郁单杭洪包诸左石钩嵇邢滑裴陆荣翁荀糜松井段富巫乌焦巴弓牧隗山谷澈宓湃郗班仰秋仲伊宫宁仇栾甘历孜詹束龙叶幸司韶郜黎蓟溥印宿白从端咸赖卓蔺屠蒙池乔尚农温别庄晏柴瞿阎慕寥习话容向古易慎游戈廖庾居衡步满国文寇广东欧沃利蔚越夔隆使厍年勾敖融冷訾辛阚那简饶空曾须烦关蒯相查后荆红竺权逮盍益桓佟'
        girlName = u'秀娟英华慧巧美娜静淑惠珠翠雅芝玉萍红娥玲芬芳燕彩春菊兰凤洁梅琳素云莲真环雪荣爱妹霞香月莺媛艳瑞凡佳嘉琼勤珍贞莉桂娣叶璧璐娅琦晶妍茜秋珊莎锦黛青倩婷姣婉娴瑾颖露瑶怡婵雁蓓纨仪荷丹蓉眉君琴蕊薇菁梦岚苑婕馨瑗琰韵融园艺咏卿聪澜纯毓悦昭冰爽琬茗羽希宁欣飘育滢馥筠柔竹霭凝晓欢霄枫芸菲寒伊亚宜可姬舒影荔枝思丽'
        i = random.randint(0,len(firstName)-1)
        j = random.randint(0,len(girlName)-2)
        firstName = firstName[i]
        girlName = girlName[j:j+2]
        Name = firstName+girlName
        return Name

    def getRndAddress(self):
        '''
        生成随机地址
        :return:
        '''
        Address = u'重庆大厦,黑龙江路,十梅庵街,遵义路,湘潭街,瑞金广场,仙山街,仙山东路,仙山西大厦,白沙河路,赵红广场,机场路,民航街,长城南路,流亭立交桥,虹桥广场,长城大厦,礼阳路,风岗街,中川路,白塔广场,兴阳路,文阳街,绣城路,河城大厦,锦城广场,崇阳街,华城路,康城街,正阳路,和阳广场,中城路,江城大厦,顺城路,安城街,山城广场,春城街,国城路,泰城街,德阳路,明阳大厦,春阳路,艳阳街,秋阳路,硕阳街,青威高速,瑞阳街,丰海路,双元大厦,惜福镇街道,夏庄街道,古庙工业园,中山街,太平路,广西街,潍县广场,博山大厦,湖南路,济宁街,芝罘路,易州广场,荷泽四路,荷泽二街,荷泽一路,荷泽三大厦,观海二广场,广西支街,观海一路,济宁支街,莒县路,平度广场,明水路,蒙阴大厦,青岛路,湖北街,江宁广场,郯城街,天津路,保定街,安徽路,河北大厦,黄岛路,北京街,莘县路,济南街,宁阳广场,日照街,德县路,新泰大厦,荷泽路,山西广场,沂水路,肥城街,兰山路,四方街,平原广场,泗水大厦,浙江路,曲阜街,寿康路,河南广场,泰安路,大沽街,红山峡支路,西陵峡一大厦,台西纬一广场,台西纬四街,台西纬二路,西陵峡二街,西陵峡三路,台西纬三广场,台西纬五路,明月峡大厦,青铜峡路,台西二街,观音峡广场,瞿塘峡街,团岛二路,团岛一街,台西三路,台西一大厦,郓城南路,团岛三街,刘家峡路,西藏二街,西藏一广场,台西四街,三门峡路,城武支大厦,红山峡路,郓城北广场,龙羊峡路,西陵峡街,台西五路,团岛四街,石村广场,巫峡大厦,四川路,寿张街,嘉祥路,南村广场,范县路,西康街,云南路,巨野大厦,西江广场,鱼台街,单县路,定陶街,滕县路,钜野广场,观城路,汶上大厦,朝城路,滋阳街,邹县广场,濮县街,磁山路,汶水街,西藏路,城武大厦,团岛路,南阳街,广州路,东平街,枣庄广场,贵州街,费县路,南海大厦,登州路,文登广场,信号山支路,延安一街,信号山路,兴安支街,福山支广场,红岛支大厦,莱芜二路,吴县一街,金口三路,金口一广场,伏龙山路,鱼山支街,观象二路,吴县二大厦,莱芜一广场,金口二街,海阳路,龙口街,恒山路,鱼山广场,掖县路,福山大厦,红岛路,常州街,大学广场,龙华街,齐河路,莱阳街,黄县路,张店大厦,祚山路,苏州街,华山路,伏龙街,江苏广场,龙江街,王村路,琴屿大厦,齐东路,京山广场,龙山路,牟平街,延安三路,延吉街,南京广场,东海东大厦,银川西路,海口街,山东路,绍兴广场,芝泉路,东海中街,宁夏路,香港西大厦,隆德广场,扬州街,郧阳路,太平角一街,宁国二支路,太平角二广场,天台东一路,太平角三大厦,漳州路一路,漳州街二街,宁国一支广场,太平角六街,太平角四路,天台东二街,太平角五路,宁国三大厦,澳门三路,江西支街,澳门二路,宁国四街,大尧一广场,咸阳支街,洪泽湖路,吴兴二大厦,澄海三路,天台一广场,新湛二路,三明北街,新湛支路,湛山五街,泰州三广场,湛山四大厦,闽江三路,澳门四街,南海支路,吴兴三广场,三明南路,湛山二街,二轻新村镇,江南大厦,吴兴一广场,珠海二街,嘉峪关路,高邮湖街,湛山三路,澳门六广场,泰州二路,东海一大厦,天台二路,微山湖街,洞庭湖广场,珠海支街,福州南路,澄海二街,泰州四路,香港中大厦,澳门五路,新湛三街,澳门一路,正阳关街,宁武关广场,闽江四街,新湛一路,宁国一大厦,王家麦岛,澳门七广场,泰州一路,泰州六街,大尧二路,青大一街,闽江二广场,闽江一大厦,屏东支路,湛山一街,东海西路,徐家麦岛函谷关广场,大尧三路,晓望支街,秀湛二路,逍遥三大厦,澳门九广场,泰州五街,澄海一路,澳门八街,福州北路,珠海一广场,宁国二路,临淮关大厦,燕儿岛路,紫荆关街,武胜关广场,逍遥一街,秀湛四路,居庸关街,山海关路,鄱阳湖大厦,新湛路,漳州街,仙游路,花莲街,乐清广场,巢湖街,台南路,吴兴大厦,新田路,福清广场,澄海路,莆田街,海游路,镇江街,石岛广场,宜兴大厦,三明路,仰口街,沛县路,漳浦广场,大麦岛,台湾街,天台路,金湖大厦,高雄广场,海江街,岳阳路,善化街,荣成路,澳门广场,武昌路,闽江大厦,台北路,龙岩街,咸阳广场,宁德街,龙泉路,丽水街,海川路,彰化大厦,金田路,泰州街,太湖路,江西街,泰兴广场,青大街,金门路,南通大厦,旌德路,汇泉广场,宁国路,泉州街,如东路,奉化街,鹊山广场,莲岛大厦,华严路,嘉义街,古田路,南平广场,秀湛路,长汀街,湛山路,徐州大厦,丰县广场,汕头街,新竹路,黄海街,安庆路,基隆广场,韶关路,云霄大厦,新安路,仙居街,屏东广场,晓望街,海门路,珠海街,上杭路,永嘉大厦,漳平路,盐城街,新浦路,新昌街,高田广场,市场三街,金乡东路,市场二大厦,上海支路,李村支广场,惠民南路,市场纬街,长安南路,陵县支街,冠县支广场,小港一大厦,市场一路,小港二街,清平路,广东广场,新疆路,博平街,港通路,小港沿,福建广场,高唐街,茌平路,港青街,高密路,阳谷广场,平阴路,夏津大厦,邱县路,渤海街,恩县广场,旅顺街,堂邑路,李村街,即墨路,港华大厦,港环路,馆陶街,普集路,朝阳街,甘肃广场,港夏街,港联路,陵县大厦,上海路,宝山广场,武定路,长清街,长安路,惠民街,武城广场,聊城大厦,海泊路,沧口街,宁波路,胶州广场,莱州路,招远街,冠县路,六码头,金乡广场,禹城街,临清路,东阿街,吴淞路,大港沿,辽宁路,棣纬二大厦,大港纬一路,贮水山支街,无棣纬一广场,大港纬三街,大港纬五路,大港纬四街,大港纬二路,无棣二大厦,吉林支路,大港四街,普集支路,无棣三街,黄台支广场,大港三街,无棣一路,贮水山大厦,泰山支路,大港一广场,无棣四路,大连支街,大港二路,锦州支街,德平广场,高苑大厦,长山路,乐陵街,临邑路,嫩江广场,合江路,大连街,博兴路,蒲台大厦,黄台广场,城阳街,临淄路,安邱街,临朐路,青城广场,商河路,热河大厦,济阳路,承德街,淄川广场,辽北街,阳信路,益都街,松江路,流亭大厦,吉林路,恒台街,包头路,无棣街,铁山广场,锦州街,桓台路,兴安大厦,邹平路,胶东广场,章丘路,丹东街,华阳路,青海街,泰山广场,周村大厦,四平路,台东西七街,台东东二路,台东东七广场,台东西二路,东五街,云门二路,芙蓉山村,延安二广场,云门一街,台东四路,台东一街,台东二路,杭州支广场,内蒙古路,台东七大厦,台东六路,广饶支街,台东八广场,台东三街,四平支路,郭口东街,青海支路,沈阳支大厦,菜市二路,菜市一街,北仲三路,瑞云街,滨县广场,庆祥街,万寿路,大成大厦,芙蓉路,历城广场,大名路,昌平街,平定路,长兴街,浦口广场,诸城大厦,和兴路,德盛街,宁海路,威海广场,东山路,清和街,姜沟路,雒口大厦,松山广场,长春街,昆明路,顺兴街,利津路,阳明广场,人和路,郭口大厦,营口路,昌邑街,孟庄广场,丰盛街,埕口路,丹阳街,汉口路,洮南大厦,桑梓路,沾化街,山口路,沈阳街,南口广场,振兴街,通化路,福寺大厦,峄县路,寿光广场,曹县路,昌乐街,道口路,南九水街,台湛广场,东光大厦,驼峰路,太平山,标山路,云溪广场,太清路'
        i = Address.count(",")
        i = random.randint(0,i)
        Address = Address.split(",")[i]
        i = unicode(i)
        Address = Address+i+u"号"
        return Address
    #coding=utf-8
    def getRndPwd(self):
        '''
        生成随机密码
        :return:
        '''
        Pwd1 = u'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
        Pwd2 = u'0123456789'
        i = random.randint(0,len(Pwd1)-1)
        j = random.randint(0,len(Pwd2)-8)
        Pwd1 = Pwd1[i]
        Pwd2 = Pwd2[j:j+8]
        Pwd = Pwd1+Pwd2
        return Pwd

    def GetMiddleStr(self,str1,int1,int2):
        '''
        获取某一字符串中的某一段字符串
        :return:
        '''
        int1 = int(int1)
        int2 = int(int2)
        return str1[int1:int2]

    def Getint_addNo(self,int1,int2):
        '''
        得到两个数字相加的结果
        '''
        int1 = int(int1)
        int2 = int(int2)
        intA = int1 + int2
        return intA

    def Get_FilePath(self):
        '''
        获取当前文件路径并返回
        '''
        #获取脚本路径
        path = sys.path[0]
        #判断为脚本文件还是py2exe编译后的文件,如果是脚本文件,则返回的是脚本的目录,如果是py2exe编译后的文件,则返回的是编译后的文件路径
        if os.path.isdir(path):
            return path
        elif os.path.isfile(path):
            return os.path.dirname(path)

    def check_Dir(self,path,dec='utf-8',enc='gbk'):
        reload(sys)
        sys.setdefaultencoding('utf-8')
        path = path.decode(dec).encode(enc)
        # print path
        if (not os.path.exists(path)):
            # print 'ok'
            os.makedirs(path)




# l = MyLibrary()
# print l.Get_FilePath();
#print  l.Getint_addNo(5,6)
# print 'abc'
# print l.IsnRegistPictureCode()
# print l.GetMiddleStr("hdajkhdsadsadsadsadsadasdsa",3,15)
# print l.getRanNum(8)
# print l.getRndAddress()
# print l.IsnPictureCode()
# print l.getLoginCode('18612111600')
# print l.regexStr('orderNo=(.*)$','?address=&templateId=&appointmentTime=&expressway=2&orderType=1&orderNo=UCMP000001980833')
# print l.getMobileRegisterCode('13246600001')
# print l.getMobile()
# print l.getLoginCode('13246600001')
# print l.IsnPictureCode()
# print l.changeMailHref('123@qq.com')
# print l.getRanNum(1)
# l.check_Dir("E:\\会员自助工具\\会员打印自动化测试\\面单打印\\201608\\1")
# print l.joinStrPro("a","b","c")