def _run_script(self): username = self.username.get() password = self.password.get() message_text = self.text_message.get("1.0", END) group_name = self.distribution_menu_var.get() action = self.radio_var.get() schedule_action = self.check_box_schedule.get() minutes_entry = self.minutes_entry_value.get() hours_entry = self.hours_entry_value.get() days_entry = self.days_entry_value.get() valid = self._check_form(username, password, message_text, group_name) if valid: is_schedule = 0 if schedule_action: is_schedule = 1 dm_users_list = db.Database().get_users_from_dm_users( group_name) time_schedule = ScheduleCalc().calc_schedule_time( action, minutes_entry, hours_entry, days_entry) bot = DM(username, password) timing_thread = threading.Timer( time_schedule, bot.send_message_to_distribution_group, [message_text, dm_users_list, group_name, is_schedule]) timing_thread.start() else: dm_users_list = db.Database().get_users_from_dm_users( group_name) bot = DM(username, password) t = threading.Thread( target=bot.send_message_to_distribution_group, args=(message_text, dm_users_list, group_name, is_schedule)) t.start()
def _settings_data(self): self.database = db.Database() data_settings = self.database.get_data_from_settings() # Init the box list of distribution groups username_menu = self.username_option.get() if username_menu: distribution_groups = self.database.get_distribution_lists_by_username( username_menu) for group in distribution_groups: self.listbox.insert(END, group[1]) # This 'if' because when i run for the first time the program, # there is no 'data settings' - its empty. so i init it with 0 if data_settings == '' or data_settings is None: self.amount = 0 else: self.amount = data_settings[1] # Set the CheckButton self.title_amount[ 'text'] = 'LIKE/FOLLOW/COMMENT users who has more then {} likes '.format( data_settings[1]) self.check_schedule.set(data_settings[2]) self.current_hours['text'] = "HOURS: {}".format(data_settings[3]) self._activate_check()
def _remove_from_unfollow_list(self): name_selection = self.unfollow_users_list_box.get( self.unfollow_users_list_box.curselection()) if name_selection: index = self.unfollow_users_list_box.get(0, END).index(name_selection) self.unfollow_users_list_box.delete(index) db.Database().remove_username_from_unfollow_list(name_selection)
def _remove_group_from_distribution_list(self): group_selection = self.listbox.get(self.listbox.curselection()) if group_selection: database = db.Database() is_deleted = database.remove_group_from_distribution_list( group_selection) if is_deleted: self.listbox.delete(self.listbox.curselection())
def __init__(self, video_capture): self.video_capture = video_capture self.fcount = config["frequency_count"] self.icount = config["image_count"] self.frequency = config["frequency"] self.crop_face_dir = config['crop_image_dir'] self.db = db.Database('face_recognition')
def __init__(self, username, password): self.username = username self.password = password self.base_url = 'https://www.instagram.com' # the options from this website -> https://www.selenium.dev/documentation/en/webdriver/page_loading_strategy/ options = Options() options.page_load_strategy = 'eager' self.driver = webdriver.Chrome('chromedriver.exe', options=options) self.database = db.Database()
def _render_coin_balance_graph_exchange(self, exchange_id, timeframe, modifier): """ render timeline graph for specified date range and exchange """ # prepare the plot p = figure(width=800, height=350, x_axis_type="datetime") p.title.text = "Coin Overview" p.legend.location = "top_left" p.grid.grid_line_alpha = 0 p.xaxis.axis_label = 'Date' p.yaxis.axis_label = 'Coin' p.ygrid.band_fill_color = "olive" p.ygrid.band_fill_alpha = 0.1 database = db.Database(self.config['database']) # get all wallets from the exchange wallets = database.get_wallets_from_exchange(exchange_id) # loop trough all wallets and prepare the balance loop_count = 0 for w in wallets: # if we are working on EUROS we wont add it if w['currency'] == "EUR": continue # get the last n days of balance data balance = database.get_balance_from_wallet(w['id'], timeframe, modifier) # only get data from wallets with available balance if balance: # fix the dateformat for the balance entries for b in balance: time = datetime.fromtimestamp(b['timestamp']) b['timestamp'] = datetime.strftime(time, "%Y-%m-%d %H:%M:%S.%f") # convert to matrix balance = pandas.DataFrame(balance) # from here we convert to numpy else somehow no graph is displayed np_balance_balance = np.array(balance['balance']) np_balance_timestamp = np.array(balance['timestamp'], dtype=np.datetime64) # add a line with the coins # was not able to get the timeline working so we randomize # our colors a little bit (will fail with more then 15 wallets in one exchange) p.line(np_balance_timestamp, np_balance_balance, color=Category20[15][loop_count], legend=w['currency']) loop_count = loop_count + 1 script, div = components(p) return {'script': script, 'div': div}
def _display_users_to_boxlist(self, value): distribution_users = db.Database().get_users_from_dm_users(value) self.listbox.delete(0, 'end') self.num_distribution_users = 0 for user in distribution_users: self.listbox.insert(END, user[0]) self.num_distribution_users += 1 self.title_amount_users_list.config(text="{} Users".format( self.num_distribution_users), font=self.h3)
def __init__(self, connection, data): self.database = db.Database(connection) self.data = data self.category_list = [] self.random_products = [] self.id_chosen_product = 0 self.substitute = [] self.digits = [ v for k in self.data if k == 'digits' for v in self.data[k] ]
def unfollow_user(self, username): self._login() self._nav_user(username) time.sleep(2) self.driver.find_element_by_xpath( '//button[text()="Following"]').click() try: self._popup_unfollow() db.Database().remove_username_from_unfollow_list(username) except Exception as e: print('unfollow user: ', e)
def _render_rate_balance_graph_exchange(self, exchange_id, timeframe, modifier): """ render timeline graph for specified date range and exchange """ # prepare the plot p = figure(width=800, height=350, x_axis_type="datetime") p.title.text = "Exchange Rate Overview" p.legend.location = "top_left" p.grid.grid_line_alpha = 0 p.xaxis.axis_label = 'Date' p.yaxis.axis_label = 'Exchange Rate' p.ygrid.band_fill_color = "olive" p.ygrid.band_fill_alpha = 0.1 database = db.Database(self.config['database']) # get all wallets from the exchange wallets = database.get_wallets_from_exchange(exchange_id) # loop trough all wallets and prepare the balance loop_count = 0 for w in wallets: # if we are working on EUROS we wont add it if w['currency'] == "EUR": continue # get the last n days of exachange rates rate = database.get_rate_for_wallet(w['id'], 'EUR', timeframe, modifier) # only get data from wallets with available rates if rate: # fix the dateformat for the balance entries for r in rate: time = datetime.fromtimestamp(r['timestamp']) r['timestamp'] = datetime.strftime(time, "%Y-%m-%d %H:%M:%S.%f") # create a panda matrix rate = pandas.DataFrame(rate) # from here we convert to numpy else somehow no graph is displayed np_rate_rate = np.array(rate['rate']) np_rate_timestamp = np.array(rate['timestamp'], dtype=np.datetime64) p.circle(np_rate_timestamp, np_rate_rate, color=Category20[15][loop_count], legend="exchange rate {}".format(w['currency'])) loop_count = loop_count + 1 script, div = components(p) return {'script': script, 'div': div}
def _save_distribution_list(self): list_name = self.distribution_list_name.get() username_menu = self.username_option.get() # If list name is not empty, than enter to this block (save the name list in db) if list_name and username_menu: database = db.Database() is_saved = database.create_distribution_group( list_name, username_menu) if is_saved: self.listbox.insert(END, list_name) self.distribution_list_name.set('') else: print('Did not saved')
def unfollow_users(self, user_list): for user in user_list: self._nav_user(user) time.sleep(2) self.driver.find_element_by_xpath( '//button[text()="Following"]').click() try: self._popup_unfollow() db.Database().remove_username_from_unfollow_list(user) time.sleep(1) except Exception as e: print('unfollow users: ', e) self.driver.find_element_by_xpath( '/html/body/div[4]/div/div/div[3]/button[1]').click()
def overview(self): database = db.Database(self.config['database']) # lets get the exchanges from the database exchanges = [] exchanges_raw = database.get_exchanges() for e in exchanges_raw: exchange = { 'name': e['name'], 'wallets': [], 'coin_graph': self._render_coin_balance_graph_exchange( e['id'], self.config['overview']['timeframe'], self.config['overview']['modifier']), 'rate_graph': self._render_rate_balance_graph_exchange( e['id'], self.config['overview']['timeframe'], self.config['overview']['modifier']), 'euro_graph': self._render_euro_balance_graph_exchange( e['id'], self.config['overview']['timeframe'], self.config['overview']['modifier']), 'total': 0 } wallets_raw = database.get_wallets_from_exchange(e['id']) for w in wallets_raw: balance = database.get_last_balance_from_wallet(w['id']) exchange_rate_EUR = database.get_last_rate_for_wallet_currency( wallet_id=w['id'], timestamp=balance['timestamp'], to_currency="EUR") balance_in_EUR = math.ceil(balance['balance'] * exchange_rate_EUR) timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(balance['timestamp'])) exchange['wallets'].append({ 'timestamp': timestamp, 'type': w['type'], 'currency': w['currency'], 'balance': balance['balance'], 'balance_euro': balance_in_EUR }) exchange['total'] = exchange['total'] + balance_in_EUR exchanges.append(exchange) return template('overview', data={'exchanges': exchanges})
def _set_username_password(self, value): for account in self.accounts: if value == account[3]: self.username.set(account[3]) self.password.set(account[4]) self.unfollow_users_list_box.delete(0, 'end') self.amount_not_following = 0 self.unfollow_users = db.Database().get_unfollow_users( account[3]) for user in self.unfollow_users: self.unfollow_users_list_box.insert(END, user[2]) self.amount_not_following += 1 self.unfollow_title.config(text='You are following {}'.format( self.amount_not_following))
def _set_username_password_followers(self, value): for account in self.accounts: if value == account[3]: self.username_followers.set(account[3]) self.password_followers.set(account[4]) self.account_username = account[3] self.distribution_list = db.Database().get_distribution_lists_by_username(value) for group in self.distribution_list: self.groups_list.append(group[1]) if len(self.groups_list) > 0: self.distribution_menu = ttk.OptionMenu(self, self.distribution_menu_var, self.groups_list[0], *self.groups_list) self.distribution_menu.grid(column=0, columnspan=2, row=11, pady=20) self.distribution_title.grid_forget() else: self.distribution_title.grid(column=0, columnspan=2, row=11, pady=20) self.distribution_menu.grid_forget()
def _render_euro_balance_graph_exchange(self, exchange_id, timeframe, modifier): """ render a graph with total value of all wallets per exchange """ # prepare the plot p = figure(width=800, height=350, x_axis_type="datetime") p.title.text = "Euro Value Overview" p.legend.location = "top_left" p.grid.grid_line_alpha = 0 p.xaxis.axis_label = 'Date' p.yaxis.axis_label = 'Value in Euro' p.ygrid.band_fill_color = "olive" p.ygrid.band_fill_alpha = 0.1 database = db.Database(self.config['database']) balance = database.get_balance_in_euro_from_exchange( exchange_id, timeframe, modifier) if balance: # fix the dateformat for the balance entries for b in balance: time = datetime.fromtimestamp(b['timestamp']) b['timestamp'] = datetime.strftime(time, "%Y-%m-%d %H:%M:%S.%f") #print ("{} :: {} :: {}".format(exchange_id, w['id'],balance)) # convert to matrix balance = pandas.DataFrame(balance) # from here we convert to numpy else somehow no graph is displayed np_balance_balance = np.array(balance['euro']) np_balance_timestamp = np.array(balance['timestamp'], dtype=np.datetime64) # add a line with the coins # was not able to get the timeline working so we randomize # our colors a little bit (will fail with more then 15 wallets in one exchange) p.line(np_balance_timestamp, np_balance_balance, color=Category20[15][0], legend="Total in EUR") script, div = components(p) return {'script': script, 'div': div}
def _save_changes(self): database = db.Database() likes_amount = self.likes_amount.get() schedule_hour = self.schedule_hour.get() is_schedule = self.check_schedule.get() if likes_amount.isnumeric() and not int(likes_amount) < 0: database.save_settings(likes_amount, schedule_hour, is_schedule) messagebox.showinfo('Settings', 'Changes has been saved') self.likes_amount.set("") data = database.get_data_from_settings() self.title_amount[ 'text'] = 'LIKE/FOLLOW/COMMENT users who has more then {} likes '.format( data[1]) self.current_hours['text'] = "HOURS: {}".format(data[3]) else: messagebox.showerror('Only numbers', 'Please enter only numbers to amount entry')
def _set_username_password(self, value): self.groups_list = [] for account in self.accounts: if value == account[3]: self.username.set(account[3]) self.password.set(account[4]) self.distribution_list = db.Database( ).get_distribution_lists_by_username(value) for group in self.distribution_list: self.groups_list.append(group[1]) if len(self.groups_list) > 0: self.distribution_menu = ttk.OptionMenu( self, self.distribution_menu_var, self.groups_list[0], *self.groups_list) self.distribution_menu.grid(column=1, row=12) self.distribution_title.grid_forget() else: self.distribution_title.grid(column=1, row=12) self.distribution_menu.grid_forget()
def __init__(self, window): super().__init__(window) self.headerFont = tkfont.Font(family="Helvetica", size=12, weight='bold') self.titleFont = tkfont.Font(family="Helvetica", size=9) self.h3 = tkfont.Font(family="Helvetica", size=11, weight='bold') self.bold = tkfont.Font(weight='bold', size=10) self.results = tkfont.Font(size=11, weight='bold') self.username = StringVar() self.password = StringVar() self.menu = StringVar() self.amount_not_following = 0 self.amount_unfollow_users = 0 self.accounts = db.Database().get_accounts() user_name_list = [] for account in self.accounts: user_name_list.append(account[3]) ttk.Label(self, text='Check which users you follow don\'t follow you back', font=self.headerFont)\ .grid(column=0, row=0, padx=10, pady=10) # Users menu ttk.Label(self, text='Choose user', font=self.titleFont).grid(column=0, row=1, padx=10, pady=10) if len(user_name_list) > 0: ttk.OptionMenu(self, self.menu, user_name_list[0], *user_name_list, command=self._set_username_password).grid(column=0, row=2) else: ttk.Label(self, text='No Users, go to Accounts', font=self.titleFont).grid(column=0, row=2, padx=10, pady=10) # username and password form ttk.Label(self, text='username:'******'w') ttk.Entry(self, textvariable=self.username, width=30, show='*').grid(column=0, row=3) ttk.Label(self, text='password:'******'w') ttk.Entry(self, textvariable=self.password, width=30, show='*').grid(column=0, row=4) ttk.Button(self, text="RUN", command=self._check_form).grid(column=0, row=5) # box list display all users that the account has followed them self.unfollow_title = ttk.Label(self, text='You are following {}'.format( self.amount_not_following), font=self.bold) self.unfollow_title.grid(column=0, row=6, pady=20) self.unfollow_users_list_box = Listbox(self, width=25, height=16) self.unfollow_users_list_box.grid(column=0, row=7, rowspan=3) ttk.Button(self, text="REMOVE", command=self._remove_from_unfollow_list).grid(column=0, row=11, rowspan=1, pady=(10, 0)) ttk.Button(self, text="UNFOLLOW LIST", command=lambda: self._unfollow_users(self.unfollow_users))\ .grid(column=0, columnspan=2, row=11, pady=(10, 0), padx=(0, 200)) ttk.Button(self, text="UNFOLLOW USER", command=self._unfollow_user)\ .grid(column=0, columnspan=2, row=11, pady=(10, 0), padx=(200, 0)) # box list display all the names of people that are not following you back ttk.Label(self, text='Search results:', font=self.titleFont).grid(column=3, row=1) self.listbox = Listbox(self, width=30, height=13) self.listbox.grid(column=3, rowspan=5, row=2) ttk.Button(self, text="SEARCH", command=self._search_user).grid(column=3, row=8, rowspan=3, pady=(8, 8)) # right side - unfollow all users in list box schedule_frame = ttk.LabelFrame(self, text='UNFOLLOW EVERYONE') schedule_frame.grid(column=4, row=1, ipady=30, rowspan=2, padx=40) title = Label( schedule_frame, text= "By click this button, the program will go to your 'following' list " "and will unfollow all of them", bg='gray23', font=self.bold, fg='gray67') unfollow_btn = ttk.Button( schedule_frame, text="UNFOLLOW", command=self._unfollow_all_users_account_follow_them) title.pack(fill=X) unfollow_btn.place(anchor=S, relx=0.5, rely=0.8)
def __init__(self, window): super().__init__(window) self.location_url = StringVar() self.location = StringVar() self.check_box_like = IntVar() self.check_box_follow = IntVar() self.check_box_comment = IntVar() self.check_box_distribution_list = IntVar() self.check_box_schedule = IntVar() self.distribution_menu_var = StringVar() self.minutes_entry_value = IntVar() self.hours_entry_value = IntVar() self.days_entry_value = IntVar() self.amount = StringVar() self.menu = StringVar() self.username = StringVar() self.password = StringVar() self.groups_list = [] self.radio_var = IntVar() self.MINUTES = 0 self.HOURS = 1 self.DAYS = 2 self.check_box_schedule.set(0) self.check_box_comment.set(0) self.check_box_like.set(0) self.check_box_follow.set(0) self.check_box_distribution_list.set(0) self.headerFont = tkfont.Font(family="Helvetica", size=14, weight='bold') self.titleFont = tkfont.Font(family="Helvetica", size=9) self.h3 = tkfont.Font(family="Helvetica", size=11, weight='bold') self.bold = tkfont.Font(weight='bold', size=10) self.accounts = db.Database().get_accounts() user_name_list = [] for account in self.accounts: user_name_list.append(account[3]) ttk.Label(self, text='Find posts by Location', font=self.headerFont).grid(column=0, row=0, padx=10, pady=5) # Search location by URL ttk.Label(self, text='Find location by its URL', font=self.h3).grid(column=0, row=1, padx=10, pady=5) ttk.Entry(self, textvariable=self.location_url, width=40).grid(column=0, row=2) ttk.Label(self, text='*For example: \' https://www.instagram.com/explore/locations/212988663/new-york-new-york/ \' ', font=self.titleFont)\ .grid(column=0, row=3, padx=10, pady=5) # Search location by name ttk.Label(self, text='Find location by its name', font=self.h3).grid(column=0, row=4, padx=10, pady=5) ttk.Entry(self, textvariable=self.location, width=40, state=DISABLED).grid(column=0, row=5) ttk.Label( self, text= '*For example: \'New York, Shalvata, Lighthouse hotel...(Not active now...) \' ', font=self.titleFont).grid(column=0, row=6, padx=10, pady=5) # Amount of posts to like/comment/follow ttk.Label(self, text='Enter the number of posts to like/comment/follow', font=self.titleFont).grid(column=0, row=7, padx=10, pady=10) ttk.Entry(self, textvariable=self.amount).grid(column=0, row=8) # title for the checkbox ttk.Label(self, text='You can choose more then one action', font=self.h3).grid(column=0, row=9, padx=10, pady=10) # Checkbox buttons ttk.Checkbutton(self, text='LIKE posts', variable=self.check_box_like) \ .grid(column=0, row=11, padx=20, pady=10, sticky='w') ttk.Checkbutton(self, variable=self.check_box_follow, text='FOLLOW users', command=self._activate_distribution_check_box) \ .grid(column=0, row=12, padx=20, pady=10, sticky='w') self.distribution_check_box = ttk.Checkbutton( self, variable=self.check_box_distribution_list, text='Save users in distribution list?', state='disabled') self.distribution_check_box.grid(column=0, row=12, pady=10) # Groups distribution # If there are groups, it will display them. Else it will display message if len(self.groups_list) > 0: self.distribution_menu = ttk.OptionMenu(self, self.distribution_menu_var, self.groups_list[0], *self.groups_list, state='DISABLED') self.distribution_menu.grid(column=0, row=12) else: self.distribution_title = ttk.Label( self, text="Choose user to display distribution lists ", font=self.titleFont) self.distribution_title.grid(column=1, columnspan=1, row=12) ttk.Checkbutton(self, text='Write you\'re COMMENT on post ', variable=self.check_box_comment, command=self._activate_check, ) \ .grid(column=0, row=13, padx=20, pady=10, sticky='w') ttk.Checkbutton(self, text='Schedule action', variable=self.check_box_schedule) \ .grid(column=0, row=14, pady=10, padx=20, sticky='w') self.comment_entry = ttk.Entry(self, state='disabled', width=50) self.comment_entry.grid(column=0, row=15) ttk.Label(self, text="To comment on posts enter more then one word, use ' , ' to separate each word ", font=self.titleFont)\ .grid(column=0, row=16, padx=10, pady=10) ttk.Label(self, text="For example: Nice picture,Looking good,I like it ", font=self.titleFont)\ .grid(column=0, row=17) # Users menu ttk.Label(self, text='Choose user', font=self.titleFont).grid(column=1, row=1, padx=10, pady=10, columnspan=2) if len(user_name_list) > 0: print(user_name_list) ttk.OptionMenu(self, self.menu, user_name_list[0], *user_name_list, command=self._set_username_password).grid( column=1, row=2, columnspan=2) else: ttk.Label(self, text='No Users, go to Accounts', font=self.titleFont).grid(column=1, row=2, padx=10, pady=10) ttk.Label(self, text='Please enter username and password', font=self.titleFont) \ .grid(column=1, row=3, padx=10, pady=10, columnspan=2) ttk.Label(self, text='username:'******'w') ttk.Entry(self, textvariable=self.username, show='*', width=30).grid(column=2, row=4) ttk.Label(self, text='password:'******'w') ttk.Entry(self, textvariable=self.password, show='*', width=30).grid(column=2, row=5) # Schedule Actions schedule_frame = ttk.LabelFrame(self, text='Schedule Action') schedule_frame.grid(column=3, row=2, rowspan=2, ipadx=25, ipady=10, padx=(30, 0)) entry_frame = ttk.Frame(schedule_frame) radio_min = ttk.Radiobutton(schedule_frame, text='Minuts', variable=self.radio_var, value=self.MINUTES, command=self._enable_entry) radio_hours = ttk.Radiobutton(schedule_frame, text='Hours', variable=self.radio_var, value=self.HOURS, command=self._enable_entry) radio_days = ttk.Radiobutton(schedule_frame, text='Days', variable=self.radio_var, value=self.DAYS, command=self._enable_entry) self.minutes_entry = ttk.Entry(entry_frame, textvariable=self.minutes_entry_value) self.hours_entry = ttk.Entry(entry_frame, textvariable=self.hours_entry_value, state='disabled') self.days_entry = ttk.Entry(entry_frame, textvariable=self.days_entry_value, state='disabled') radio_min.place(relx=0.08, rely=0) radio_hours.place(relx=0.34, rely=0) radio_days.place(relx=0.6, rely=0) self.minutes_entry.pack(side=LEFT) self.hours_entry.pack(side=LEFT) self.days_entry.pack(side=LEFT) entry_frame.pack(side=LEFT, pady=(50, 0)) ttk.Button(self, text="SEARCH", command=self._run_script).grid(column=0, row=18, pady=8)
def __init__(self, window): super().__init__(window) self.user_url_followers = StringVar() self.user_url_following = StringVar() self.menu_followers = StringVar() self.menu_following = StringVar() self.username_following = StringVar() self.password_following = StringVar() self.username_followers = StringVar() self.password_followers = StringVar() self.num_following = IntVar() self.groups_list = [] self.check_box_distribution_list = IntVar() self.distribution_menu_var = StringVar() self.minutes_entry_value = IntVar() self.hours_entry_value = IntVar() self.days_entry_value = IntVar() self.check_box_schedule = IntVar() self.radio_var = IntVar() self.MINUTES = 0 self.HOURS = 1 self.DAYS = 2 self.check_box_schedule.set(0) self.check_box_distribution_list.set(0) self.accounts = db.Database().get_accounts() user_name_list = [] for account in self.accounts: user_name_list.append(account[3]) self.headerFont = tkfont.Font(family="Helvetica", size=12, weight='bold') self.titleFont = tkfont.Font(family="Helvetica", size=9) self.bold = tkfont.Font(weight='bold', size=10) # Left side Form ttk.Label(self, text='Follow after users that user following them', font=self.headerFont)\ .grid(column=0, row=0, padx=10, pady=10) ttk.Label(self, text='Enter the user URL', font=self.titleFont).grid(column=0, row=1, padx=10, pady=10) ttk.Entry(self, textvariable=self.user_url_following, width=50).grid(column=0, row=2) ttk.Label(self, text='Choose user', font=self.titleFont).grid(column=0, row=3, padx=10, pady=10) if len(user_name_list) > 0: ttk.OptionMenu(self, self.menu_following, user_name_list[0], *user_name_list, command=self._set_username_password_following)\ .grid(column=0, row=4) else: ttk.Label(self, text='No Users, go to Accounts', font=self.titleFont).grid(column=0, row=4, padx=10, pady=10) # username and password form ttk.Label(self, text='Please enter username and password', font=self.titleFont) \ .grid(column=0, row=5, padx=10, pady=10) ttk.Label(self, text='username:'******'w') ttk.Entry(self, textvariable=self.username_following, show='*', width=25).grid(column=0, row=6) ttk.Label(self, text='password:'******'w') ttk.Entry(self, textvariable=self.password_following, show='*', width=25).grid(column=0, row=7) ttk.Button(self, text="START FOLLOW", command=self._search_following).grid(column=0, row=10, pady=15) # Middle area - number of users to follow and distribution list ttk.Label(self, text='Enter the number of people to follow', font=self.titleFont).grid(column=0, columnspan=2, row=8, pady=10) self.following_input = ttk.Entry(self, textvariable=self.num_following, width=20) self.following_input.grid(column=0, columnspan=2, row=9, pady=10) self.distribution_check_box = ttk.Checkbutton(self, variable=self.check_box_distribution_list, text='Save users in distribution list?') self.distribution_check_box.grid(column=0, columnspan=2, row=10, pady=20) ttk.Checkbutton(self, text='Schedule action', variable=self.check_box_schedule) \ .grid(column=0, columnspan=2, row=12, pady=10, padx=20) # Groups distribution # If there are groups, it will display them. Else it will display message if len(self.groups_list) > 0: self.distribution_menu = ttk.OptionMenu(self, self.distribution_menu_var, self.groups_list[0], *self.groups_list, state='DISABLED') self.distribution_menu.grid(column=0, columnspan=2, row=11) else: self.distribution_title = ttk.Label(self, text="Choose user to display distribution lists ", font=self.titleFont) self.distribution_title.grid(column=0, columnspan=2, row=11) # Right side Form ttk.Label(self, text='Follow after users that following user', font=self.headerFont)\ .grid(column=1, row=0, padx=100, pady=10) ttk.Label(self, text='Enter the user URL', font=self.titleFont).grid(column=1, row=1, padx=10, pady=10) ttk.Entry(self, textvariable=self.user_url_followers, width=50).grid(column=1, row=2) ttk.Label(self, text='Choose user', font=self.titleFont).grid(column=1, row=3, padx=10, pady=10) if len(user_name_list) > 0: ttk.OptionMenu(self, self.menu_followers, user_name_list[0], *user_name_list, command=self._set_username_password_followers)\ .grid(column=1, row=4) else: ttk.Label(self, text='No Users, go to Accounts', font=self.titleFont).grid(column=1, row=4, padx=10, pady=10) # username and password form ttk.Label(self, text='Please enter username and password', font=self.titleFont) \ .grid(column=1, row=5, padx=10, pady=10) ttk.Label(self, text='username:'******'w') ttk.Entry(self, textvariable=self.username_followers, show='*', width=25).grid(column=1, row=6) ttk.Label(self, text='password:'******'w') ttk.Entry(self, textvariable=self.password_followers, show='*', width=25).grid(column=1, row=7) ttk.Button(self, text="START FOLLOW", command=self._search_followers).grid(column=1, row=10, pady=15) # Schedule Actions schedule_frame = ttk.LabelFrame(self, text='Schedule Action') schedule_frame.grid(column=2, row=2, rowspan=2, ipadx=25, ipady=10, padx=(30, 0)) entry_frame = ttk.Frame(schedule_frame) radio_min = ttk.Radiobutton(schedule_frame, text='Minuts', variable=self.radio_var, value=self.MINUTES, command=self._enable_entry) radio_hours = ttk.Radiobutton(schedule_frame, text='Hours', variable=self.radio_var, value=self.HOURS, command=self._enable_entry) radio_days = ttk.Radiobutton(schedule_frame, text='Days', variable=self.radio_var, value=self.DAYS, command=self._enable_entry) self.minutes_entry = ttk.Entry(entry_frame, textvariable=self.minutes_entry_value) self.hours_entry = ttk.Entry(entry_frame, textvariable=self.hours_entry_value, state='disabled') self.days_entry = ttk.Entry(entry_frame, textvariable=self.days_entry_value, state='disabled') radio_min.place(relx=0.08, rely=0) radio_hours.place(relx=0.34, rely=0) radio_days.place(relx=0.6, rely=0) self.minutes_entry.pack(side=LEFT) self.hours_entry.pack(side=LEFT) self.days_entry.pack(side=LEFT) entry_frame.pack(side=LEFT, pady=(50, 0))
def __init__(self, window): super().__init__(window) self.headerFont = tkfont.Font(family="Helvetica", size=12, weight='bold') self.titleFont = tkfont.Font(family="Helvetica", size=9) self.h3 = tkfont.Font(family="Helvetica", size=11, weight='bold') self.bold = tkfont.Font(weight='bold', size=10) self.check_box_distribution_list = IntVar() self.distribution_menu_var = StringVar() self.check_box_comment = IntVar() self.check_box_schedule = IntVar() self.check_box_follow = IntVar() self.check_box_like = IntVar() self.minutes_entry_value = IntVar() self.hours_entry_value = IntVar() self.days_entry_value = IntVar() self.username = StringVar() self.password = StringVar() self.hashtag = StringVar() self.amount = StringVar() self.menu = StringVar() self.radio_var = IntVar() self.groups_list = [] self.MINUTES = 0 self.HOURS = 1 self.DAYS = 2 self.check_box_comment.set(0) self.check_box_schedule.set(0) self.check_box_like.set(0) self.check_box_follow.set(0) self.check_box_distribution_list.set(0) self.accounts = db.Database().get_accounts() user_name_list = [] for account in self.accounts: user_name_list.append(account[3]) ttk.Label(self, text='Search for posts by Hash tag key word', font=self.headerFont)\ .grid(column=0, row=0, padx=10, pady=5) # username and password form ttk.Label(self, text='Please enter username and password', font=self.titleFont)\ .grid(column=0, row=1, padx=10, pady=5) ttk.Label(self, text='username:'******'w') ttk.Entry(self, textvariable=self.username, show='*').grid(column=0, row=2) ttk.Label(self, text='password:'******'w') ttk.Entry(self, textvariable=self.password, show='*').grid(column=0, row=3) # Hash tag form - for example 'travel' ttk.Label(self, text='Enter the hash tag keyword ', font=self.titleFont).grid(column=0, row=4, padx=10, pady=10) ttk.Entry(self, textvariable=self.hashtag).grid(column=0, row=5) # Amount of posts to like/comment/follow ttk.Label(self, text='Enter the number of posts to like/comment/follow', font=self.titleFont)\ .grid(column=0, row=6, padx=10,pady=10) ttk.Entry(self, textvariable=self.amount).grid(column=0, row=7) # title for the checkbox ttk.Label(self, text='You can choose more then one action', font=self.h3)\ .grid(column=0, row=8, padx=10,pady=10) # Checkbox buttons ttk.Checkbutton(self, text='LIKE posts', variable=self.check_box_like)\ .grid(column=0, row=11, padx=20, pady=10, sticky='w') ttk.Checkbutton(self, variable=self.check_box_follow, text='FOLLOW users', command=self._activate_distribution_check_box) \ .grid(column=0, row=12, padx=20, pady=10, sticky='w') self.distribution_check_box = ttk.Checkbutton( self, variable=self.check_box_distribution_list, text='Save users in distribution list?', state='disabled') self.distribution_check_box.grid(column=0, columnspan=1, row=12, pady=10) # Groups distribution # If there are groups, it will display them. Else it will display message if len(self.groups_list) > 0: self.distribution_menu = ttk.OptionMenu(self, self.distribution_menu_var, self.groups_list[0], *self.groups_list, state='DISABLED') self.distribution_menu.grid(column=1, row=12) else: self.distribution_title = ttk.Label( self, text="Choose user to display distribution lists ", font=self.titleFont) self.distribution_title.grid(column=1, row=12) ttk.Checkbutton(self, text='Write you\'re COMMENT on post ', variable=self.check_box_comment, command=self._activate_check).grid(column=0, row=13, padx=20, pady=10, sticky='w') ttk.Checkbutton(self, text='Schedule action', variable=self.check_box_schedule)\ .grid(column=0, row=14, pady=10, padx=20, sticky='w') # Comment entry self.comment_entry = ttk.Entry(self, state='disabled', width=50) self.comment_entry.grid(column=0, row=15) ttk.Label( self, text= "To comment on posts enter more then one word, use ' , ' to separate each word ", font=self.titleFont).grid(column=0, row=16, padx=10, pady=10) ttk.Label(self, text="For example: Nice picture,Looking good,I like it ", font=self.titleFont).grid(column=0, row=17) # Users menu ttk.Label(self, text='Choose user', font=self.titleFont).grid(column=1, row=1, padx=10, pady=10) if len(user_name_list) > 0: ttk.OptionMenu(self, self.menu, user_name_list[0], *user_name_list, command=self._set_username_password).grid(column=1, row=2) else: ttk.Label(self, text='No Users, go to Accounts', font=self.titleFont)\ .grid(column=1, row=2, padx=10, pady=10) # Schedule Actions schedule_frame = ttk.LabelFrame(self, text='Schedule Action') schedule_frame.grid(column=2, row=1, ipadx=35, ipady=10, padx=(30, 0)) entry_frame = ttk.Frame(schedule_frame) radio_min = ttk.Radiobutton(schedule_frame, text='Minuts', variable=self.radio_var, value=self.MINUTES, command=self._enable_entry) radio_hours = ttk.Radiobutton(schedule_frame, text='Hours', variable=self.radio_var, value=self.HOURS, command=self._enable_entry) radio_days = ttk.Radiobutton(schedule_frame, text='Days', variable=self.radio_var, value=self.DAYS, command=self._enable_entry) self.minutes_entry = ttk.Entry(entry_frame, textvariable=self.minutes_entry_value) self.hours_entry = ttk.Entry(entry_frame, textvariable=self.hours_entry_value, state='disabled') self.days_entry = ttk.Entry(entry_frame, textvariable=self.days_entry_value, state='disabled') radio_min.place(relx=0.08, rely=0) radio_hours.place(relx=0.34, rely=0) radio_days.place(relx=0.6, rely=0) self.minutes_entry.pack(side=LEFT) self.hours_entry.pack(side=LEFT) self.days_entry.pack(side=LEFT) entry_frame.pack(side=LEFT, pady=(50, 0)) # Run the script button ttk.Button(self, text="RUN", command=self._run_script).grid(column=0, row=18, pady=(15, 0))
from database import db from path import PATH DB_FILENAME = f"{PATH}../../resource/database/poppy_tester.save.db" database = db.Database(DB_FILENAME) with database: dbi = database() # database.table("elmsave", db.Column.Foreign("eid", database["Element"]))
import cv2 import argparse import face_recognition import numpy as np from database import db from conf import config init_db = db.Database('face_recognition') def parse_args(): '''parse args''' parser = argparse.ArgumentParser() parser.add_argument('--input_image', type=str, help='the directory of known people ') parser.add_argument( '--crop_image_dir', type=str, ) def crop_face(original_face): ''' FUNCTION: Crop images according webcam RETURN: List of crop images ''' crop_imgs = [] face_locations = face_recognition.face_locations(original_face) for i in range(len(face_locations)):
def query_exchanges(exchanges, database_file, schedule=None): """ query the given exchanges for the wallets and exchange rates write values into given database object """ # loop trough the exchanges # query all wallets # write wallets and current values into database database = db.Database(database_file) rates = cryptocompare.CrytpoCompare() try: for exchange in exchanges: try: # set the exchange name exchange_name = exchange.__class__.__name__ # lets get the wallets from the exchange wallets = exchange.wallets() # lets loop over the wallets and write them into the database for wallet in wallets: # make sure all the wallets exist in the database database.update_wallet(exchange_name=exchange_name, wallet_type=wallet.type, wallet_currency=wallet.currency) # now write the current balance and timestamp to the db database.insert_balance( exchange_name=exchange_name, wallet_type=wallet.type, wallet_currency=wallet.currency, wallet_balance=wallet.balance, wallet_timestamp=wallet.last_update.strftime('%s')) # lets get an approximation of the value of the currenct # historical price is not necessary up to date when running the request so we run against the current price exchange_rates = rates.price(from_currency=wallet.currency, exchange=exchange_name) if not exchange_rates: exchange_rates = rates.price( from_currency=wallet.currency) # now add the rates to the database for from_currency, currency_rates in exchange_rates.items( ): for to_currency, rate in currency_rates.items(): database.insert_rates( exchange_name=exchange_name, from_currency=from_currency, to_currency=to_currency, rate=rate, rate_timestamp=wallet.last_update.strftime( '%s')) except BaseException as err: logger.error( "problem encountered while requesting wallets from {}. error message: {}" .format(exchange_name, err)) except Exception as err: raise if schedule: Timer(int(schedule), query_exchanges, args=(exchanges, database_file, schedule)).start()
def __init__(self, window): self.window = window self.likes_amount = StringVar() self.check_schedule = IntVar() self.schedule_hour = IntVar() self.username_option = StringVar() self.distribution_list_name = StringVar() self.headerFont = tkfont.Font(family="Helvetica", size=12, weight='bold') self.titleFont = tkfont.Font(family="Helvetica", size=9) self.bold = tkfont.Font(weight='bold', size=10) self.amount = 0 self.accounts = db.Database().get_accounts() user_name_list = [] for account in self.accounts: user_name_list.append(account[3]) ttk.Label(self.window, text='SETTINGS ', font=self.headerFont) \ .grid(column=0, row=0, padx=10, pady=10) self.title_amount = ttk.Label( self.window, text='LIKE/FOLLOW/COMMENT posts who have more then {} likes '. format(self.amount), font=self.titleFont) self.title_amount.grid(column=0, row=1, padx=10, pady=10) ttk.Entry(self.window, textvariable=self.likes_amount).grid(column=0, row=2) # Schedule Frame configuration schedule_frame = ttk.LabelFrame(self.window, text='SCHEDULE UNFOLLOW') schedule_frame.grid(column=1, row=1, ipady=50, rowspan=3) title = Label( schedule_frame, text="Schedule the time to unfollow users that you followed them", bg='gray23', font=self.bold, fg='gray67') self.check_active = Checkbutton(schedule_frame, text='Active function', bg='gray23', font=self.titleFont, pady=5, padx=5, fg='gray67', command=self._activate_check, variable=self.check_schedule) self.spin_hours = Spinbox(schedule_frame, from_=0, to=1000, bg='gray23', state=DISABLED, width=8, textvariable=self.schedule_hour) hours_label = Label(schedule_frame, text="Hours", bg='gray23', fg='gray67') self.current_hours = Label(schedule_frame, text="HOURS:", bg='gray23', fg='gray67') title.pack(fill=X) self.check_active.place(anchor=NW, relx=0, rely=0.4) self.spin_hours.place(anchor=N, relx=0.4, rely=0.4) hours_label.place(anchor=N, relx=0.55, rely=0.4) self.current_hours.place(relx=0, rely=0.8) ttk.Button(self.window, text="SAVE CHANGES", command=self._save_changes, width=30)\ .grid(column=0, columnspan=4, row=4, pady=15) # Distribution list for DM distribution_list = ttk.LabelFrame(self.window, text='Distribution list') distribution_list.grid(column=2, row=1, ipady=120, ipadx=50, padx=20, rowspan=4) title = Label(distribution_list, text="Create distribution lists to DM them ", bg='gray23', font=self.bold, fg='gray67') self.listbox = Listbox(distribution_list, width=20, height=10) list_name = Label(distribution_list, text="Enter list name ", bg='gray23', fg='gray67') input_list_name = ttk.Entry(distribution_list, textvariable=self.distribution_list_name) add_btn = ttk.Button(distribution_list, text="ADD", width=10, command=self._save_distribution_list) remove_btn = ttk.Button( distribution_list, text="REMOVE", width=10, command=self._remove_group_from_distribution_list) username_choose_title = Label(distribution_list, text="Please choose a username", bg='gray23', fg='gray67') users_list_option = ttk.OptionMenu(distribution_list, self.username_option, user_name_list[0], *user_name_list, command=self._set_users_groups) title.pack(fill=X) list_name.place(relx=0.0, rely=0.2) input_list_name.place(relx=0.0, rely=0.3) username_choose_title.place(relx=0.0, rely=0.5) users_list_option.place(relx=0.0, rely=0.6) self.listbox.place(relx=0.6, rely=0.2) add_btn.place(relx=0.6, rely=0.9) remove_btn.place(relx=0.2, rely=0.9) # Init data self._settings_data()
def __init__(self, window): super().__init__(window) self.headerFont = tkfont.Font(family="Helvetica", size=12, weight='bold') self.titleFont = tkfont.Font(family="Helvetica", size=9) self.h3 = tkfont.Font(family="Helvetica", size=11, weight='bold') self.bold = tkfont.Font(weight='bold', size=10) self.distribution_menu_var = StringVar() self.num_distribution_users = 0 self.users_menu = StringVar() self.username = StringVar() self.password = StringVar() self.direct_message = StringVar() self.groups_list = [] self.check_box_distribution_list = IntVar() self.distribution_menu_var = StringVar() self.minutes_entry_value = IntVar() self.hours_entry_value = IntVar() self.days_entry_value = IntVar() self.check_box_schedule = IntVar() self.radio_var = IntVar() self.MINUTES = 0 self.HOURS = 1 self.DAYS = 2 self.check_box_schedule.set(0) self.accounts = db.Database().get_accounts() user_name_list = [] for account in self.accounts: user_name_list.append(account[3]) ttk.Label(self, text='Send direct messages to distribution groups', font=self.headerFont)\ .grid(column=0, row=0, padx=10, pady=10) # username and password form ttk.Label(self, text='Please enter username and password', font=self.titleFont)\ .grid(column=0, row=1, padx=10, pady=10) ttk.Label(self, text='username:'******'w') ttk.Entry(self, textvariable=self.username, show='*').grid(column=0, row=2) ttk.Label(self, text='password:'******'w') ttk.Entry(self, textvariable=self.password, show='*').grid(column=0, row=3) ttk.Label(self, text='Choose user', font=self.titleFont).grid(column=1, row=1, padx=10, pady=10) if len(user_name_list) > 0: ttk.OptionMenu(self, self.users_menu, user_name_list[0], *user_name_list, command=self._set_username_password).grid(column=1, row=2) else: ttk.Label(self, text='No Users, go to Accounts', font=self.titleFont)\ .grid(column=1, row=2, padx=10, pady=10) # Direct Messages ttk.Label(self, text='Type your message', font=self.titleFont).grid(column=0, row=4, padx=10, pady=10) self.text_message = Text(self, height=7, width=50) self.text_message.grid(column=0, row=5, padx=20) # Groups distribution # If there are groups, it will display them. Else it will display message if len(self.groups_list) > 0: self.distribution_menu = ttk.OptionMenu( self, self.distribution_menu_var, self.groups_list[0], *self.groups_list, command=self._display_users_to_boxlist) self.distribution_menu.grid(column=1, row=3, rowspan=3) else: self.distribution_title = ttk.Label( self, text="Choose user to display distribution lists ", font=self.titleFont) self.distribution_title.grid(column=1, row=3, rowspan=3) # Run the script button ttk.Button(self, text="SEND", command=self._run_script).grid(column=0, row=6, pady=16) # Display distribution users box self.listbox = Listbox(self, width=25, height=15) self.listbox.grid(column=2, row=3, rowspan=4, padx=(10, 0)) self.title_amount_users_list = ttk.Label( self, text="{} Users".format(self.num_distribution_users), font=self.h3) self.title_amount_users_list.grid(column=2, row=7, pady=(10, 0)) # Schedule Actions schedule_frame = ttk.LabelFrame(self, text='Schedule Action') schedule_frame.grid(column=3, row=2, rowspan=2, ipadx=25, ipady=10, padx=(30, 0)) entry_frame = ttk.Frame(schedule_frame) radio_min = ttk.Radiobutton(schedule_frame, text='Minuts', variable=self.radio_var, value=self.MINUTES, command=self._enable_entry) radio_hours = ttk.Radiobutton(schedule_frame, text='Hours', variable=self.radio_var, value=self.HOURS, command=self._enable_entry) radio_days = ttk.Radiobutton(schedule_frame, text='Days', variable=self.radio_var, value=self.DAYS, command=self._enable_entry) self.minutes_entry = ttk.Entry(entry_frame, textvariable=self.minutes_entry_value) self.hours_entry = ttk.Entry(entry_frame, textvariable=self.hours_entry_value, state='disabled') self.days_entry = ttk.Entry(entry_frame, textvariable=self.days_entry_value, state='disabled') radio_min.place(relx=0.08, rely=0) radio_hours.place(relx=0.34, rely=0) radio_days.place(relx=0.6, rely=0) self.minutes_entry.pack(side=LEFT) self.hours_entry.pack(side=LEFT) self.days_entry.pack(side=LEFT) entry_frame.pack(side=LEFT, pady=(50, 0)) ttk.Checkbutton(self, text='Schedule action', variable=self.check_box_schedule) \ .grid(column=3, row=4, pady=10, padx=20)
if schedule: Timer(int(schedule), query_exchanges, args=(exchanges, database_file, schedule)).start() # # main # if __name__ == '__main__': try: configuration = WalletsConfiguration() # initialuze the different exchanges database = db.Database(configuration.global_settings['database']) exchanges = [] for name, value in configuration.exchanges.items(): # create the exchange object if name == "Bitstamp": exchange = eval(name)(value['customerid'], value['key'], value['secret']) else: exchange = eval(name)(value['key'], value['secret']) exchanges.append(exchange) # and make sure the exchange is registered in the database database.update_exchange(name) database = None # now lets start reading our current wallets from the different exchanges if int(configuration.global_settings['schedule']) > 0: