Skip to content

Commit ed86aac

Browse files
committed
Update block_inactive_licenses.py
1 parent 2c8e3ad commit ed86aac

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

block_inactive_licenses.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ def identify_inactive_keys(token, productId, window=30, block=False):
1919

2020
all_keys = []
2121

22-
time_window = 60*60*24*window # 1 month back in time
22+
time_window = 60*60*24*int(window) # 1 month back in time
2323
time_now = int(time.time())
2424

2525
filtered_keys = []
2626

2727
not_processed_keys = []
2828

29-
## only non blocked keys should be listed.
30-
3129
iteration = 1
3230
while True:
3331
temp = Product.get_keys(token, product_id, iteration)[0]
@@ -49,15 +47,15 @@ def identify_inactive_keys(token, productId, window=30, block=False):
4947

5048
if len(req) > 0:
5149
req = req[0]
50+
51+
if int(req["time"]) + time_window < time_now:
52+
filtered_keys.append(req["key"])
53+
print("Detected key {0}".format(req["key"]))
54+
else:
55+
print("Skipped key {0}".format(req["key"]))
5256
else:
53-
print("Skipped key {0}".format(key["key"]))
54-
continue
55-
56-
if req["time"] + time_window > time_now:
57-
filtered_keys.append(req["key"])
58-
print("Detected key {0}".format(req["key"]))
59-
else:
60-
print("Skipped key {0}".format(req["key"]))
57+
filtered_keys.append(key["key"])
58+
print("Detected key {0}".format(key["key"]))
6159

6260
if block:
6361

@@ -83,8 +81,4 @@ def identify_inactive_keys(token, productId, window=30, block=False):
8381

8482
args = parser.parse_args()
8583

86-
print(identify_inactive_keys(args.token, args.product,args.window, args.block))
87-
88-
89-
90-
84+
print(identify_inactive_keys(args.token, args.product,args.window, args.block))

0 commit comments

Comments
 (0)