예제 #1
0
def remove_subscription(nums='C:/Users/админ/Desktop/1.txt',
                        begin=0,
                        show=False):
    rapi = Rest()
    count = 0

    if not isinstance(nums, list):
        nums = open(nums).readlines()
    for phone in nums[begin:]:
        rapi.change_owner(ctn=str(phone).strip())
        try:
            subscrs = rapi.get_subscriptions()['subscriptions']
        except KeyError:
            print(rapi.get_subscriptions())
        count += len(subscrs)
        for el in subscrs:
            rapi.remove_subscription(subscription_id=el['id'],
                                     subscription_type=el['type'])
        if len(subscrs) > 0:
            print('Made {} request(-s) for {}th of {} numbers'.format(
                len(subscrs),
                nums.index(phone) + 1, len(nums)))
        else:
            print(
                "Didn't found subscriptions on {}.\n{}th of {} numbers".format(
                    rapi.ctn,
                    nums.index(phone) + 1, len(nums)))
            nums.remove(phone)
    print('Totally made {} requests for remove subscriptions'.format(count))
    if count != 0:
        check_subscription(nums, show)
예제 #2
0
파일: tools.py 프로젝트: dubanoze/beeapi
def remove_subscription(nums="C:/Users/админ/Desktop/1.txt", begin=0, show=False):
    rapi = Rest()
    count = 0

    if not isinstance(nums, list):
        nums = open(nums).readlines()
    for phone in nums[begin:]:
        rapi.change_owner(ctn=str(phone).strip())
        try:
            subscrs = rapi.get_subscriptions()["subscriptions"]
        except KeyError:
            print(rapi.get_subscriptions())
        count += len(subscrs)
        for el in subscrs:
            rapi.remove_subscription(subscription_id=el["id"], subscription_type=el["type"])
        if len(subscrs) > 0:
            print("Made {} request(-s) for {}th of {} numbers".format(len(subscrs), nums.index(phone) + 1, len(nums)))
        else:
            print(
                "Didn't found subscriptions on {}.\n{}th of {} numbers".format(
                    rapi.ctn, nums.index(phone) + 1, len(nums)
                )
            )
            nums.remove(phone)
    print("Totally made {} requests for remove subscriptions".format(count))
    if count != 0:
        check_subscription(nums, show)
예제 #3
0
def get_mass_serv():
    session = get_session('ekomobile')

    rapi = Rest()
    services = get_class('service_fx')
    agree = get_class('operator_agree')
    ctn = get_class('ctn')
    btp = get_class('operator_tarif')
    banlist = session.query(agree.i_id).filter(agree.moboperator == 1,
                                               agree.payment_type == 0,
                                               agree.discontinued == 0).all()
    banlist = [el[0] for el in banlist]
    ctnlist = session.query(ctn.msisdn, ctn.operator_tarif).filter(
        ctn.operator_agree.in_(banlist),
        ctn.status == 1).group_by(ctn.operator_tarif).all()
    result = []

    for el in ctnlist:

        rapi.change_owner(ctn=int(el[0]))
        rez = rapi.get_available_services()['availableServices']
        if len(rez) == 0:
            print(rapi.ctn)
        for r in rez:
            tarif = session.query(
                btp.name).filter(btp.i_id == int(el[1])).one()[0]
            try:
                serv = session.query(services.i_id).filter(
                    services.bee_sync == r['name']).one()[0]
            except NoResultFound:
                serv = 'Нет в билле!'
            result.append([
                rapi.ctn, el[1], tarif, serv, r['name'], r['entityName'],
                r['rcRate']
            ])
        print('{} из {}'.format(ctnlist.index(el) + 1, len(ctnlist)))

    names = ['Номер', 'Тариф', 'Техкод услуги', 'Название услуги', 'АП услуги']

    session.close()
    try:
        ex_write(names, result, path='C:/Users/ГостЪ/Desktop/services.xlsx')
    except ValueError:
        return result
    else:
        return
예제 #4
0
파일: tools.py 프로젝트: dubanoze/beeapi
def get_mass_serv():
    session = get_session("ekomobile")

    rapi = Rest()
    services = get_class("service_fx")
    agree = get_class("operator_agree")
    ctn = get_class("ctn")
    btp = get_class("operator_tarif")
    banlist = (
        session.query(agree.i_id).filter(agree.moboperator == 1, agree.payment_type == 0, agree.discontinued == 0).all()
    )
    banlist = [el[0] for el in banlist]
    ctnlist = (
        session.query(ctn.msisdn, ctn.operator_tarif)
        .filter(ctn.operator_agree.in_(banlist), ctn.status == 1)
        .group_by(ctn.operator_tarif)
        .all()
    )
    result = []

    for el in ctnlist:

        rapi.change_owner(ctn=int(el[0]))
        rez = rapi.get_available_services()["availableServices"]
        if len(rez) == 0:
            print(rapi.ctn)
        for r in rez:
            tarif = session.query(btp.name).filter(btp.i_id == int(el[1])).one()[0]
            try:
                serv = session.query(services.i_id).filter(services.bee_sync == r["name"]).one()[0]
            except NoResultFound:
                serv = "Нет в билле!"
            result.append([rapi.ctn, el[1], tarif, serv, r["name"], r["entityName"], r["rcRate"]])
        print("{} из {}".format(ctnlist.index(el) + 1, len(ctnlist)))

    names = ["Номер", "Тариф", "Техкод услуги", "Название услуги", "АП услуги"]

    session.close()
    try:
        ex_write(names, result, path="C:/Users/ГостЪ/Desktop/services.xlsx")
    except ValueError:
        return result
    else:
        return
예제 #5
0
파일: tools.py 프로젝트: dubanoze/beeapi
def check_subscription(nums, show=False, for_return=False):

    rapi = Rest()

    rez = []
    for phone in nums:
        try:
            rapi.change_owner(ctn=str(phone).strip())
        except NoResultFound:
            continue
        subscrs = rapi.get_subscriptions()["subscriptions"]
        if len(subscrs) > 0:
            rez.append(rapi.ctn)
            if show:
                for el in subscrs:
                    print(el[""])
        print("Check {} of {}".format(nums.index(phone) + 1, len(nums)))
    print("Now count of numbers with active subscriptions = {}".format(len(rez)))

    if len(rez) > 0:
        print("Numbers with subscriptions:")
        for el in rez:
            print(str(el))
예제 #6
0
def check_subscription(nums, show=False, for_return=False):

    rapi = Rest()

    rez = []
    for phone in nums:
        try:
            rapi.change_owner(ctn=str(phone).strip())
        except NoResultFound:
            continue
        subscrs = rapi.get_subscriptions()['subscriptions']
        if len(subscrs) > 0:
            rez.append(rapi.ctn)
            if show:
                for el in subscrs:
                    print(el[''])
        print('Check {} of {}'.format(nums.index(phone) + 1, len(nums)))
    print('Now count of numbers with active subscriptions = {}'.format(
        len(rez)))

    if len(rez) > 0:
        print('Numbers with subscriptions:')
        for el in rez:
            print(str(el))