-
-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Mishchenko
committed
Jul 14, 2020
1 parent
0047a85
commit 4265d88
Showing
6 changed files
with
122 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/venv* | ||
/.idea | ||
interacted_users.* | ||
sessions.json | ||
*.pyc | ||
.DS_Store | ||
screenshots | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from src.counters_parser import parse | ||
from src.navigation import navigate, Tabs | ||
from src.utils import * | ||
|
||
|
||
def get_my_profile_info(device): | ||
navigate(device, Tabs.PROFILE) | ||
|
||
username = None | ||
title_view = device(resourceId='com.instagram.android:id/title_view', | ||
className='android.widget.TextView') | ||
if title_view.exists: | ||
username = title_view.text | ||
else: | ||
print(COLOR_FAIL + "Failed to get username" + COLOR_ENDC) | ||
|
||
followers = None | ||
followers_text_view = device(resourceId='com.instagram.android:id/row_profile_header_textview_followers_count', | ||
className='android.widget.TextView') | ||
if followers_text_view.exists: | ||
followers_text = followers_text_view.text | ||
if followers_text: | ||
followers = parse(device, followers_text) | ||
else: | ||
print(COLOR_FAIL + "Cannot get your followers count text" + COLOR_ENDC) | ||
else: | ||
print(COLOR_FAIL + "Cannot find your followers count view" + COLOR_ENDC) | ||
|
||
report_string = "" | ||
if username: | ||
report_string += "Hello, @" + username + "!" | ||
if followers: | ||
report_string += " You have " + str(followers) + " followers so far." | ||
|
||
if not report_string == "": | ||
print(report_string) | ||
|
||
return username, followers |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import json | ||
import os | ||
|
||
|
||
class PersistentList(list): | ||
filename = None | ||
encoder = None | ||
|
||
def __init__(self, filename, encoder): | ||
self.filename = filename | ||
self.encoder = encoder | ||
super().__init__() | ||
|
||
def persist(self, directory): | ||
if not os.path.exists(directory): | ||
os.makedirs(directory) | ||
|
||
path = directory + "/" + self.filename + ".json" | ||
|
||
if os.path.exists(path): | ||
with open(path) as json_file: | ||
json_array = json.load(json_file) | ||
os.remove(path) | ||
else: | ||
json_array = [] | ||
|
||
json_array += (self.encoder.default(self.encoder, item) for item in self) | ||
|
||
# Remove duplicates | ||
json_object = {} | ||
for item in json_array: | ||
item_id = item.get("id") | ||
if item_id is None: | ||
raise Exception("Items in PersistentList must have id property!") | ||
json_object[item_id] = item | ||
json_array = list(json_object.values()) | ||
|
||
with open(path, 'w') as outfile: | ||
json.dump(json_array, | ||
outfile, | ||
indent=4, | ||
sort_keys=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters