0
import pyautogui
import pickle

username = input("Enter your steam username: ")
pickle_out = open("steam.pickle","wb")
pickle.dump(username, pickle_out)
pickle_out.close


password_input = input("Enter your password: ")
password_test = input("Enter your password again: ")

if password_input == password_test :
    pickle_out = open("steam_password.pickle","wb")
    pickle.dump(password_input, pickle_out)
    pickle_out.close
else:
    print("The passwords don't match.")


def login():
    pyautogui.click(x=1165, y=634)
    pickle_in = open('steam.pickle','rb')
    username = pickle.load(pickle_in)
    pyautogui.typewrite(username)
    pyautogui.click(x=1162, y=669)
    pickle_inn = open('steam_password.pickle','rb')
    password = pickle.load(pickle_inn)
    pyautogui.typewrite(password)


login()


def remember():
    remember_or = input("Do you want to remember your password? (y/n) ")
    if remember_or == 'y':
        pyautogui.click(x=1163, y=697)
        pyautogui.click(x=1185, y=730)


remember()


def get_position():
    position_start = input()
    if position_start == 'm':
        print(pyautogui.position())

The error that I get is

Traceback (most recent call last):
  File "c:/Users/c/Desktop/Programming/Python/passwordsaver.py", line 32, in <module>
    login()
  File "c:/Users/c/Desktop/Programming/Python/passwordsaver.py", line 28, in login
    password = pickle.load(pickle_inn)
EOFError: Ran out of input

I checked what this error could mean and found out that it could mean that the file that i'm trying to pickle is empty but I checked and it isnt empty. I tried changing variable names as I thought that it had something to do with the code. Any help will be appreciated!

IskandarG
  • 1
  • 1
  • 3
  • 1
    `pickle_out.close` You haven't closed the file. You need `()` on the end of the function call: `pickle_out.close()` Otherwise you're _referring_ to the function but not _calling_ it. – John Gordon Jun 17 '20 at 18:41
  • Safest is to use `with` instead of calling `close` yourself. – Barmar Jun 17 '20 at 18:51

2 Answers2

0

You never closed stream.pickle, to avoid this kind of error use the with statement which close the file automaticaly when you leave it:

with open('stream.pickle', 'wb') as file: pickle.dump(username, file)

un random
  • 301
  • 1
  • 9
0

Working example:

import pickle

password_input = '123123123'
pickle_out = open("steam_password.pickle","wb")
pickle.dump(password_input, pickle_out)
pickle_out.close()

pickle_inn = open('steam_password.pickle','rb')
password = pickle.load(pickle_inn)

pickle_out.close just makes reference to function, don't calls it

And it's definetly bad idea to store password in pickle file. You can store it as md5 hash:

import hashlib

password = '123123123'
hashlib.md5(password.encode('utf8')).hexdigest()
dvec
  • 327
  • 4
  • 10
  • Adding the parenthesis fixed the problem. Apreciated – IskandarG Jun 17 '20 at 19:39
  • do i necessarly have to switch to hashlib for passwords or can i keep it in pickle if its just for me? – IskandarG Jun 17 '20 at 22:30
  • It's completly unsecure to keep passwords in raw type. You can add password hashing in one line: `password_hash_to_dump = hashlib.md5(input().encode('utf8')).hexdigest()` Then save it to .pickle file and check: `loaded_password_hash == hashlib.md5(input().encode('utf8')).hexdigest()` – dvec Jun 18 '20 at 22:04
  • its just to test the pickle module and its just for my use and i wont give it to anyone so i dont feel the need to use haslib. I already know that pickle is not safe for passwords but the next module i will learn is hash to add to this project – IskandarG Jul 18 '20 at 08:43