Skip to content

Commit

Permalink
Improve final report
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mishchenko committed Jun 2, 2020
1 parent e151b7f commit 7ed9d1f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions insomniac.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import sys
import traceback
from datetime import datetime
from functools import partial
from random import shuffle, randint
from time import sleep
Expand All @@ -23,7 +24,9 @@

storage = Storage()
totalInteractions = 0
successfulInteractions = 0
totalLikes = 0
startTime = datetime.now()


def main():
Expand Down Expand Up @@ -179,9 +182,13 @@ def iterate_over_followers(device, interaction, total_likes_limit, interactions_
else:
print "@" + username + ": interact"
item.click.wait()
interaction(device)
interaction_succeed = interaction(device)
storage.add_interacted_user(username)

if interaction_succeed:
global successfulInteractions
successfulInteractions += 1

global totalInteractions
totalInteractions += 1
interactions_count += 1
Expand Down Expand Up @@ -222,7 +229,9 @@ def interact_with_user(device, likes_count):

print "Open and like photo #" + str(i + 1) + " (" + str(row + 1) + " row, " + str(column + 1) + " column)"
if not open_photo_and_like(device, row, column):
return
return False

return True


def open_photo_and_like(device, row, column):
Expand Down Expand Up @@ -300,7 +309,10 @@ def random_sleep():
def print_report_and_quit():
print "\n"
print(COLOR_OKBLUE + "Total interactions: " + str(totalInteractions) + COLOR_ENDC)
print(COLOR_OKBLUE + "Successful interactions: " + str(successfulInteractions) + COLOR_ENDC)
print(COLOR_OKBLUE + "Total likes: " + str(totalLikes) + COLOR_ENDC)
working_time = datetime.now() - startTime
print(COLOR_OKBLUE + "Time worked: " + str(working_time) + COLOR_ENDC)
sys.exit(0)


Expand Down

0 comments on commit 7ed9d1f

Please sign in to comment.