GramAddict / bot

Completely free and open-source human-like Instagram bot. Powered by UIAutomator2 and compatible with basically any Android device 5.0+ that can run Instagram - real or emulated.
https://docs.gramaddict.org
MIT License
1.14k stars 180 forks source link

v2.0.5 is not compatible with Python v3.6, triggering unexpected 'capture_output' #197

Closed captain-melanie closed 3 years ago

captain-melanie commented 3 years ago

Hi, thank you for the amazing new features added to the new version. I just upgraded to the v2.0.5 and re-installed dependencies pip3 install -r requirements.txt, but the bot couldn't start.

What happened:

[05/12 10:20:42]     INFO | -------- START: 10:20:42 - 2021/05/12 --------
Traceback (most recent call last):
  File "run.py", line 3, in <module>
    GramAddict.run()
  File "/var/www/html/having_fun/gramaddict2/GramAddict/__init__.py", line 135, in run
    if device.is_screen_locked():
  File "/var/www/html/having_fun/gramaddict2/GramAddict/core/device_facade.py", line 139, in is_screen_locked
    shell=True,
  File "/usr/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'

What you expected to happen: Successfully run the bot

How to reproduce it (as minimally and precisely as possible):

Ubuntu 18.8 and Python 3.6 Run:

python3 run.py --config accounts/MY_ACCOUNT/config.yml

Anything else we need to know?:

capture_output does not exist in Python 3.6. I had to make the following change to make it work

diff --git a/GramAddict/core/device_facade.py b/GramAddict/core/device_facade.py
index 7853ff0..76882da 100644
--- a/GramAddict/core/device_facade.py
+++ b/GramAddict/core/device_facade.py
@@ -6,7 +6,7 @@ from enum import Enum, auto
 from os import listdir, getcwd
 from random import randint, uniform
 from re import search
-from subprocess import run
+from subprocess import run, PIPE
 from time import sleep
 from GramAddict.core.utils import random_sleep

@@ -135,7 +135,8 @@ class DeviceFacade:
         data = run(
             f"adb -s {self.deviceV2.serial} shell dumpsys window",
             encoding="utf-8",
-            capture_output=True,
+            stdout=PIPE,
+            stderr=PIPE,
             shell=True,
         )
         if data != "":
@@ -151,7 +152,8 @@ class DeviceFacade:
         data = run(
             f"adb -s {serial} shell dumpsys input_method",
             encoding="utf-8",
-            capture_output=True,
+            stdout=PIPE,
+            stderr=PIPE,
             shell=True,
         )
         if data != "":

Environment:

Relevant Logs: N/A




mastrolube commented 3 years ago

Hello! Thanks for pointing out and fixing that! It's strange that the static-check of python 3.6 didn't tell me about that problem.. I used 3.7 for most of the development so I didn't notice. Will test and push the fix soon.. thanks!

captain-melanie commented 3 years ago

Hello! Thanks for pointing out and fixing that! It's strange that the static-check of python 3.6 didn't tell me about that problem.. I used 3.7 for most of the development so I didn't notice. Will test and push the fix soon.. thanks!

No problem, hope this helps. I use Ubuntu so I'm a bit hesitant to having different versions of Python.