pumapy 2.3.2__tar.gz → 2.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {pumapy-2.3.2/pumapy.egg-info → pumapy-2.5.0}/PKG-INFO +10 -3
  2. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/appium_actions.py +7 -0
  3. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/telegram/telegram.py +53 -25
  4. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/whatsapp/whatsapp.py +36 -15
  5. pumapy-2.5.0/puma/version.py +1 -0
  6. {pumapy-2.3.2 → pumapy-2.5.0/pumapy.egg-info}/PKG-INFO +10 -3
  7. {pumapy-2.3.2 → pumapy-2.5.0}/pumapy.egg-info/requires.txt +1 -1
  8. {pumapy-2.3.2 → pumapy-2.5.0}/setup.py +1 -1
  9. pumapy-2.3.2/puma/version.py +0 -1
  10. {pumapy-2.3.2 → pumapy-2.5.0}/LICENSE.txt +0 -0
  11. {pumapy-2.3.2 → pumapy-2.5.0}/README.md +0 -0
  12. {pumapy-2.3.2 → pumapy-2.5.0}/puma/__init__.py +0 -0
  13. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/__init__.py +0 -0
  14. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/__init__.py +0 -0
  15. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/google_maps/__init__.py +0 -0
  16. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/google_maps/google_maps.py +0 -0
  17. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/snapchat/__init__.py +0 -0
  18. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/snapchat/snapchat.py +0 -0
  19. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/telegram/__init__.py +0 -0
  20. {pumapy-2.3.2 → pumapy-2.5.0}/puma/apps/android/whatsapp/__init__.py +0 -0
  21. {pumapy-2.3.2 → pumapy-2.5.0}/puma/computer_vision/__init__.py +0 -0
  22. {pumapy-2.3.2 → pumapy-2.5.0}/puma/computer_vision/ocr.py +0 -0
  23. {pumapy-2.3.2 → pumapy-2.5.0}/puma/utils/__init__.py +0 -0
  24. {pumapy-2.3.2 → pumapy-2.5.0}/puma/utils/route_simulator.py +0 -0
  25. {pumapy-2.3.2 → pumapy-2.5.0}/puma/utils/video_utils.py +0 -0
  26. {pumapy-2.3.2 → pumapy-2.5.0}/pumapy.egg-info/SOURCES.txt +0 -0
  27. {pumapy-2.3.2 → pumapy-2.5.0}/pumapy.egg-info/dependency_links.txt +0 -0
  28. {pumapy-2.3.2 → pumapy-2.5.0}/pumapy.egg-info/top_level.txt +0 -0
  29. {pumapy-2.3.2 → pumapy-2.5.0}/setup.cfg +0 -0
  30. {pumapy-2.3.2 → pumapy-2.5.0}/test/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pumapy
3
- Version: 2.3.2
3
+ Version: 2.5.0
4
4
  Home-page: https://github.com/NetherlandsForensicInstitute/puma
5
5
  Author: Netherlands Forensic Institute
6
6
  Author-email: netherlandsforensicinstitute@users.noreply.github.com
@@ -13,8 +13,15 @@ Requires-Dist: pytesseract==0.3.10
13
13
  Requires-Dist: geopy~=2.4.1
14
14
  Requires-Dist: setuptools~=75.1.0
15
15
  Requires-Dist: gpxpy~=1.6.2
16
- Requires-Dist: adb_pywrapper~=1.0.2
16
+ Requires-Dist: adb_pywrapper~=1.0.3
17
17
  Requires-Dist: requests~=2.32.3
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: description
21
+ Dynamic: description-content-type
22
+ Dynamic: home-page
23
+ Dynamic: license
24
+ Dynamic: requires-dist
18
25
 
19
26
  # Puma - Programmable Utility for Mobile Automation
20
27
 
@@ -91,6 +91,13 @@ class AndroidAppiumActions:
91
91
  def activate_app(self):
92
92
  self.driver.activate_app(self.app_package)
93
93
 
94
+ def terminate_app(self):
95
+ self.driver.terminate_app(self.app_package)
96
+
97
+ def restart_app(self):
98
+ self.terminate_app()
99
+ self.activate_app()
100
+
94
101
  def app_open(self) -> bool:
95
102
  return str(self.driver.current_package) == self.app_package
96
103
 
@@ -1,16 +1,15 @@
1
1
  from time import sleep
2
- from typing import Dict
2
+ from typing import Dict, Optional
3
3
 
4
4
  from appium.webdriver.common.appiumby import AppiumBy
5
5
 
