Exemplo n.º 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)
Exemplo n.º 2
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)
Exemplo n.º 3
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))
Exemplo n.º 4
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))