def __init__(self, username, password):
     self.username = username
     self.password = password
     try:
         scratch = scratchapi.ScratchUserSession(username, password)
     except:
         raise Exception('Scratch login failed.')
Пример #2
0
 def __init__(self, projId, username, password):
     self.os = os
     self.username = username
     self.letters = string.ascii_lowercase
     self.password = ''.join(random.choice(self.letters) for i in range(15))
     self.os.environ[self.password] = password
     self.projId = projId
     self.log = []
     self.vars = {}
     try:
         scratch = scratchapi.ScratchUserSession(username, password)
     except:
         raise Exception('Scratch login failed.')
Пример #3
0
def askForData():
    isValid = False

    while not isValid:
        user = input("Enter the bot's username > ")
        pas = input("Enter the bot's password > ")
        try:
            scratch = scratchapi.ScratchUserSession(user, pas)
            isValid = True
        except:
            print("Invalid username or password")

    return user, str(encryptor.encrypt(pas), "utf-8")
Пример #4
0
def fol(USER, BOTUSER, PASSWORD):
    if userExists(USER):
        with open("following.txt", "a") as f:
            fol = f.read()
            if not USER in fol:
                scratch = scratchapi.ScratchUserSession(BOTUSER, PASSWORD)
                scratch.users.follow(USER)
                print("ScratchBot followed " + USER)
                f.write(USER)
                if mode == "prompt":
                    scratch.users.comment(BOTUSER, "ScratchBot followed " + USER)
                else:
                    scratch.users.comment(ASKERUSER, "ScratchBot followed " + USER)
            else:
                print("Have already followed user")
    else:
        print("Could not find user with given username")
Пример #5
0
    def login(self):

        # Attempts to log the user in to the scratchapi

        usernameData = self.usernameEntry.get()
        passwordData = self.passwordEntry.get()

        if usernameData == "" or passwordData == "":
            # Stop the function if the fields are empty.
            self.errorMessage.config(text="These fields are required.")
            return

        # Attempt to login to the scratchapi with the given username and password

        try:
            scratch = scratchapi.ScratchUserSession(usernameData, passwordData)
        except:
            # Stop the function if there was an error
            self.errorMessage.config(text="Login failed.")
            return

        self.controller.show_frame(MainPage)
            n += '00' + e
    return n

# Default options
daemon = True
logfile = "/dev/null"

try:
    (opts, []) = getopt(sys.argv[1:], 'dl:')
except:
    usage()

for opt, val in opts:
    if opt == '-d':
        daemon = False
    elif opt == '-l':
        logfile = val

scratch = scratchapi.ScratchUserSession(input("Scratch Username: "******"Scratch Password: "******"Error: Could not log in!", file=sys.stderr)
    sys.exit(1)

if daemon:
    daemonize()

while True:
    get_tweet()
    time.sleep(config.config['delay'])
Пример #7
0
            unicode(time.strftime(u"%Y-%m-%d %H:%M:%S UTC", time.gmtime())) +
            u'\n')
        info("chat.log loaded.")
else:
    info("Logging is disabled")

# === Authentication ===

if visual:
    info("Visual mode is enabled. Skipping authentication.")
elif login_prompt:
    while True:
        username = raw_input("[PROMPT] Username: "******"[PROMPT] Password: "******"Login failed. Please try again.", 2, False)
    info("Successfully logged in with account, " + username + '.')
else:
    info("Automatic login is enabled. Logging into user, " + username + '.')
    for i in range(1, 6):
        info("Attempt " + str(i) + "...")
        try:
            scratch = scratchapi.ScratchUserSession(username, password)
            if scratch.tools.verify_session():
                break
        except Exception:
Пример #8
0
 def __init__(self,username,password):
   self.username=username
   self.password=password
   self.scratch=scratchapi.ScratchUserSession(username,password)