6
6
  from puma.apps.android.appium_actions import supported_version, AndroidAppiumActions
7
- from puma.apps.android.telegram import logger
8
7
 
9
8
  TELEGRAM_PACKAGE = 'org.telegram.messenger'
10
9
  TELEGRAM_WEB_PACKAGE = 'org.telegram.messenger.web'
11
10
 
12
11
 
13
- @supported_version("11.2.2")
12
+ @supported_version("11.6.1")
14
13
  class TelegramActions(AndroidAppiumActions):
15
14
 
16
15
  def __init__(self,
@@ -31,19 +30,24 @@ class TelegramActions(AndroidAppiumActions):
31
30
  desired_capabilities=desired_capabilities,
32
31
  implicit_wait=implicit_wait,
33
32
  appium_server=appium_server)
34
- self.package_name = TELEGRAM_WEB_PACKAGE if telegram_web_version else TELEGRAM_PACKAGE
35
33
 
36
- def _currently_at_homescreen(self) -> bool:
37
- return self.is_present('//android.widget.FrameLayout[@content-desc="New Message"]')
34
+ def _currently_at_homescreen(self, **kwargs) -> bool:
35
+ return self.is_present('//android.widget.FrameLayout[@content-desc="New Message"]', **kwargs)
38
36
 
39
- def _currently_in_conversation(self) -> bool:
40
- return self.is_present('//android.widget.ImageView[@content-desc="Emoji, stickers, and GIFs"]')
37
+ def _currently_in_conversation(self, **kwargs) -> bool:
38
+ return self.is_present('//android.widget.ImageView[@content-desc="Emoji, stickers, and GIFs"]', **kwargs)
41
39
 
42
- def _currently_in_camera(self) -> bool:
43
- return self.is_present('//android.widget.Button[lower-case(@content-desc)="shutter"]')
40
+ def _currently_in_camera(self, **kwargs) -> bool:
41
+ return self.is_present('//android.widget.Button[lower-case(@content-desc)="shutter"]', **kwargs)
44
42
 
45
- def _currently_in_call(self) -> bool:
46
- return self.is_present('//android.widget.Button[@text="End Call"]')
43
+ def _currently_in_call(self, **kwargs) -> bool:
44
+ return self.is_present('//android.widget.Button[lower-case(@text)="end call"]', **kwargs)
45
+
46
+ def _currently_in_active_call(self, **kwargs) -> bool:
47
+ """
48
+ Returns true if currently in a call that is in actual progress (meaning: the other party answered the call).
49
+ """
50
+ return self.is_present('//android.widget.LinearLayout[@content-desc="Encryption key of this call"]', **kwargs)
47
51
 
48
52
  def _load_conversation_titles(self):
49
53
  while True:
@@ -58,18 +62,23 @@ class TelegramActions(AndroidAppiumActions):
58
62
  self.driver.back()
59
63
  print('all conversations loaded!')
60
64
 
61
- def return_to_homescreen(self, attempts=10):
65
+ def return_to_homescreen(self, attempts: int = 10, try_restart: bool = True):
62
66
  """
63
67
  Returns to the start screen of Telegram
64
68
  :param attempts: Number of attempts to return to home screen. Avoids an infinite loop when a popup occurs.
65
69
  """
66
- if self.driver.current_package != self.package_name:
67
- self.driver.activate_app(self.package_name)
68
- while not self._currently_at_homescreen() and attempts > 0:
70
+ attempt = 0
71
+ while not self._currently_at_homescreen() and attempt < attempts:
72
+ if self.driver.current_package != self.app_package:
73
+ self.activate_app()
69
74
  self.driver.back()
70
- attempts -= 1
71
- if attempts == 0 and not self._currently_at_homescreen():
72
- raise Exception('Tried to return to homescreen but ran out of attempts...')
75
+ attempt += 1
76
+ if not self._currently_at_homescreen():
77
+ if try_restart:
78
+ self.restart_app()
79
+ self.return_to_homescreen(attempts, False)
80
+ else:
81
+ raise Exception('Tried to return to homescreen but ran out of attempts...')
73
82
  self._load_conversation_titles()
74
83
  sleep(1)
75
84
 
@@ -94,6 +103,8 @@ class TelegramActions(AndroidAppiumActions):
94
103
  self.return_to_homescreen()
95
104
  xpath = f'//android.view.ViewGroup[starts-with(lower-case(@content-desc), "{chat.lower()}")]'
96
105
  self.driver.find_element(by=AppiumBy.XPATH, value=xpath).click()
