Esempio n. 1
0
 def _reconnect(self):
     print "Trying to reconnect.."
     self.reconnecting = True
     options = self.justdice.options
     try:
         self.justdice.sock.disconnect()
         response = load_justdice(secret_url=options.secret,
             proxy = options.proxy)
         new_justdice = login(response, options, TrackResultSocket)
     except Exception, e:
         print 'error reconnecting: %s' % e
         new_justdice = None
Esempio n. 2
0
 def _reconnect(self):
     print "Trying to reconnect.."
     self.reconnecting = True
     options = self.justdice.options
     try:
         self.justdice.sock.disconnect()
         response = load_justdice(secret_url=options.secret,
                                  proxy=options.proxy)
         new_justdice = login(response, options, TrackResultSocket)
     except Exception, e:
         print 'error reconnecting: %s' % e
         new_justdice = None
Esempio n. 3
0
def main():
    options = handle_input(enable_dummy=False)

    print "Connecting.."
    response = load_justdice(secret_url=options.secret, proxy=options.proxy)
    justdice = login(response, options, TrackResultSocket)
    if justdice is None:
        # Login failed.
        return

    justdice.options = options
    root = Tkinter.Tk()
    gui = GUI(root, justdice)
    root.lift()
    root.mainloop()
Esempio n. 4
0
def main():
    options = handle_input(enable_dummy=False)

    print "Connecting.."
    response = load_justdice(secret_url=options.secret, proxy=options.proxy)
    justdice = login(response, options, TrackResultSocket)
    if justdice is None:
        # Login failed.
        return

    justdice.options = options
    root = Tkinter.Tk()
    gui = GUI(root, justdice)
    root.lift()
    root.mainloop()
Esempio n. 5
0
def main(user, pwd, google_2fa=None):
    print "Connecting.."
    response = load_justdice()
    print "Logging in.."
    justdice = JustDiceSocket(response,
            login={'user': user, 'pwd': pwd, '2fa': google_2fa})
    now = time.time()
    max_login_wait = 15 # seconds
    while not justdice.logged_in:
        if time.time() - now > max_login_wait:
            # Timed out.
            justdice.logged_in = None
        if justdice.logged_in is None:
            # Could not login.
            print "Couldn't log in"
            break
        time.sleep(0.75)
    else:
        print "Secret url: %s" % current_secreturl()
    justdice.sock.emit('disconnect')
Esempio n. 6
0
def main():
    parser = OptionParser()
    # Login
    parser.add_option('-s', '--secret', help='Pass a secret url')
    parser.add_option('-u', '--user', help='User name for login')
    parser.add_option('-p', '--password', help='User password')
    parser.add_option('-g', '--gauth', help='2FA code')

    options, args = parser.parse_args()

    print "Connecting.."
    response = load_justdice(secret_url=options.secret)
    justdice = login(False, response, options.user, options.password,
            options.gauth, options.secret, TrackResultSocket)
    if justdice is None:
        # Login failed.
        return

    justdice.queue = Queue.Queue()
    root = Tkinter.Tk()
    root.wm_title(u'just-dice tracking')
    gui = GUI(root, justdice)
    root.lift()
    root.mainloop()
Esempio n. 7
0
def main(user, pwd, google_2fa=None):
    print "Connecting.."
    response = load_justdice()
    print "Logging in.."
    justdice = JustDiceSocket(response,
                              login={
                                  'user': user,
                                  'pwd': pwd,
                                  '2fa': google_2fa
                              })
    now = time.time()
    max_login_wait = 15  # seconds
    while not justdice.logged_in:
        if time.time() - now > max_login_wait:
            # Timed out.
            justdice.logged_in = None
        if justdice.logged_in is None:
            # Could not login.
            print "Couldn't log in"
            break
        time.sleep(0.75)
    else:
        print "Secret url: %s" % current_secreturl()
    justdice.sock.emit('disconnect')
Esempio n. 8
0
    def __init__(self, output, *args):
        super(GetStats, self).__init__(*args)
        self.out = open(output, 'a')
        self.fields = ['timestamp', 'bets', 'profit', 'purse', 'wagered']
        self.got_result = False
        self._working = False

    def on_result(self, result):
        if self._working:
            return
        self._working = True
        stats = result['stats']
        stats['timestamp'] = int(time.time())
        line = ','.join(map(str, [stats[field] for field in self.fields]))
        self.out.write("%s\n" % line)
        self.got_result = True

print "Connecting.."
response = load_justdice()
sys.stdout.write("Waiting for result..")
justdice = GetStats('out.csv', response, None)
now = time.time()
max_wait_time = 10 # seconds
while not justdice.got_result and time.time() - now < max_wait_time:
    sys.stdout.write('.')
    sys.stdout.flush()
    time.sleep(0.1)
print
if not justdice.got_result:
    print "No results this time"