def main(): # Load information from our config.ini file ConfigManager.load_configuration() # We'll give it a good 10 tries to see if we can get the channel ID for i in range(10): if C.channel_id == '': print("Retrieving channel ID . . . Attempt {}".format(i + 1)) C.channel_id = get_channel_id_from_name(C.channel_name) print("Retrieving bot channel ID . . .") C.bot_channel_id = get_channel_id_from_name(C.bot_channel_name) else: break # If the ID is empty after we go through that, we'll just quit out # Otherwise, we'll move on to trying to authenticate if C.channel_id == '': print( "Could not retrieve channel ID. Check to make sure the username provided is correct." ) print("Quitting...") else: print("Channel ID successfully retreived.") #asyncio.get_event_loop().set_debug(True) _loop.run_until_complete(start())
def main(): # Load information from our config.ini file ConfigManager.load_configuration() # We'll give it a good 10 tries to see if we can get the channel ID for i in range(10): if C.channel_id == '': print("Retrieving channel ID . . . Attempt {}".format(i + 1)) C.channel_id = get_channel_id_from_name(C.channel_name) print("Retrieving bot channel ID . . .") C.bot_channel_id = get_channel_id_from_name(C.bot_channel_name) else: print("???") break # If the ID is empty after we go through that, we'll just quit out # Otherwise, we'll move on to trying to authenticate if C.channel_id == '': print( "Could not retrieve channel ID. Check to make sure the username provided is correct." ) print("Quitting...") else: print("Channel ID successfully retreived.") #asyncio.get_event_loop().set_debug(True) while (True): try: _loop.run_until_complete(start()) #(websockets.ConnectionResetError, websockets.ConnectionClosed): except websockets.exceptions.ConnectionClosed: print("Connection error.") print(sys.exc_info()) print("Restarting...") continue except KeyboardInterrupt: print("Keyboard Interrupt. Now exiting.") break except: print("Connection Terminated?") print(sys.exc_info()) break finally: print( "Unexpected non-exception error. Now exiting to prevent infinite loop." ) print(sys.exc_info()) break
def __init__(self): #loadPrcFile("Config.prc") ShowBase.__init__(self) self.config = ConfigManager.loadSettings() #Config stuff here self.filters = CommonFilters(base.win, base.cam) self.AOEnabled = False self.bloomEnabled = False self.invertEnabled = False self.OSD = True self.shadersLoaded = False self.xray_mode = False self.show_model_bounds = False self.fogEnabled = True self.mouseEnabled = False #Store which keys are currently pressed self.keyMap = { "1": 0, "escape": 0, "left": 0, "right": 0, "forward": 0, "backward": 0, "cam-left": 0, "cam-right": 0, } self.ButtonImage = loader.loadModel( "phase_3/models/gui/quit_button.bam") self.introButtons()
from flask import Flask, request, flash from src import ResponseManager, CookieManager, UserFileManager, ConfigManager app = Flask(__name__) app.secret_key = ConfigManager.get_config("APP_SECRET_KEY") app.config.update( APPLICATION_ROOT=ConfigManager.get_config("APP_APPLICATION_ROOT"), REMEMBER_COOKIE_HTTPONLY=ConfigManager.get_config("APP_SECURE"), REMEMBER_COOKIE_SECURE=ConfigManager.get_config("APP_SECURE")) def validate_file_cookie(cookie, file): return cookie is not None and CookieManager.validate_file_by_jwt( cookie, file) @app.route('/cholewp1/dl/file/<string:file_id>/name/<string:filename>', methods=['GET']) def get_file(file_id, filename): cookie = request.cookies.get("file") if not validate_file_cookie(cookie, file_id): return ResponseManager.create_response_401() try: return UserFileManager.get_file(file_id, filename) except FileNotFoundError: return ResponseManager.create_response_404() @app.route('/cholewp1/dl/file/<string:file_id>/thumbnail', methods=['GET']) def get_thumbnail(file_id):
from datetime import datetime import jwt from src import ConfigManager secret = ConfigManager.get_config("DL_COOKIE_SECRET_KEY") secure = ConfigManager.get_config("APP_SECURE") def validate_user_jwt(token, username): token = jwt.decode(token, secret, "HS256") expire = token['exp'] if username != token['user']: return False return datetime.now() < datetime.fromtimestamp(expire) def validate_file_by_jwt(token, file_id): token = jwt.decode(token, secret, "HS256") expire = token['exp'] file_ids = token['file_list'] if file_id not in file_ids: return False return datetime.now() < datetime.fromtimestamp(expire)
from functools import wraps from six.moves.urllib.parse import urlencode from authlib.flask.client import OAuth from flask import Flask, request, session, flash, redirect from werkzeug.utils import secure_filename from src import ResourceManager, SessionManager, FileManager, ResponseManager, CookieManager, ConfigManager __redirect_link_prefix = ConfigManager.get_config("DL_REDIRECT_LINK_PREFIX") __is_app_secured = ConfigManager.get_config("APP_SECURE") __application_base_url = ConfigManager.get_config( "WEBAPP_APPLICATION_BASE_URL") __login_callback = ConfigManager.get_config("WEBAPP_LOGIN_CALLBACK") __user_info_url = ConfigManager.get_config("OAUTH_USER_INFO") __oauth_client_id = ConfigManager.get_config("OAUTH_CLIENT_ID") app = Flask(__name__) app.secret_key = ConfigManager.get_config("APP_SECRET_KEY") app.config["APPLICATION_ROOT"] = ConfigManager.get_config( "APP_APPLICATION_ROOT") app.config.update(SESSION_COOKIE_HTTPONLY=__is_app_secured, SESSION_COOKIE_SECURE=__is_app_secured, REMEMBER_COOKIE_HTTPONLY=__is_app_secured, REMEMBER_COOKIE_SECURE=__is_app_secured) oauth = OAuth(app) auth0 = oauth.register( 'auth0', client_id=__oauth_client_id,
import os from src import ConfigManager __thumbnails_dir = "db/thumbnails/" __users_dir = "db/userfiles/" __my_rabbit_id = ConfigManager.get_config("DL_RABBIT_ID") def create_thumbnail(file_id): os.system("/usr/bin/convert " + __users_dir + file_id + " -resize 64x64 " + __thumbnails_dir + file_id) return None
def loadConfig(self): conf = ConfigManager.ConfigManager() conf.generateSettings() return conf.loadSettings()
import uuid from redis import Redis from src import ConfigManager __db = Redis() __db_table_user_file = "cholewp1:dl:v4:user_file" __db_table_file = "cholewp1:dl:v4:file" __db_table_shared_file = "cholewp1:dl:v5:shared_file" __sharelink_prefix = ConfigManager.get_config("WEBAPP_SHARELINK_PREFIX") def check_file_count(user): file_ids = get_user_file_ids(user) if len(file_ids) > 5: return False return True def get_new_file_id(user): if not check_file_count(user): return None __id = "file_" + str(uuid.uuid4()).replace("-", "X") db_rec = __db.hget(__db_table_file, __id) while db_rec is not None: __id = "file_" + str(uuid.uuid4()).replace("-", "X") db_rec = __db.hget(__db_table_file, __id) return __id