106
+ if not self._currently_in_conversation(implicit_wait=1):
107
+ raise RuntimeError("Conversation was not opened after clicking the conversation")
97
108
 
98
109
  def select_group(self, group_name: str):
99
110
  """
@@ -214,7 +225,7 @@ class TelegramActions(AndroidAppiumActions):
214
225
  value='//android.widget.ImageView[lower-case(@content-desc)="send"]').click()
215
226
  sleep(0.3) # the animation after sending a picture might throw off the script
216
227
 
217
- def start_call(self, chat: str = None, video: bool = False):
228
+ def start_call(self, chat: str = None, video: bool = False) -> bool:
218
229
  """
219
230
  Makes a call and ends the call after a given number of seconds.
220
231
  The call is made to either
@@ -222,6 +233,7 @@ class TelegramActions(AndroidAppiumActions):
222
233
  * a given contact name
223
234
  :param chat: Optional: name of the conversation to start a call in
224
235
  :param video: False (default) for voice call, True for video call.
236
+ :return: True if call was successfully started
225
237
  """
226
238
  self._if_chat_go_to_chat(chat)
227
239
  if not video:
@@ -232,16 +244,32 @@ class TelegramActions(AndroidAppiumActions):
232
244
  value='//android.widget.ImageButton[lower-case(@content-desc)="more options"]').click()
233
245
  self.driver.find_element(by=AppiumBy.XPATH,
234
246
  value='//android.widget.TextView[lower-case(@text)="video call"]').click()
247
+ # wait a short while (max 2s) for the call to have started
248
+ return self._currently_in_call(implicit_wait=2)
249
+
250
+ def get_call_status(self) -> Optional[str]:
251
+ """
252
+ Returns a string describing the status of the current call, which is a text visible on the call screen.
253
+ If the call is in progress, no text indicates this, but this method will return "In progress".
254
+ If not currently in a call, this method returns None.
255
+ Known statuses include 'Requesting', 'Waiting' and 'Ringing'.
256
+ """
257
+ if not self._currently_in_call():
258
+ return None
259
+ if self._currently_in_active_call():
260
+ return "In progress"
261
+ status_element = '//android.widget.LinearLayout[ends-with(@text, "Telegram Call")]/android.widget.FrameLayout/android.widget.TextView'
262
+ status_element = self.driver.find_element(by=AppiumBy.XPATH, value=status_element)
263
+ return status_element.get_attribute("text")
235
264
 
236
265
  def end_call(self):
237
266
  """
238
267
  Ends the current call. Assumes the call screen is open.
239
268
  """
240
- if self._currently_in_call():
241
- self.driver.find_element(by=AppiumBy.XPATH,
242
- value='//android.widget.Button[lower-case(@text)="end call"]').click()
243
- else:
244
- logger.warn('Could not end call as current screen was not the call screen.')
269
+ if not self._currently_in_call():
270
+ raise Exception('Cannot end call while not in call screen.')
271
+ self.driver.find_element(by=AppiumBy.XPATH,
272
+ value='//android.widget.Button[lower-case(@text)="end call"]').click()
245
273
 
246
274
  def answer_call(self):
247
275
  """
@@ -10,7 +10,7 @@ from puma.apps.android.appium_actions import supported_version, AndroidAppiumAct
10
10
  WHATSAPP_PACKAGE = 'com.whatsapp'
11
11
 
12
12
 
13
- @supported_version("2.24.20.89")
13
+ @supported_version("2.24.25.78")
14
14
  class WhatsappActions(AndroidAppiumActions):
15
15
  def __init__(self,
16
16
  device_udid,
@@ -36,7 +36,8 @@ class WhatsappActions(AndroidAppiumActions):
36
36
  '//android.widget.Button[@content-desc="Send message"]')
37
37
 
38
38
  def currently_in_conversation(self) -> bool:
39
- return self.is_present('//android.widget.LinearLayout[@resource-id="com.whatsapp:id/conversation_root_layout"]')
39
+ return self.is_present('//android.widget.LinearLayout[@resource-id="com.whatsapp:id/conversation_root_layout"]',
40
+ implicit_wait=1)
40
41
 
41
42
  def return_to_homescreen(self):
42
43
  if self.driver.current_package != WHATSAPP_PACKAGE:
@@ -61,6 +62,8 @@ class WhatsappActions(AndroidAppiumActions):
61
62
  chats_of_interest_text = ", ".join([chat.text for chat in chats_of_interest])
62
63
  print(
63
64
  f"[WARNING]: Multiple chats found that contain the subject {subject}: {chats_of_interest_text}. Selecting the first one.")
65
+ if len(chats_of_interest) == 0:
66
+ raise Exception(f'Cannot find conversation with name {subject}')
64
67
  chats_of_interest[0].click()
65
68
 
66
69
  def create_new_chat(self, contact, first_message):
@@ -210,13 +213,23 @@ class WhatsappActions(AndroidAppiumActions):
210
213
  # Go to gallery
211
214
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/input_attach_button").click()
212
215
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/pickfiletype_gallery_holder").click()
213
- self.driver.find_element(by=AppiumBy.XPATH,
214
- value='//android.widget.LinearLayout[@content-desc="Gallery"]').click()
215
- directory_tile = f'//android.widget.TextView[@resource-id="com.whatsapp:id/title" and @text="{directory_name}"]'
216
- self.swipe_to_find_element(xpath=directory_tile).click()
217
-
218
- sleep(0.5)
219
- self.driver.find_element(by=By.CLASS_NAME, value="android.widget.ImageView").click()
216
+ if self.is_present('//android.widget.LinearLayout[@content-desc="Gallery"]'):
217
+ self.driver.find_element(by=AppiumBy.XPATH,
218
+ value='//android.widget.LinearLayout[@content-desc="Gallery"]').click()
219
+ directory_tile = f'//android.widget.TextView[@resource-id="com.whatsapp:id/title" and @text="{directory_name}"]'
220
+ self.swipe_to_find_element(xpath=directory_tile).click()
221
+ sleep(0.5)
222
+ self.driver.find_element(by=By.CLASS_NAME, value="android.widget.ImageView").click()
223
+ elif self.is_present('//android.widget.TextView[@resource-id="com.whatsapp:id/title"]'):
224
+ self.driver.find_element(by=AppiumBy.XPATH,
225
+ value='//android.widget.TextView[@resource-id="com.whatsapp:id/title"]').click()
226
+ sleep(0.5)
227
+ self.driver.find_element(by=AppiumBy.XPATH, value='//android.widget.ListView/android.view.ViewGroup[last()]').click()
228
+ directory_tile = f'//android.widget.TextView[@text="{directory_name}"]'
229
+ self.swipe_to_find_element(xpath=directory_tile).click()
230
+ sleep(0.5)
231
+ self.driver.find_element(by=AppiumBy.XPATH, value='//android.widget.ImageView[@resource-id="com.google.android.providers.media.module:id/icon_thumbnail"]').click()
232
+ self.driver.find_element(by=AppiumBy.XPATH, value='//android.widget.Button[@resource-id="com.google.android.providers.media.module:id/button_add"]').click()
220
233
 
221
234
  if caption:
222
235
  text_box = self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/caption")
@@ -227,6 +240,9 @@ class WhatsappActions(AndroidAppiumActions):
227
240
 
228
241
  if view_once:
229
242
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/view_once_toggle").click()
243
+ popup_button = '//android.widget.Button[@resource-id="com.whatsapp:id/vo_sp_bottom_sheet_ok_button"]'
244
+ if self.is_present(popup_button):
245
+ self.driver.find_element(by=AppiumBy.XPATH, value=popup_button).click()
230
246
  sleep(1)
231
247
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/send").click()
232
248
 
@@ -286,6 +302,9 @@ class WhatsappActions(AndroidAppiumActions):
286
302
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/input_attach_button").click()
287
303
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/pickfiletype_location_holder").click()
288
304
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/live_location_btn").click()
305
+ dialog = '//android.widget.LinearLayout[@resource-id="com.whatsapp:id/location_new_user_dialog_container"]'
306
+ if self.is_present(dialog):
307
+ self.driver.find_element(by=AppiumBy.XPATH, value="//android.widget.Button[@text='Continue']").click()
289
308
  if caption is not None:
290
309
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/comment").send_keys(caption)
291
310
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/send").click()
@@ -316,7 +335,7 @@ class WhatsappActions(AndroidAppiumActions):
316
335
  self._if_chat_go_to_chat(chat)
317
336
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/input_attach_button").click()
318
337
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/pickfiletype_contact_holder").click()
319
- self.scroll_to_find_element(text_contains=contact_name).click()
338
+ self.swipe_to_find_element(f'//android.widget.TextView[@resource-id="com.whatsapp:id/name" and @text="{contact_name}"]').click()
320
339
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/next_btn").click()
321
340
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/send_btn").click()
322
341
 
@@ -350,6 +369,9 @@ class WhatsappActions(AndroidAppiumActions):
350
369
  'and @text="Updates"]').click()
351
370
  self.driver.find_element(by=AppiumBy.XPATH,
352
371
  value='//android.widget.ImageButton[@content-desc="New status update"]').click()
372
+ open_camera = '//android.widget.Button[@content-desc="Camera"]'
373
+ if self.is_present(open_camera):
374
+ self.driver.find_element(by=AppiumBy.XPATH, value=open_camera).click()
353
375
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/shutter").click()
354
376
  if caption:
355
377
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/caption").send_keys(caption)
@@ -439,8 +461,8 @@ class WhatsappActions(AndroidAppiumActions):
439
461
  """
440
462
  Ends the current call. Assumes the call screen is open.
441
463
  """
442
- end_call_button = '//android.widget.Button[@resource-id="com.whatsapp:id/end_call_button"]'
443
- if not self.is_present(end_call_button):
464
+ end_call_button = '//*[@content-desc="Leave call" or @resource-id="com.whatsapp:id/end_call_button" or @resource-id="com.whatsapp:id/footer_end_call_btn"]'
465
+ if not self.is_present(end_call_button, implicit_wait=1):
444
466
  # tap screen to make call button visible
445
467
  background = '//android.widget.RelativeLayout[@resource-id="com.whatsapp:id/call_screen"]'
446
468
  self.driver.find_element(by=AppiumBy.XPATH, value=background).click()
@@ -588,8 +610,7 @@ class WhatsappActions(AndroidAppiumActions):
588
610
  self.select_chat(group_name)
589
611
  self.driver.find_element(by=AppiumBy.ID, value="com.whatsapp:id/conversation_contact").click()
590
612
  self.scroll_to_find_element(text_equals=participant).click()
591
- self.driver.find_element(by=AppiumBy.XPATH, value=
592
- f"//*[@resource-id='android:id/select_dialog_listview']//*[@text='Remove {participant}']").click()
613
+ self.driver.find_element(by=AppiumBy.XPATH, value="//*[starts-with(@text, 'Remove')]").click()
593
614
  self.driver.find_element(by=AppiumBy.XPATH, value="//*[@class='android.widget.Button' and @text='OK']").click()
594
615
  sleep(5)
595
616
  self.return_to_homescreen()
@@ -638,6 +659,6 @@ class WhatsappActions(AndroidAppiumActions):
638
659
  """
639
660
  self._if_chat_go_to_chat(chat)
640
661
  most_recent_view_once = \
641
- self.driver.find_elements(by=AppiumBy.ID, value="com.whatsapp:id/view_once_media_type_large")[-1]
662
+ self.driver.find_elements(by=AppiumBy.XPATH, value='//*[contains(@resource-id, "view_once_media")]')[-1]
642
663
  most_recent_view_once.click()
643
664
  self.driver.back()
@@ -0,0 +1 @@
1
+ version = "2.5.0"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pumapy
3
- Version: 2.3.2
3
+ Version: 2.5.0
4
4
  Home-page: https://github.com/NetherlandsForensicInstitute/puma
5
5
  Author: Netherlands Forensic Institute
6
6
  Author-email: netherlandsforensicinstitute@users.noreply.github.com
@@ -13,8 +13,15 @@ Requires-Dist: pytesseract==0.3.10
13
13
  Requires-Dist: geopy~=2.4.1
14
14
  Requires-Dist: setuptools~=75.1.0
15
15
  Requires-Dist: gpxpy~=1.6.2
16
- Requires-Dist: adb_pywrapper~=1.0.2
16
+ Requires-Dist: adb_pywrapper~=1.0.3
17
17
  Requires-Dist: requests~=2.32.3
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: description
21
+ Dynamic: description-content-type
22
+ Dynamic: home-page
23
+ Dynamic: license
24
+ Dynamic: requires-dist
18
25
 
19
26
  # Puma - Programmable Utility for Mobile Automation
20
27
 
@@ -4,5 +4,5 @@ pytesseract==0.3.10
4
4
  geopy~=2.4.1
5
5
  setuptools~=75.1.0
6
6
  gpxpy~=1.6.2
7
- adb_pywrapper~=1.0.2
7
+ adb_pywrapper~=1.0.3
8
8
  requests~=2.32.3
@@ -22,7 +22,7 @@ setup(
22
22
  "geopy~=2.4.1",
23
23
  "setuptools~=75.1.0",
24
24
  "gpxpy~=1.6.2",
25
- "adb_pywrapper~=1.0.2",
25
+ "adb_pywrapper~=1.0.3",
26
26
  "requests~=2.32.3"
27
27
  ],
28
28
  )
@@ -1 +0,0 @@
1
- version = "2.3.2"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes