def get(self): account = accounts.account() if not account or not account.ADMIN_LINK_ACCESS_RIGHT: self.redirect(users.create_login_url(self.request.uri)) return self.player_name = self.request.get('p').lower() # Show admin UI template_values = { 'tabs': config.get_tabs(self.player_name, account), 'selected_tab': config.TAB_NONE, 'account': account, 'adminlog_url': self.get_url(config.ADMINLOG_URL), 'playerdetail_url': self.get_url(config.PLAYERDETAIL_URL), 'adjust_score_url': self.get_url(config.ADJUSTSCORE_URL), 'blockplayer_url': self.get_url(config.BLOCKPLAYER_URL), 'hideplayer_url': self.get_url(config.HIDEPLAYER_URL), 'resetplayer_url': self.get_url(config.RESETPLAYER_URL), 'sendchat_url': self.get_url(config.SENDCHAT_URL), 'drain_url': self.get_url(config.DRAIN_URL), 'logout_url': users.create_logout_url(self.request.uri), } self.response.headers['Content-Type'] = 'application/xhtml+xml' path = os.path.join(os.path.dirname(__file__), 'admin.xhtml') self.response.out.write(template.render(path, template_values))
def import2(self, accid, datafile): """ """ user = accounts.user(cherrypy.request.login) data = datafile.file.read() filename = "{}_{}_{}.csv".format(accid, datetime.datetime.utcnow().strftime("%Y%m%d"), randint(10000, 99999)) with open(os.path.join(config.HERE, 'static', 'imports', filename), 'w') as f: f.write(data) account = accounts.account(accid) account.import_transactions(filename) return self.view(accid)
def get_tabs(player, account=accounts.account()): tabs = [] tabs.append({ 'title': 'Leaderboard', 'id' : TAB_LEADERBOARD, 'url' : LEADERBOARD_URL }) if player: tabs.append({ 'title': 'Stats', 'id' : TAB_STATS, 'url' : STATS_URL }) tabs.append({ 'title': 'Games', 'id' : TAB_GAMES, 'url' : GAMES_URL }) tabs.append({ 'title': 'Search', 'id' : TAB_SEARCH, 'url' : SEARCH_URL }) tabs.append({ 'title': 'About', 'id' : TAB_ABOUT, 'url' : ABOUT_URL }) if account and account.ADMIN_LINK_ACCESS_RIGHT: tabs.append({ 'title': 'Admin', 'id' : TAB_ADMIN, 'url' : ADMIN_URL }) if player != '': for tab in tabs: tab['url'] = '%s?p=%s' % (tab['url'], player) return tabs
def get(self): # Requires an authenticated user with proper access rights account = accounts.account() if not account or not account.ADMIN_LOG_ACCESS_RIGHT: self.redirect(users.create_logout_url(self.request.uri)) # Get args self.get_args() # If json request, perform that response if self.request.get('j'): self.response.headers['Content-Type'] = 'text/plain' data = dict(tables=self.collect_tables()) self.response.out.write(json.dumps(data)) return # Calc all-url if self.player_name: all_url = '%s?p=%s&c=%d' % (config.ADMINLOG_URL, self.player_name, self.count) else: all_url = '%s?c=%d' % (config.ADMINLOG_URL, self.count) # Calc count-url if self.player_name: count_url = '%s?p=%s' % (config.ADMINLOG_URL, self.player_name) else: count_url = '%s?x=1' % config.ADMINLOG_URL # Otherwise render the template and serve the response template_values = { 'tabs': config.get_tabs(self.player_name, account), 'selected_tab': config.TAB_NONE, 'all_url': all_url, 'count_url': count_url, 'tables': self.collect_tables(), 'player_name': self.player_name, 'count': self.count, 'show_counts': [ 50, 100, 250, 500, 1000 ], } self.set_caching_headers(60) self.response.headers['Content-Type'] = 'application/xhtml+xml' path = os.path.join(os.path.dirname(__file__), 'adminlog.xhtml') self.response.out.write(template.render(path, template_values))
def get(self): # player_name is the player that is browsing. The tabs will be # populated with query args with this player name player_name = self.request.get('p') # stats_player is the player to get stats on. If 'u' isn't set, # use player_name. stats_player = self.request.get('u') if stats_player == '': stats_player = player_name p = player.load_from_name(stats_player, player_name) if not p: message.show(self, message.PLAYER_NOT_FOUND) return selected_tab = config.TAB_NONE if p.is_viewer_also_player(): selected_tab = config.TAB_STATS # get player detail url detail_url = '' account = accounts.account() if account and account.SEE_PLAYER_INFO_ACCESS_RIGHT: if player_name: detail_url = '%s?p=%s&q=%s' % (config.PLAYERDETAIL_URL, player_name, stats_player) else: detail_url = '%s?q=%s' % (config.PLAYERDETAIL_URL, stats_player) # Fill in the template template_values = { 'tabs': config.get_tabs(player_name, account), 'selected_tab': selected_tab, 'player': p, 'player_default_rating': gamestats.PLAYER_DEFAULT_RATING, 'detail_url': detail_url } self.set_caching_headers(config.INFOPAGE_MAX_AGE_SECONDS) self.response.headers['Content-Type'] = 'application/xhtml+xml' path = os.path.join(os.path.dirname(__file__), 'stats.xhtml') self.response.out.write(template.render(path, template_values))
def Bot(Crypto_Name): #set candle how long it takes to build candle candle_size = 10 #Calling initial functions #Calls excange functions exchange = Exchange_Access(desired_Exchange, Crypto_Name) #Stores data from old candles in data frame data_Handlings = data_Handling(exchange, candle_size) #account function to get account information accounts = account(desired_Exchange) while True: #Gets Crypto Curreny information from Exchange price, tick_stats = exchange.ticker() #takes in information from Exchange to Build Candle data_Handlings.candle_Builder(price, tick_stats) print(price) #Limits API calling to exchange limit time.sleep(exchange.rateLimit())
def get(self): # Requires an authenticated user with proper access rights account = accounts.account() if not account or not account.SEE_PLAYER_INFO_ACCESS_RIGHT: self.redirect(users.create_logout_url(self.request.uri)) # Get args self.get_args() # Query for results keys = [] if self.user_name: keys.append('player: %s' % self.user_name) if self.did: keys.append('did: %s' % self.did) if self.ip_address: keys.append('ip: %s' % self.ip_address) if len(keys) != 0: query_string = '%s' % ', '.join(keys) else: query_string = 'all' # If json request, perform that response if self.request.get('j'): self.response.headers['Content-Type'] = 'text/plain' data = dict(query_string=query_string, tables=self.collect_tables()) self.response.out.write(json.dumps(data)) return # Calc all-url if self.player_name: all_url = '%s?p=%s&c=%d' % (config.PLAYERDETAIL_URL, self.player_name, self.count) else: all_url = '%s?c=%d' % (config.PLAYERDETAIL_URL, self.count) # Calc count-url if self.player_name: if self.q: count_url = '%s?p=%s&q=%s' % (config.PLAYERDETAIL_URL, self.player_name, self.q) else: count_url = '%s?p=%s' % (config.PLAYERDETAIL_URL, self.player_name) else: if self.q: count_url = '%s?q=%s' % (config.PLAYERDETAIL_URL, self.q) else: count_url = '%s?x=1' % config.PLAYERDETAIL_URL # Otherwise render the template and serve the response template_values = { 'tabs': config.get_tabs(self.player_name, account), 'selected_tab': config.TAB_NONE, 'query_string': query_string, 'show_all': query_string != 'all', 'all_url': all_url, 'count_url': count_url, 'tables': self.collect_tables(), 'player_name': self.player_name, 'count': self.count, 'show_counts': [50, 100, 250, 500, 1000], } self.set_caching_headers(60) self.response.headers['Content-Type'] = 'application/xhtml+xml' path = os.path.join(os.path.dirname(__file__), 'playerdetail.xhtml') self.response.out.write(template.render(path, template_values))
def has_access(self): # Requires an authenticated user with proper access rights account = accounts.account() if account and account.HIDE_PLAYER_ACCESS_RIGHT: return account return None
def has_access(self): # Requires an authenticated user with proper access rights account = accounts.account() if account and account.ADJUST_SCORE_ACCESS_RIGHT: return account return None
def get(self): # Requires an authenticated user with proper access rights account = accounts.account() if not account or not account.SEE_PLAYER_INFO_ACCESS_RIGHT: self.redirect(users.create_logout_url(self.request.uri)) # Get args self.get_args() # Query for results keys = [] if self.user_name: keys.append('player: %s' % self.user_name) if self.did: keys.append('did: %s' % self.did) if self.ip_address: keys.append('ip: %s' % self.ip_address) if len(keys) != 0: query_string = '%s' % ', '.join(keys) else: query_string = 'all' # If json request, perform that response if self.request.get('j'): self.response.headers['Content-Type'] = 'text/plain' data = dict(query_string=query_string,tables=self.collect_tables()) self.response.out.write(json.dumps(data)) return # Calc all-url if self.player_name: all_url = '%s?p=%s&c=%d' % (config.PLAYERDETAIL_URL, self.player_name, self.count) else: all_url = '%s?c=%d' % (config.PLAYERDETAIL_URL, self.count) # Calc count-url if self.player_name: if self.q: count_url = '%s?p=%s&q=%s' % (config.PLAYERDETAIL_URL, self.player_name, self.q) else: count_url = '%s?p=%s' % (config.PLAYERDETAIL_URL, self.player_name) else: if self.q: count_url = '%s?q=%s' % (config.PLAYERDETAIL_URL, self.q) else: count_url = '%s?x=1' % config.PLAYERDETAIL_URL # Otherwise render the template and serve the response template_values = { 'tabs': config.get_tabs(self.player_name, account), 'selected_tab': config.TAB_NONE, 'query_string': query_string, 'show_all': query_string != 'all', 'all_url': all_url, 'count_url': count_url, 'tables': self.collect_tables(), 'player_name': self.player_name, 'count': self.count, 'show_counts': [ 50, 100, 250, 500, 1000 ], } self.set_caching_headers(60) self.response.headers['Content-Type'] = 'application/xhtml+xml' path = os.path.join(os.path.dirname(__file__), 'playerdetail.xhtml') self.response.out.write(template.render(path, template_values))
def have_access(self): account = accounts.account() if not account or not account.DRAIN_ACCESS_RIGHT: return False return True
def view(self, accid, description=None, category=None): acc = accounts.account(accid) _page = htmlobjects.Page(acc.name, "{} {}".format(acc.number, acc.sortcode)) return serve_template('account/view.html', _page, transactions=acc.get_transactions(description, category), categories=accounts.transaction.get_categories())
file_path = os.path.dirname(os.path.abspath(__file__)) if not (file_path in sys.path): sys.path.append(file_path) import paths admin_file = paths.admin_file_path if __name__ == "__main__": from encryption import cryption from files import write from accounts import account account_list = [] auth_list = ["master_login", "master_manager"] authorizations = "" for auth in auth_list: authorizations = authorizations + auth + "\t" authorizations = authorizations[:-1] account_list.append( account(cryption("admin"), cryption("admin"), cryption(authorizations))) account_list.append( account(cryption("admin1"), cryption("admin1"), cryption(authorizations))) buffer = "" for account in account_list: buffer = buffer + str(account) + "\n" buffer = buffer[:-1] write(admin_file, buffer)