Python settings.settings() Examples
The following are 30
code examples of settings.settings().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
settings
, or try the search function
.
Example #1
Source File: snake_app.py From SnakeAI with MIT License | 6 votes |
def init_window(self): self.centralWidget = QtWidgets.QWidget(self) self.setCentralWidget(self.centralWidget) self.setWindowTitle('Snake AI') self.setGeometry(self.top, self.left, self.width, self.height) # Create the Neural Network window self.nn_viz_window = NeuralNetworkViz(self.centralWidget, self.snake) self.nn_viz_window.setGeometry(QtCore.QRect(0, 0, 600, self._snake_widget_height + self.border[1] + self.border[3] + 200)) self.nn_viz_window.setObjectName('nn_viz_window') # Create SnakeWidget window self.snake_widget_window = SnakeWidget(self.centralWidget, self.board_size, self.snake) self.snake_widget_window.setGeometry(QtCore.QRect(600 + self.border[0], self.border[1], self.snake_widget_width, self.snake_widget_height)) self.snake_widget_window.setObjectName('snake_widget_window') # Genetic Algorithm Stats window self.ga_window = GeneticAlgoWidget(self.centralWidget, self.settings) self.ga_window.setGeometry(QtCore.QRect(600, self.border[1] + self.border[3] + self.snake_widget_height, self._snake_widget_width + self.border[0] + self.border[2] + 100, 200-10)) self.ga_window.setObjectName('ga_window')
Example #2
Source File: videoDownloader.py From Liked-Saved-Image-Downloader with MIT License | 6 votes |
def shouldUseYoutubeDl(url): for siteMask in youtubeDlSitesSupported: if siteMask in url: isBlacklisted = False for blacklistSite in youtubeDlBlacklistSites: if blacklistSite in url: isBlacklisted = True break # Use the gfycat api for these, if available # Ever since the creation of RedGifs, use YoutubeDL for all gfycat links... # if settings.settings['Gfycat_Client_id'] and 'gfycat.com' in url: # isBlacklisted = True if isBlacklisted: # We probably have another downloader return False # YoutubeDL should support this site return True return False # Returns (success or failure, output file or failure message)
Example #3
Source File: LikedSavedDownloaderServer.py From Liked-Saved-Image-Downloader with MIT License | 6 votes |
def open(self): global userSessionData currentUser = login_get_current_user(self) if not currentUser: # Failed authorization return None self.connections.add(self) if currentUser not in userSessionData: newSessionData = SessionData() userSessionData[currentUser] = newSessionData self.sessionData = userSessionData[currentUser] self.sessionData.acquire() # Set up the directory cache with the top-level output self.changeCurrentDirectory(settings.settings['Output_dir']) self.sessionData.release()
Example #4
Source File: LikedSavedDownloaderServer.py From Liked-Saved-Image-Downloader with MIT License | 6 votes |
def getRandomImage(filteredImagesCache=None, randomImageFilter=''): if not savedImagesCache: generateSavedImagesCache(settings.settings['Output_dir']) if filteredImagesCache: randomImage = random.choice(filteredImagesCache) else: randomImage = random.choice(savedImagesCache) print('\tgetRandomImage(): Chose random image {} (filter {})'.format(randomImage, randomImageFilter)) serverPath = utilities.outputPathToServerPath(randomImage) return randomImage, serverPath # # Tornado handlers # # See https://github.com/tornadoweb/tornado/blob/stable/demos/blog/blog.py # https://www.tornadoweb.org/en/stable/guide/security.html
Example #5
Source File: connect_with_proxy.py From Office365-REST-Python-Client with MIT License | 5 votes |
def set_proxy(request): proxies = {settings['url']: 'https://127.0.0.1:8888'} request.proxies = proxies
Example #6
Source File: main.py From mltshp with Mozilla Public License 2.0 | 5 votes |
def app_settings(cls): dirname = os.path.dirname(os.path.abspath(__file__)) return { "debug": options.debug, "cookie_secret": options.cookie_secret, "xsrf_cookies": options.xsrf_cookies, "twitter_consumer_key": options.twitter_consumer_key, "twitter_consumer_secret": options.twitter_consumer_secret, # invariant settings "login_url": "/sign-in", "static_path": os.path.join(dirname, "static"), "template_path": os.path.join(dirname, "templates"), "ui_modules": lib.uimodules, }
Example #7
Source File: main.py From mltshp with Mozilla Public License 2.0 | 5 votes |
def __init__(self, *args, **settings): self.db = register_connection(host=options.database_host, name=options.database_name, user=options.database_user, password=options.database_password, charset="utf8mb4") if options.use_query_cache: lib.flyingcow.cache.use_query_cache = True if options.stripe_secret_key: stripe.api_key = options.stripe_secret_key super(MltshpApplication, self).__init__(*args, **settings)
Example #8
Source File: import_files.py From Office365-REST-Python-Client with MIT License | 5 votes |
def get_token(auth_ctx): """Acquire token via client credential flow :type auth_ctx: adal.AuthenticationContext """ token = auth_ctx.acquire_token_with_client_credentials( "https://graph.microsoft.com", settings['client_credentials']['client_id'], settings['client_credentials']['client_secret']) return token
Example #9
Source File: export_files.py From Office365-REST-Python-Client with MIT License | 5 votes |
def get_token(auth_ctx): """Acquire token via client credential flow (ADAL Python library is utilized) :type auth_ctx: adal.AuthenticationContext """ token = auth_ctx.acquire_token_with_client_credentials( "https://graph.microsoft.com", settings['client_credentials']['client_id'], settings['client_credentials']['client_secret']) return token
Example #10
Source File: print_folders_and_files.py From Office365-REST-Python-Client with MIT License | 5 votes |
def get_token_for_user(auth_ctx): """ Acquire token via user credentials :type auth_ctx: adal.AuthenticationContext """ token = auth_ctx.acquire_token_with_username_password( 'https://graph.microsoft.com', settings['user_credentials']['username'], settings['user_credentials']['password'], settings['client_credentials']['client_id']) return token
Example #11
Source File: delete_deletedObjects.py From Office365-REST-Python-Client with MIT License | 5 votes |
def get_token_for_user(auth_ctx): """ :type auth_ctx: adal.AuthenticationContext """ token = auth_ctx.acquire_token_with_username_password( 'https://graph.microsoft.com', settings['user_credentials']['username'], settings['user_credentials']['password'], settings['client_credentials']['client_id']) return token
Example #12
Source File: import_users.py From Office365-REST-Python-Client with MIT License | 5 votes |
def acquire_token(auth_ctx): """ :type auth_ctx: adal.AuthenticationContext """ token = auth_ctx.acquire_token_with_username_password( 'https://graph.microsoft.com', settings['user_credentials']['username'], settings['user_credentials']['password'], settings['client_credentials']['client_id']) return token
Example #13
Source File: send_message.py From Office365-REST-Python-Client with MIT License | 5 votes |
def get_token(auth_ctx): """Acquire token via client credential flow (ADAL Python library is utilized)""" token = auth_ctx.acquire_token_with_client_credentials( "https://graph.microsoft.com", settings['client_credentials']['client_id'], settings['client_credentials']['client_secret']) return token
Example #14
Source File: utilities.py From Liked-Saved-Image-Downloader with MIT License | 5 votes |
def outputPathToDatabasePath(path): # This is a little weird return path.split(settings.settings['Output_dir'])[1]
Example #15
Source File: test_sharepoint_team_site.py From Office365-REST-Python-Client with MIT License | 5 votes |
def setUpClass(cls): super(TestTeamSite, cls).setUpClass() user_credentials = UserCredential(settings['user_credentials']['username'], settings['user_credentials']['password']) cls.client = ClientContext(settings['url']).with_credentials(user_credentials) cls.site_manager = GroupSiteManager(cls.client)
Example #16
Source File: test_sharepoint_search.py From Office365-REST-Python-Client with MIT License | 5 votes |
def setUpClass(cls): super(TestSearch, cls).setUpClass() user_credentials = UserCredential(settings['user_credentials']['username'], settings['user_credentials']['password']) cls.client = ClientContext(settings['url']).with_credentials(user_credentials) cls.search = SearchService(cls.client)
Example #17
Source File: test_sharepoint_comminication_site.py From Office365-REST-Python-Client with MIT License | 5 votes |
def setUpClass(cls): super(TestCommunicationSite, cls).setUpClass() ctx_auth = AuthenticationContext(url=settings['url']) ctx_auth.acquire_token_for_user(username=settings['user_credentials']['username'], password=settings['user_credentials']['password']) cls.client = ClientContext(settings['url'], ctx_auth) cls.site_manager = SPSiteManager(cls.client)
Example #18
Source File: test_sharepoint_web.py From Office365-REST-Python-Client with MIT License | 5 votes |
def test2_get_web_from_page_url(self): page_url = "{site_url}SitePages/Home.aspx".format(site_url=settings['url']) result = Web.get_web_url_from_page_url(self.client, page_url) self.client.execute_query() self.assertIsNotNone(result.value)
Example #19
Source File: test_sharepoint_web.py From Office365-REST-Python-Client with MIT License | 5 votes |
def test3_get_list_item_by_url(self): page_url = "SitePages/Home.aspx".format(site_url=settings['url']) target_item = self.client.web.get_list_item(page_url) self.client.execute_query() self.assertIsNotNone(target_item.resource_path)
Example #20
Source File: test_listdataservice.py From Office365-REST-Python-Client with MIT License | 5 votes |
def setUpClass(cls): super(TestSharePointListDataService, cls).setUpClass() credential = ClientCredential(settings['client_credentials']['client_id'], settings['client_credentials']['client_secret']) cls.client = ListDataService.connect_with_credentials(settings['url'], credential)
Example #21
Source File: test_sharepoint_tenant.py From Office365-REST-Python-Client with MIT License | 5 votes |
def setUpClass(cls): tenant = os.environ.get('office365_python_sdk_tenant', 'mediadev8') admin_site_url = "https://{0}-admin.sharepoint.com/".format(tenant) credentials = UserCredential(settings['user_credentials']['username'], settings['user_credentials']['password']) cls.client = ClientContext(admin_site_url).with_credentials(credentials) cls.tenant = Tenant(cls.client)
Example #22
Source File: test_sharepoint_sharing.py From Office365-REST-Python-Client with MIT License | 5 votes |
def setUpClass(cls): credentials = UserCredential(user_name=settings['user_credentials']['username'], password=settings['user_credentials']['password']) cls.client = ClientContext(settings['url']).with_credentials(credentials) current_user = cls.client.web.currentUser cls.client.load(current_user) cls.client.execute_query() cls.target_user = current_user
Example #23
Source File: graph_case.py From Office365-REST-Python-Client with MIT License | 5 votes |
def get_token(auth_ctx): """ Get token :type auth_ctx: adal.AuthenticationContext """ token = auth_ctx.acquire_token_with_username_password( 'https://graph.microsoft.com', settings['user_credentials']['username'], settings['user_credentials']['password'], settings['client_credentials']['client_id']) return token
Example #24
Source File: graph_case.py From Office365-REST-Python-Client with MIT License | 5 votes |
def setUpClass(cls): cls.client = GraphClient(settings['tenant'], get_token)
Example #25
Source File: imgurDownloader.py From Liked-Saved-Image-Downloader with MIT License | 5 votes |
def getImgurAuth(): imgurAuth = None if settings.hasImgurSettings(): return ImgurAuth(settings.settings['Imgur_client_id'], settings.settings['Imgur_client_secret']) else: logger.log('No Imgur Client ID and/or Imgur Client Secret was provided, or album download is not' ' enabled. This is required to download imgur albums. They will be ignored. Check' ' settings.txt for how to fill in these values.') return None
Example #26
Source File: app.py From listen1 with MIT License | 5 votes |
def __init__(self): tornado.web.Application.__init__(self, url_patterns, **settings)
Example #27
Source File: redis_conn.py From codo-cmdb with GNU General Public License v3.0 | 5 votes |
def create_redis_pool(): redis_configs = settings[const.REDIS_CONFIG_ITEM][const.DEFAULT_RD_KEY] pool = redis.ConnectionPool(host=redis_configs['host'], port=redis_configs['port'], password=redis_configs['password'], db=redis_configs[const.RD_DB_KEY], decode_responses=True) return pool
Example #28
Source File: snake_app.py From SnakeAI with MIT License | 5 votes |
def _mutation(self, child1_weights: np.ndarray, child2_weights: np.ndarray, child1_bias: np.ndarray, child2_bias: np.ndarray) -> None: scale = .2 rand_mutation = random.random() mutation_bucket = np.digitize(rand_mutation, self._mutation_bins) mutation_rate = self._mutation_rate if self.settings['mutation_rate_type'].lower() == 'decaying': mutation_rate = mutation_rate / sqrt(self.current_generation + 1) # Gaussian if mutation_bucket == 0: # Mutate weights gaussian_mutation(child1_weights, mutation_rate, scale=scale) gaussian_mutation(child2_weights, mutation_rate, scale=scale) # Mutate bias gaussian_mutation(child1_bias, mutation_rate, scale=scale) gaussian_mutation(child2_bias, mutation_rate, scale=scale) # Uniform random elif mutation_bucket == 1: # Mutate weights random_uniform_mutation(child1_weights, mutation_rate, -1, 1) random_uniform_mutation(child2_weights, mutation_rate, -1, 1) # Mutate bias random_uniform_mutation(child1_bias, mutation_rate, -1, 1) random_uniform_mutation(child2_bias, mutation_rate, -1, 1) else: raise Exception('Unable to determine valid mutation based off probabilities.')
Example #29
Source File: CreateDatabase.py From Liked-Saved-Image-Downloader with MIT License | 5 votes |
def AddAllFromReddit(database, settings): if not settings.hasRedditSettings(): logger.log('Reddit settings are not provided!') return submissions = [] logger.log('Adding last 1000 liked/saved submissions from Reddit. This will take a long time.') redditSubmissions, redditComments, earlyOutPoints = redditScraper.getRedditUserLikedSavedSubmissions( settings.settings['Username'], settings.settings['Password'], settings.settings['Client_id'], settings.settings['Client_secret'], request_limit = None, # No limit = request as many as possible (1000) saveLiked = settings.settings['Reddit_Save_Liked'], saveSaved = settings.settings['Reddit_Save_Saved'], earlyOutPointSaved = None, earlyOutPointLiked = None, unlikeLiked = False, unsaveSaved = False) logger.log('Retrieved submissions, adding to database...') for submission in redditSubmissions: database.addSubmission(submission) for comment in redditComments: database.addComment(comment) logger.log('Done! Saved {} submissions and {} comments'.format(len(redditSubmissions), len(redditComments)))
Example #30
Source File: redditUserImageScraper.py From Liked-Saved-Image-Downloader with MIT License | 5 votes |
def initialize(): settings.getSettings() if not settings.settings['Database']: logger.log('Please provide a location for the Database') return # Do this early so we can use it anywhere LikedSavedDatabase.initializeFromSettings(settings.settings)