def find(cardSeg):
	userDefine = 90
	current = cardSeg * 10000 + userDefine
	p = Phone()
	fp = open('result.txt', 'a')

	while (current <= (cardSeg * 10000+9990)):
		print current
		
		if (p.find(current) != None):
			'''
			print p.find(current)
			print p.find(current)['province'].decode('utf-8')
			print p.find(current)['city'].decode('utf-8')
			print p.find(current)['phone_type'].decode('utf-8')
			'''
			fp.write(str(current)+' \t')
			fp.write(p.find(current)['province']+' \t')
			fp.write(p.find(current)['city']+' \t')
			fp.write(p.find(current)['phone_type']+'\n')
			
		current += 100
	
	fp.close()
	print 'finished'
Esempio n. 2
0
class TestPhone(unittest.TestCase):
    """Submodule for unittests, derives from unittest.TestCase"""
    def setUp(self):
        """ Create object for all tests """
        # Arrange
        self.phone = Phone("Samsung", "Galaxy S8", "Android")

    def tearDown(self):
        """ Remove dependencies after test """
        self.phone = None

    def test_init(self):
        """Test that init works as expected"""
        # Assert
        self.assertEqual(self.phone.owner, "No owner yet")
        self.assertEqual(self.phone.manufacturer, "Samsung")
        self.assertEqual(self.phone.model, "Galaxy S8")
        self.assertEqual(self.phone.os, "Android")
        self.assertTrue(isinstance(self.phone._phonebook, PhoneBook))

    def test_call(self):
        inp = ["andreas"]
        with mock.patch('builtins.input', side_effect=inp):
            pass

    def test_make_call(self):
        with mock.patch('sys.stdout', new=StringIO()) as fake_out:
            with mock.patch.object(self.phone._phonebook,
                                   "get_contact") as get_mock:
                get_mock.return_value = "070-354 78 00"

                self.phone._make_call("andreas")

                content = fake_out.getvalue().rstrip()
                self.assertEqual(content, "Calling number 070-354 78 00 ...")
Esempio n. 3
0
def get_plid():
    p = Phone()
    parameters = request.get_json().get("result").get("parameters")
    print request.get_json().get("result").get('contexts')
    try:
        brand = request.get_json().get("result").get('contexts')[3].get(
            "parameters").get("brand")
    except:
        brand = "Samsung"

    print "selected brand = {0}".format(brand)
    model_number = parameters.get('number', 0)
    if type(model_number) != int:
        model_number = int(parameters.get('number', 0).encode('ascii'))

    models = p.get_models_by_brand(brand)

    selected = models[model_number]
    print selected
    plid = p.get_plid(brand, selected)
    print plid
    result = {'speech': plid, 'displayText': plid}
    response = app.response_class(response=json.dumps(result),
                                  status=200,
                                  mimetype='application/json')
    return response
Esempio n. 4
0
def test():
    phone_num = '13300001251'
    p = Phone()
    with open('province.txt', 'r') as f:
        province_list = f.read().splitlines()

    with open('province_ch.txt', 'r', encoding="utf-8") as f:
        province_ch_list = f.read().splitlines()

    try:

        desc = p.find(phone_num)
        # print(desc)
        # 返回归属的列表下标
        index = province_ch_list.index(desc.get('province'))
        # print(desc.get('province'), index)
        if index is not None:
            # 如果下标存在,找到对应数据库的表名
            use_table = province_list[index]
            insert_value(use_table, desc)

        else:
            with open('errorlog/descerror.txt', 'a', encoding='utf-8') as f:
                f.write(phone_num + '\n')
    # 无用手机号
    except Exception as e:
        with open('errorlog/NoneType.txt', 'a', encoding='utf-8') as f:
            f.write(phone_num + '\n')
Esempio n. 5
0
def main():

    phone_name = raw_input("Enter the name of your phone: ")
    number = int(raw_input("Enter your number: "))
    phone = Phone(number, phone_name)
    print "Congratulations! You've set up your phone!"
    while True:
        display_menu()
        choice = raw_input("Please select an action: ")
        if choice == "0":
            display_menu()
        elif choice == "1":
            display_contacts(phone)
        elif choice == "2":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            number = int(raw_input("Enter the contact's number: "))
            phone.add_contact(first_name, last_name, number)
        elif choice == "3":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            phone.del_contact(first_name)
        elif choice == "4":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            phone.call(first_name, last_name)
        elif choice == "5":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            message = raw_input("Enter the text message: ")
            phone.text(first_name, message)
        elif choice == "6":
            break
        else:
            print "Invalid selection. Please choose again."
Esempio n. 6
0
def data_to_csv():
    from phone import Phone
    p = Phone()
    phone_place=[]
    phones =other_cell_phone
    for phone in phones:
        if(phone[0]=='1'): #手机号1开头,并且11位
            if len(phone)==11: 
                city = p.find(phone)['city']
                phone_place.append(pinyin.get(city, format="strip", delimiter="")) #同时将地名转换为字符串
                #phone_place.append(city)
            else:
                phone_place.append('Na')
        else:
            phone_place.append('Na') #不是手机号的话置Na
    festival_array=[] #节日列表
    #print start_date1
    for item in start_date1:
        if(item in festival.keys()):
            festival_array.append(festival[item])
        else:
            festival_array.append('Na') #其他
    #print len(other_cell_phone)
    #print len(start_weekday)
    #print len(start_hour)
    #print len(use_time)
    #print len(start_date1)
    #print len(place)
    #print len(phone_place)
    #print len(phone_calldays)
    #根据已有数组创建csv文件
    columns=['phone_num','weekday','start_hour','use_time','start_date','location','other_phone_place','call_days']
    dataframe=pd.DataFrame({'phone_num':other_cell_phone,'weekday':start_weekday,'start_hour':start_hour,'use_time':use_time,'start_date':start_date1,'location':place,'other_phone_place':phone_place,'call_days':phone_calldays})
    dataframe.to_csv(address+'.csv',index=True,sep=',',columns=columns,encoding='utf-8') #默认写模式
Esempio n. 7
0
 def __init__(self, host, port, user, database, password):
     self.p = Phone()
     self.db = pymysql.connect(host=host,
                               port=port,
                               user=user,
                               database=database,
                               password=password)
     self.cursor = self.db.cursor()
Esempio n. 8
0
def init_hardware():
    try:
        global phone
        phone = Phone()
        modem = Modem()
        phone.attach_modem(modem)
    except:
        deinit_hardware()
        raise
Esempio n. 9
0
def main():
    iphone_7 = Phone('Iphone 7', 'https://www.phonearena.com/phones/Apple-iPhone-7_id9815')
    samsung_s8 = Phone('Samsung s8', 'https://www.phonearena.com/phones/Samsung-Galaxy-S8_id10311')
    moto_x_style = Phone('Moto X Style', 'https://www.phonearena.com/phones/Motorola-Moto-X-Style_id9553')

    phones = [iphone_7, samsung_s8, moto_x_style]
    col_users, col_items = get_meli_phones_info(phones)
    get_meli_users_info(col_users, col_items)
    get_specs_info(phones)
def test_is_valid_phone_number_with_round_brackets_on_area_code():
    """
    Positive Testing
    Valid phone number given with round brackets on area code.
    """
    phone = '(416) 789-5308'
    result = Phone().parse_phone_number(phone)
    assert result.get('area_code') == '416'
    assert result.get('trunk') == '789'
    assert result.get('phone_number') == '5308'
def test_is_valid_phone_number_with_hyphen():
    """
    Positive Testing
    Valid phone number given separated by hyphen(-).
    """
    phone = '416-789-5308'
    result = Phone().parse_phone_number(phone)
    assert result.get('area_code') == '416'
    assert result.get('trunk') == '789'
    assert result.get('phone_number') == '5308'
def test_is_valid_phone_number_with_extension_specified_by_ext():
    """
    Positive Testing
    Valid phone number with extension specified by ext.
    """
    phone = '416-789-5308 ext. 1111'
    result = Phone().parse_phone_number(phone)
    assert result.get('area_code') == '416'
    assert result.get('trunk') == '789'
    assert result.get('phone_number') == '5308'
    assert result.get('extension') == '1111'
def test_is_valid_phone_number_with_extension_specified_by_hash():
    """
    Positive Testing
    Valid phone number with extension specified by #.
    """
    phone = 'emergency 1-(416) 789.5308 #1111'
    result = Phone().parse_phone_number(phone)
    assert result.get('area_code') == '416'
    assert result.get('trunk') == '789'
    assert result.get('phone_number') == '5308'
    assert result.get('extension') == '1111'
Esempio n. 14
0
File: Q.PY Progetto: wansoft/WANPLAN
def get_info(phones):
    p = Phone()
    #phones = [18575670303,18588201231,15626585681]
    #print(phones)
 
    for phone in phones:
        try:
            city = p.find(phone)['city']
            province = p.find(phone)['province']
            print("%s %s %s" % (phone, province, city))
        except:
            pass
Esempio n. 15
0
def get_models():
    parameters = request.get_json().get("result").get("parameters")
    brand = parameters.get('brand')
    # print brand
    phone = Phone()
    models = phone.get_models_by_brand(brand)
    text = "Here are the available models for {0}:\n{1}".format(brand, models)
    result = {'speech': text, 'displayText': text}
    # print result
    response = app.response_class(response=json.dumps(result),
                                  status=200,
                                  mimetype='application/json')
    return response
Esempio n. 16
0
 def __init__(self):
     print 'Starting a new game'
     self.coordinates = (0, 0)
     self.location = GameLocation(self.x_offset, self.y_offset, self.width,
                                  self.height)
     self.vision = Vision(self.location)
     self.controller = Controller(self.x_offset, self.y_offset)
     self.phone = Phone()
     self._build_buttons()
     self._reset_food()
     self._build_customers()
     self._build_recipes()
     self.mat = GameObject('Mat', (199, 380))
Esempio n. 17
0
    def search(self, number):
        ph = Phone()
        city = ph.find(number)

        print(city)  # 所有信息
        print('手机号:' + number)
        print('所属省份:' + city['province'])
        print('所属市区:' + city['city'])
        print('邮    编:' + city['zip_code'])
        print('电话区号:' + city['area_code'])
        print('运 营 商:' + city['phone_type'])

        return city
Esempio n. 18
0
def main():
    smart_phone = Phone(2018, "Samsung", "$500", "32MB", "8", "555-666-7777")
    print("Yay", smart_phone.brand)
    print(str(smart_phone))
    smart_phone.charge_battery(17)
    print("current battery", smart_phone.show_current_battery(), "hours")
    smart_phone.use_battery(4)
    print("current battery", smart_phone.show_current_battery(), "hours")
def Get_Excel_data():
    file = './Tel.xlsx'   #电话号码存储的excle表
    re1 = xlrd.open_workbook(file)

    outwb = xlwt.Workbook() #创建工作簿
    # print(type(outwb))
    outws = outwb.add_sheet("new")  #在工作簿中新建一个工作表new
    # print(type(outws))

    # 读取第一个sheet
    ws = re1.sheet_by_index(0)
    rows = ws.nrows
    # print(rows)
    outws.write(0, 0, u'电话号')  #给新表的第一行添加对应的标签
    outws.write(0, 1, u'省份')
    outws.write(0, 2, u'城市')
    outws.write(0, 3, u'区号')
    outws.write(0, 4, u'运营商')

    for i in range(0, rows):
        Telvalue = int(ws.cell_value(i, 0))
        # print(Telvalue)
        data = Phone().find(Telvalue)
        print(data)
        outws.write(i + 1, 0, Telvalue)  #给新表的个列添加对应的数据
        try:
            outws.write(i + 1, 1, data['province'])
            outws.write(i + 1, 2, data['city'])
            outws.write(i + 1, 3, data['area_code'])
            outws.write(i + 1, 4, data['phone_type'])

            outwb.save(r'New_Tel.xls')
        except:
            print("none")
    def get_numbers_addr(self,number1,number2,number3):
        info1 = Phone().find(number1)
        info2 = Phone().find(number2)
        info3 = Phone().find(number3)
        try:
            phone1 = info1['phone']
            province1 = info1['province']
            city1 = info1['city']
            zip_code1 = info1['zip_code']
            area_code1 = info1['area_code']
            phone_type1 = info1['phone_type']
        except:
            print("Sorry,号码<%s>归属地信息系统暂时无法查询..." % number1)
            print("请登录http://www.ip138.com/sj/ 进行查询")
        else:
            print("手机号码:%s\n运营商:%s\n归属地:%s,%s\n邮编:%s\n区号:%s" % (phone1, phone_type1, province1, city1, zip_code1, area_code1))
            print("*"*20)
            time.sleep(1)
        try:
            phone2 = info2['phone']
            province2 = info2['province']
            city2 = info2['city']
            zip_code2 = info2['zip_code']
            area_code2 = info2['area_code']
            phone_type2 = info2['phone_type']
        except:
            print("Sorry,号码<%s>归属地信息系统暂时无法查询..." % number2)
            print("请登录http://www.ip138.com/sj/ 进行查询")
        else:
            time.sleep(1)
            print("手机号码:%s\n运营商:%s\n归属地:%s,%s\n邮编:%s\n区号:%s" % (phone2, phone_type2, province2, city2, zip_code2, area_code2))
            print("*" * 20)

        try:
            phone3 = info3['phone']
            province3 = info3['province']
            city3 = info3['city']
            zip_code3 = info3['zip_code']
            area_code3 = info3['area_code']
            phone_type3 = info3['phone_type']
        except:
            print("Sorry,号码<%s>归属地信息系统暂时无法查询..." % number3)
            print("请登录http://www.ip138.com/sj/ 进行查询")
        else:
            print("手机号码:%s\n运营商:%s\n归属地:%s,%s\n邮编:%s\n区号:%s" % (phone3, phone_type3, province3, city3, zip_code3, area_code3))
            time.sleep(1)
Esempio n. 21
0
def get_phone_region(phone_num):

    info = Phone().find(phone_num)
    if info is not None:
        region = info['province'] + ' ' + info['city'] + ' ' + info['phone_type']
    else:
        region = '该号码暂未查询到归属地,请检查号码正确性或手动查询!'
    return region
Esempio n. 22
0
 def insert(self, id, brand, model, price, count, version):
     '''
     插入数据
     :param phone:
     :return:
     '''
     phone = Phone(id, brand, model, price, count, version)
     self.phones.append(phone)
Esempio n. 23
0
def get_brands():
    """
    gets list of phones from root API
    :return: list of supported phone models
    """
    phone = Phone()
    brands = phone.get_brands()
    text = "Sure! Here are the available brands:\n " \
           "{0}\n" \
           "What do you want?".format(brands)

    result = {'speech': text, 'displayText': text}
    # print result

    response = app.response_class(response=json.dumps(result),
                                  status=200,
                                  mimetype='application/json')
    return response
Esempio n. 24
0
    def extract_cellphone_location(self, phoneNum, nation='CHN'):
        """
        extract cellphone number locations according to the given number
        eg: extract_cellphone_location('181000765143',nation=CHN)


        :param: phoneNum<string>, nation<string>
        :return: location<dict>{'phone': '18100065143', 'province': '上海', 'city': '上海', 'zip_code': '200000', 'area_code': '021', 'phone_type': '电信'}

        """
        if nation=='CHN':
            p = Phone()
            loc_dict = p.find(phoneNum)
        if nation!='CHN':
            x = phonenumbers.parse(phoneNum, 'GB')
            if phonenumbers.is_possible_number(x):
                loc_dict = x
        # print(loc_dict)
        return loc_dict
Esempio n. 25
0
def getPhoneInfo(phoneNum):
    info = Phone().find(phoneNum)
    if info:
        phone = info['phone']
        province = info['province']
        city = info['city']
        zip_code = info['zip_code']
        area_code = info['area_code']
        phone_type = info['phone_type']
    return info
Esempio n. 26
0
def phone_city(calls):
    try:
        call = Phone()
        a = []
        for i in calls:
            try:
                call1 = call.find(i.strip())
                pro = call1['province']
                ci = call1['city']
                info = i + '\t' + pro + '\t' + ci
                # print(info)
                a.append(info)
            except Exception as e:
                # print(e)
                pass
        return a
    except Exception as e:
        print(e)
        pass
