masterking32 / MasterHamsterKombatBot

Master Hamster Kombat Bot is a Python-based automation tool specifically designed for the game Hamster Kombat. This bot is capable of performing all in-game tasks, including auto-tapping, cipher tasks, and purchasing the best cards on your behalf. It's a free and fully automated farming bot that enhances your Hamster Kombat gaming experience.
https://github.com/masterking32/MasterCryptoFarmBot
Apache License 2.0
289 stars 100 forks source link

Error while running .exe #449

Closed vashamamasha2014 closed 6 days ago

vashamamasha2014 commented 6 days ago

Screenshot_1

Раньше When compiling in .exe via PyInstaller with the parameter -noconsole


pyinstaller --onefile --noconsole --add-data "C:\Users\user\PycharmProjects\BD_Viewer\MasterHamsterKombatBot\config.py;." --add-data "C:\Users\user\PycharmProjects\BD_Viewer\MasterHamsterKombatBot\utilities.py;." --add-data "C:\Users\user\PycharmProjects\BD_Viewer\MasterHamsterKombatBot\promogames.py;." --add-data "C:\Users\user\PycharmProjects\BD_Viewer\MasterHamsterKombatBot\useful_files;useful_files" --add-data "C:\Users\user\PycharmProjects\BD_Viewer\MasterHamsterKombatBot\banner.py;." --add-data "C:\Users\user\PycharmProjects\BD_Viewer\MasterHamsterKombatBot\warna.py;." C:\Users\user\PycharmProjects\BD_Viewer\MasterHamsterKombatBot\main.py``` , the version of the bot in which the loading bar and banner appeared gives an error when launched: 
Traceback (most recent call last):
  File "main.py", line 2300, in <module>
  File "main.py", line 2290, in main
  File "main.py", line 2277, in loading_bar2
AttributeError: 'NoneType' object has no attribute 'write'

The answer should be found in "sys.stdout", please fix it in the next patch.
Fy0urM commented 6 days ago

In the original, pyinstaller does not need to specify all files, by specifying 1 main.py file it will automatically pull up all imports. Try not to add all files manually

Fy0urM commented 6 days ago

try just pyinstaller --onefile main.py

vashamamasha2014 commented 6 days ago

try just pyinstaller --onefile main.py

This happens when exactly "-noconsole", I need a silent start.

vashamamasha2014 commented 6 days ago

try just pyinstaller --onefile main.py -noconsole: image

Fy0urM commented 6 days ago

I see, in that case, I can't help you.

Fy0urM commented 6 days ago

You can try commenting out the for loop within which stdout is used, this will disable the banner display but should help if stdout is not used anywhere else.

vashamamasha2014 commented 6 days ago

You can try commenting out the for loop within which stdout is used, this will disable the banner display but should help if stdout is not used anywhere else.

I have solved the problem, please fix it in your main code so that users do not have problems with this in the future, thank you. There are two functions that need to be fixed:

def loading_bar(duration):
    bar_length = 40
    end_time = time.time() + duration
    while time.time() < end_time:
        for i in range(bar_length + 1):
            percent = (i / bar_length) * 100
            bar = "█" * i + "-" * (bar_length - i)
            print(f"\r[{bar}] {percent:.2f}%", end='', flush=True)
            time.sleep(duration / bar_length)  # Adjust the duration for each step

    # Clear the loading bar
    print("\r" + " " * (bar_length + 8) + "\r", end='', flush=True)

if __name__ == "__main__":
    loading_bar(4)
Fy0urM commented 6 days ago

You can try commenting out the for loop within which stdout is used, this will disable the banner display but should help if stdout is not used anywhere else.

I have solved the problem, please fix it in your main code so that users do not have problems with this in the future, thank you. There are two functions that need to be fixed:

def loading_bar(duration):
    bar_length = 40
    end_time = time.time() + duration
    while time.time() < end_time:
        for i in range(bar_length + 1):
            percent = (i / bar_length) * 100
            bar = "█" * i + "-" * (bar_length - i)
            print(f"\r[{bar}] {percent:.2f}%", end='', flush=True)
            time.sleep(duration / bar_length)  # Adjust the duration for each step

    # Clear the loading bar
    print("\r" + " " * (bar_length + 8) + "\r", end='', flush=True)

if __name__ == "__main__":
    loading_bar(4)
  • def loading_bar2(duration):
    total_steps = 20
    interval = duration / total_steps
    
    print("Loading:", end=" ", flush=True)
    
    for i in range(1, total_steps + 1):
        print(f"\rLoading: {'█' * i}{' ' * (total_steps - i)} {int(i * 100 / total_steps)}%", end="", flush=True)
        time.sleep(interval)
    
    print(f"\rLoading: {'█' * total_steps} 100%", flush=True)

I'm afraid that users who don't want to use the code provided by the author according to the instructions provided by the author will have to solve their problems themselves).

vashamamasha2014 commented 6 days ago

I'm afraid that users who don't want to use the code provided by the author according to the instructions provided by the author will have to solve their problems themselves).

I don't see any difficulties for you, as one of the developers who actively participates in the development of this bot, to apply this code. Moreover, it does not violate the functionality of the loading bar. Github is needed for this, to share developments, and so that each user can contribute to the common cause)

masterking32 commented 6 days ago

We do not support or release any executable (.exe) files, as they are not related to the project.