예제 #1
0
    def login(self):
        log_event(self.parentQueue, "Logging in...")
        self.loginButton.config(state="disabled")

        self.thread = ThreadedClient(self.parentQueue, "login", self.driver)
        self.thread.start()
        self.periodiccall()
예제 #2
0
    def update_settings(self):
        try:
            self.checkqueue()
        except:
            print("Error checking queue")

        try:
            self.config.read("./data/settings.ini")

            for option in self.GUI_STATS_VARS:
                # GET current stat value in config.ini
                stat_value = self.config.get("Statistics", str(option))

                # SET updated value to stringVar
                option.set(str(stat_value))

            for option in self.GUI_SETTINGS_VARS:
                # Get DISPLAYED value pulled from Dropdown memory object
                choice = option.get()

                # WRITE displayed value in writing to config.ini
                self.config.set("Settings", str(option), str(choice))

            # Update email, pwd, Futbin URL
            pwd_on_gui = self.passwordVar.get()
            email_on_gui = self.emailVar.get()

            self.config.set("Logins", "email", str(email_on_gui))
            self.config.set("Logins", "password", str(pwd_on_gui))

            # Check if URL has changed
            url_on_gui = str(self.futbinURLVar.get())
            url_on_disk = str(self.config.get("Other", "futbin_url"))

            if (url_on_gui != url_on_disk):
                # Run futbin function
                filters = getFilters(url_on_gui)

                for f in self.GUI_URL_VARS:
                    f.set("")
                    f_name = str(f)
                    self.config.set("Other", f_name, "")

                    if f_name in filters:
                        self.config.set("Other", f_name, str(filters[f_name]))
                        f.set(str(filters[f_name]))

                log_event(self.parentQueue,
                          "Successfully updated Futbin filters")

            self.config.set("Other", "futbin_url", str(url_on_gui))
            self.config.set("Other", "autoinput", str(self.autoInputVar.get()))

            with open("./data/settings.ini", 'w') as configfile:
                self.config.write(configfile)

            # every 1 second update labels
            self.after(3000, self.update_settings)
        except:
            print("Error updating GUI, restart")
예제 #3
0
    def startBot(self):
        log_event(self.parentQueue, "Autobidder started")
        self.startButton.config(state="disabled",
                                style="Accent.TButton",
                                text="RUNNING")

        self.thread = ThreadedClient(self.parentQueue, "autobidder",
                                     self.driver)
        self.thread.start()
        self.periodiccall()
예제 #4
0
def find_posts():
    try:
        posts = app.db.find().sort('created_at', -1)
    except Exception as e:
        log_event('error', 'find_all_posts',
                  "Failed to retrieve posts from the database. \
                   Reason: {}".format(str(e)))
        abort(500)
    else:
        log_event('info', 'find_all_posts',
                  'Successfully retrieved all posts from the database')
        return dumps(posts)
예제 #5
0
 def zipkin_fill_attrs(headers):
     try:
         zipkin_attrs=ZipkinAttrs(
             trace_id=headers['X-B3-TraceID'],
             span_id=headers['X-B3-SpanID'],
             parent_span_id=headers['X-B3-ParentSpanID'],
             flags=headers['X-B3-Flags'],
             is_sampled=headers['X-B3-Sampled'],
         )
     except KeyError:
         log_event('warning', 'zipkin_fill_headers', "Tracing enabled and some Zipkin HTTP headers are missing")
         zipkin_attrs = None
         pass
     return zipkin_attrs
예제 #6
0
def find_post(id):
    start_time = time.time()
    try:
        post = app.db.find_one({'_id': ObjectId(id)})
    except Exception as e:
        log_event('error', 'post_find',
                  "Failed to find the post. Reason: {}".format(str(e)),
                  request.values)
        abort(500)
    else:
        stop_time = time.time()  # + 0.3
        resp_time = stop_time - start_time
        app.post_read_db_seconds.observe(resp_time)
        log_event('info', 'post_find',
                  'Successfully found the post information', {'post_id': id})
        return dumps(post)
예제 #7
0
def add_post():
    try:
        title = request.values.get('title')
        link = request.values.get('link')
        created_at = request.values.get('created_at')
    except Exception as e:
        log_event('error', 'request_error',
                  "Bad input parameters. Reason: {}".format(str(e)))
        abort(400)
    try:
        app.db.insert({
            'title': title,
            'link': link,
            'created_at': created_at,
            'votes': 0
        })
    except Exception as e:
        log_event('error', 'post_create',
                  "Failed to create a post. Reason: {}".format(str(e)), {
                      'title': title,
                      'link': link
                  })
        abort(500)
    else:
        log_event('info', 'post_create', 'Successfully created a new post', {
            'title': title,
            'link': link
        })
        app.post_count.inc()
        return 'OK'
예제 #8
0
def vote():
    try:
        post_id = request.values.get('id')
        vote_type = request.values.get('type')
    except Exception as e:
        log_event('error', 'request_error',
                  "Bad input parameters. Reason: {}".format(str(e)))
        abort(400)
    try:
        post = app.db.find_one({'_id': ObjectId(post_id)})
        post['votes'] += int(vote_type)
        app.db.update_one({'_id': ObjectId(post_id)},
                          {'$set': {
                              'votes': post['votes']
                          }})
    except Exception as e:
        log_event('error', 'post_vote',
                  "Failed to vote for a post. Reason: {}".format(str(e)), {
                      'post_id': post_id,
                      'vote_type': vote_type
                  })
        abort(500)
    else:
        log_event('info', 'post_vote', 'Successful vote', {
            'post_id': post_id,
            'vote_type': vote_type
        })
        return 'OK'
예제 #9
0
 def initialize_driver(self):
     log_event(self.parentQueue, " - - - - Bot started - - - - ")
     self.driver = create_driver()
     setup_adblock(self.driver)