Esempio n. 27
0
 def add_phone(self):
     print(len(phone_id) + 1)
     brand = input('请输入手机品牌')
     model = input('请输入手机型号')
     price = float(input('请输入手机价格'))
     count = int(input('请输入手机数量'))
     version = input('请输入手机版本')
     phone_id.append(len(phone_id) + 1)
     p = Phone(brand, model, price, count, version)
     self.phone[len(phone_id)] = p
     print('添加成功')
Esempio n. 28
0
def parseMobPhoneNum(phoneNum):
    mobileType, mobilePhone = guessPhoneType(phoneNum)
    if mobileType == 'mobile':
        phone_dict = Phone().find(mobilePhone)
        phoneProv = phone_dict['province']
        phoneCity = phone_dict['city']
        phoneType = phone_dict['phone_type']
        phoneAreaCode = phone_dict['area_code']
        phoneZipCode = phone_dict['zip_code']
        return mobilePhone, phoneProv, phoneCity, phoneType, phoneAreaCode, phoneZipCode
    else:
        return '', '', '', '', '', ''
Esempio n. 29
0
    def __init__(self, filename):
        """Initialises the instance with a given lable file.

        This method loads the given label file and populates the list of phones,
        which are parsed using the Phone class.

        :params filename: label file to be loaded
        """
        self.phones = []
        with open(filename, 'r') as f:
            for idx,l in enumerate(f.readlines()):
                self.phones.append(Phone(l,idx))
Esempio n. 30
0
    def run_once(self):
        """This method do the whole work"""
        # form socket list every time as list
        # could be moded in handlers
        socket_list = [self._asock, self._psock]
        for sock in self._users_list:
            socket_list.append(sock)

        infds, _, _ = select.select(socket_list, [], [], 1)

        for fds in infds:
            if fds is self._asock:
                sock, addr = fds.accept()
                self._loginfo('Admin connected from {}'.format(addr))
                RemoteAdmin(self._users_list, sock, addr)
                socket_list.append(sock)
                continue

            if fds is self._psock:
                sock, addr = fds.accept()
                self._loginfo('Phone connected from {}'.format(addr))
                Phone(self._order_number, self._users_list, sock, addr)
                self._order_number += 1
                if self._order_number > 999:
                    self._order_number = 0
                socket_list.append(sock)
                continue

            if fds in self._users_list:
                user = self._users_list[fds]
            else:
                #unknows -> close
                self._logerror("uknown socket in list")
                socket_list.remove(fds)
                fds.close()
                continue

            data = fds.recv(1024)
            if not data:
                #closed
                self._loginfo('{} disconnected'.format(user.get_addr()))
                fds.close()
                socket_list.remove(fds)
                del self._users_list[fds]
                user.close()
            else:
                user.handle_data(data)

        # check timeouts
        for sock in list(self._users_list):
            user = self._users_list[sock]
            user.check_timeout()
Esempio n. 31
0
def shaixuan():
    # 打开csv
    print(
        '-----------------------------------------------------------------------------------------'
    )
    print(
        '号码筛选小程序使用说明:\n(1)将号码保存到txt文件,每个号码一行;\n(2)将txt文件放到本程序当前目录下;\n(3)程序运行结束后将创建csv文件到当前目录下;\n'
    )
    print('接下来请输入你要打开的txt文件名,如"xxx.txt",输入xxx即可')
    print(
        '-----------------------------------------------------------------------------------------'
    )
    xxx = input('文件名是:')
    # 打开txt
    t1 = time.time()
    try:
        with open(xxx + '.txt', 'r', encoding='UTF-8') as f:
            tel_list = []
            n = 0
            nn = 0
            for num in f:
                # print(num.strip())
                # 把号码放入函数转换成字典

                try:
                    info = Phone().find(num.strip())
                    print(info)
                    phone = info['phone']
                    province = info['province']
                    city = info['city']
                    zip_code = info['zip_code']
                    area_code = info['area_code']
                    phone_type = info['phone_type']
                    # 把字典里的值放入元组添加到列表
                    tel_list.append((phone, province, city, zip_code,
                                     area_code, phone_type))
                    n += 1
                except Exception as e:
                    print(e)
                    print(num + '无法识别')
                    nn += 1
    except Exception as e:
        input('应该是文件名输错了,请检查后重试')
    else:
        # 遍历结束后,把列表写入到csv(一次性全部写入)
        ff = open(xxx + '.csv', 'a', newline='')
        writer = csv.writer(ff)
        writer.writerows(tel_list)
        f.close()
        ff.close()
        print('成功查找%s条数据,有%s条没找到' % (n, nn))
        return t1
Esempio n. 32
0
 def __init__(self):
     self.gi = Phone('phone.dat')
     self.gi2 = pygeoip.GeoIP('GeoLiteCity.dat')
     self.root = tkinter.Tk()
     self.menubar = Menu(self.root)
     filemenu = Menu(self.menubar, tearoff=0)
     self.menubar.add_cascade(label='图片编辑', menu=filemenu)
     self.root['menu'] = self.menubar
     filemenu.add_command(
         label="压缩图片",
         command=lambda: self.compressImage('pic', 'mini_pic'))
     filemenu.add_command(label="帮助", command=self.help)
     filemenu.add_command(label="关于", command=self.about)
     filemenu.add_command(label="退出", command=self.root.quit)
     self.root.title("ip地址和号码归属地查询、批量压缩图片小工具")
     self.Label = tkinter.Label(self.root, text="请输入IP地址或者电话号码:", width=50)
     self.text_input = tkinter.Entry(self.root, width=30)
     self.display_info = tkinter.Listbox(self.root, width=50)
     self.result_button = tkinter.Button(self.root,
                                         background='blue',
                                         command=self.find_position,
                                         text="查询")
Esempio n. 33
0
def init_app(input, output):
    global i, o, phone
    i = input; o = output 
    i.set_maskable_callback("KEY_ANSWER", answer)
    i.set_nonmaskable_callback("KEY_HANGUP", hangup)
    phone = Phone()
    try:
        #This not good enough - either make the systemctl library system-wide or add more checks
        os_call(["systemctl", "stop", "*****@*****.**"])
    except Exception as e:
        print(repr(e))
        #import pdb;pdb.set_trace()
    Thread(target=check_modem_connection, args=[True]).start()
Esempio n. 34
0
def main():
    import config
    phone = Phone()
    phone.setSoundDevices(config.SND_SPK, config.SND_MIC, config.SND_RING)
    phone.register(config)

    gui = Gui()

    controller = Controller(phone, gui)

    import time
    while True:
        phone.loop()
        gui.loop()
        time.sleep(0.1)
class TraceMalware:

    def get_source_place(self, result_path):
        """

        :param result_path:
        :return:
        """
        try:
            with open(result_path, 'r') as fp:
                apk_info = json.load(fp)
        except Exception, e:
            print "can not open the file!"
            return

        p = Phone()
        for apk_name in apk_info:

            # apk中的移动电话归属地查询
            if "mobilephone" in apk_info[apk_name]:
                print "apk_name", apk_name
                for phone_number in apk_info[apk_name]["mobilephone"]:
                    # print phone_number
                    p_source_info = p.find(phone_number)
                    if type(p_source_info) is dict:
                        print phone_number
                        for p_info in p_source_info:
                            print p_info, p_source_info[p_info]

            # apk 中的银行卡信息查询
            if "bank_card" in apk_info[apk_name]:
                for bank_card in apk_info[apk_name]["bank_card"]:
                    bank_info = self.get_bank_card_info(bank_card)
                    if bank_info:
                        print bank_card
                        for key in bank_info:
                            print key, bank_info[key]

            # apk中固定电话归属地查询
            if "telephone" in apk_info[apk_name]:
                for tele_id in apk_info[apk_name]["telephone"]:
                    if tele_id is None or len(tele_id)<10:
                        continue
                    tele_area = self.get_tele_num_place(tele_id[:4])
                    print tele_id, tele_area

            # apk中身份证号的归属地查询
            if "id_card" in apk_info[apk_name]:
                for id in apk_info[apk_name]["id_card"]:
                    id_result = self.get_id_card_place(id)
                    print id, id_result
Esempio n. 36
0
def main():

    phone_name = raw_input("Enter the name of your phone: ")
    number = int(raw_input("Enter your number: "))
    phone = Phone(number, phone_name)
    print "Congratulations! You've set up your phone!"
    while True:
        display_menu()
        choice = raw_input("Please select an action: ")
        if choice == "0":
            display_menu()
        elif choice == "1":
            display_contacts(phone)
        elif choice == "2":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            number = int(raw_input("Enter the contact's number: "))
            phone.add_contact(first_name, last_name, number)
            print "USE A METHOD FROM THE PHONE CLASS TO ADD CONTACT"
        elif choice == "3":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            phone.del_contact(first_name, last_name, number)
            print "USE AN METHOD FROM THE PHONE CLASS TO DELETE CONTACT"
        elif choice == "4":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            print "USE AN METHOD FROM THE PHONE CLASS TO MAKE CALL"
        elif choice == "5":
            first_name = raw_input("Enter the contact's first name: ")
            last_name = raw_input("Enter the contact's last name: ")
            message = raw_input("Enter the text message: ")
            print "USE AN METHOD FROM THE PHONE CLASS TO SEND TEXT"
        elif choice == "6":
            break
        else:
            print "Invalid selection. Please choose again."
Esempio n. 37
0
class TestPhone(TestCase):

    def setUp(self):
        self.p = Phone()

    def tearDown(self):
        pass

    def test_get_phone_no_type(self):

        self.assertEqual(self.p.get_phone_no_type(1), '移动')
        self.assertEqual(self.p.get_phone_no_type(2), '联通')
        self.assertEqual(self.p.get_phone_no_type(3), '电信')
        self.assertEqual(self.p.get_phone_no_type(6), '移动虚拟运营商')
        self.assertEqual(self.p.get_phone_no_type(5), '联通虚拟运营商')
        self.assertEqual(self.p.get_phone_no_type(4), '电信虚拟运营商')
        self.assertEqual(self.p.get_phone_no_type(7), None)

    def test_find_on_assert_error(self):

        try:
            self.p.find(123)
            self.assertTrue(False)
        except AssertionError:
            pass

    def test_find_on_ok(self):

        res = self.p.find(1521147)
        self.assertEqual(res['zip_code'], '421000')
        self.assertEqual(res['area_code'], '0734')
        self.assertEqual(res['city'], '衡阳')
        self.assertEqual(res['province'], '湖南')
        self.assertEqual(res['phone_type'], '移动')

    def test_find_on_no_res(self):

        res = self.p.find(1991147)
        self.assertEqual(res, None)
Esempio n. 38
0
 def setUp(self):
     self.p = Phone()
Esempio n. 39
0
from phone import Phone


p = Phone()
p.test()
Esempio n. 40
0
 def test_pretty_print_with_full_us_phone_number(self):
     number = Phone("11234567890")
     self.assertEqual("(123) 456-7890", number.pretty())    
Esempio n. 41
0
 def test_pretty_print(self):
     number = Phone("1234567890")
     self.assertEqual("(123) 456-7890", number.pretty())
Esempio n. 42
0
 def test_area_code(self):
     number = Phone("1234567890")
     self.assertEqual("123", number.area_code())
Esempio n. 43
0
        self.running = False

    def installApp(self, app):
        if not self.apps.has_key(app.id):
            self.apps[app.app_id] = app

    def uninstallApp(self, app_id):
        if self.apps.has_key(app_id):
            self.apps.pop(app_id)


if __name__ == "__main__":
    print threading.currentThread().getName()
    from phone import Phone

    phone = Phone()
    phone.imei = "111"
    phone.imsi = "222"
    phone.wmac = "333"
    phone.uid = "5654444"
    phone.os = "Android"
    phone.resolution = "rrr"
    phone.access = "wifi"
    phone.os_version = "4.4.2"
    phone.android_id = "android_idxxx"
    phone.toolcid = "sddd"
    phone.channel = "gf"
    app = AppUsbHelper(phone)
    appman = AppManager(phone)
    print app._buildSelfStaticInfo()
    import sys
Esempio n. 44
0
def test():
	p  = Phone()
	print p.find(1888888)
	print p.find(1888888)['province'].decode('utf-8')
	print p.find(1888888)['city'].decode('utf-8')
	print p.find(1888888)['phone_type'].decode('utf-8')