def get_settings(self): config = ConfigParser.RawConfigParser() # Checks if the settings settings file already exists if os.path.isfile(os.path.join(__root__.path(), CONFIG_DIR + SETTINGS_FILENAME)): config.read(CONFIG_DIR + SETTINGS_FILENAME) return config raise ConfigurationFileNotFound(CONFIG_DIR + SETTINGS_FILENAME)
def get_settings(self): config = ConfigParser.RawConfigParser() # Checks if the settings settings file already exists path = os.path.join(__root__.path(), CONFIG_DIR + SETTINGS_FILENAME) if os.path.isfile(path): config.read(CONFIG_DIR + SETTINGS_FILENAME) return config raise Exception("Conf file not found in path: %s"% path)
def __call__(self, json_file = None): config = ConfigParser.RawConfigParser() # Checks if the settings settings file already exists if os.path.isfile(os.path.join(__root__.path(), CONFIG_DIR + SETTINGS_FILENAME)): config.read(CONFIG_DIR + SETTINGS_FILENAME) return config # Reads the EC2 User Data file user_data = self.fetch_ec2_user_data(json_file) # Checks if file contains the needed information system_specs = self.parse_user_data(user_data) # Returns settings according to system specs return self.retrieve_constants(system_specs)
def __call__(self, json_file=None): config = ConfigParser.RawConfigParser() # Checks if the settings settings file already exists if os.path.isfile( os.path.join(__root__.path(), CONFIG_DIR + SETTINGS_FILENAME)): config.read(CONFIG_DIR + SETTINGS_FILENAME) return config # Reads the EC2 User Data file user_data = self.fetch_ec2_user_data(json_file) # Checks if file contains the needed information system_specs = self.parse_user_data(user_data) # Returns settings according to system specs return self.retrieve_constants(system_specs)
import os import yaml import __root__ with open(os.path.join(__root__.path(), 'credentials.yml'), 'r') as stream: creds = yaml.load(stream) api_key = creds['api'] mongo_creds = creds['mongo']
import pygame from enum import Enum import logging import __root__ import os # from .settings import Settings # from .states import StateValue logger = logging.getLogger("MAIN") default_name = "RPG" root_dir = __root__.path() # active_screen: list = [] class Background(pygame.sprite.Sprite): def __init__(self, image_file: str = "", location: list = (0, 0)): pygame.sprite.Sprite.__init__(self) # call Sprite initializer self.image = pygame.image.load(image_file) self.rect = self.image.get_rect() self.rect.left, self.rect.top = location print('sss', self) pygame.display.flip() class UpdateSetting(Enum): BG_IMAGE: str = "BG_IMAGE" SCREEN_WIDTH: str = "SCREEN_WIDTH" class Screen:
""" To read the configurations """ import os import __root__ from Config import configreader from Scripts.Utils.Log.logger import Logger config_file = os.path.join(__root__.path() + '/Config/service.yml') config = configreader.read_configuration(config_file) logger = Logger(config).log_obj
import os import __root__ from Config import configreader from Utility.Log.logger import Logger # Reading the configuration config_file = os.path.join(__root__.path(), "./Config/service.yml") config = configreader.read_configuration(config_file) logger = Logger(config).log_obj
def run(self): import __root__ """ Use this function to run build, train, and test your neural network. """ trained = self.importWeights(__root__.path()+'/res/weights') # self.test(trained) # return import matplotlib.pyplot as plt value = 150 plt.figure(1) plt.title("["+str(value)+",50"+",x,"+"y"+"]") for i in range(50,500, 5): print i for j in range(50, 500, 5): color = 'black' if np.around(trained.activate([value,50,i,j]))[0] == np.float32(1.0): color = 'red' else: color = 'blue' x = i y = j plt.scatter(x,y,c=color,s = 20, label = color, alpha=0.9, edgecolor = 'none') plt.grid(True) plt.figure(2) plt.title("["+str(value)+",100"+",x,"+"y"+"]") for i in range(50,500, 5): print i for j in range(50, 500, 5): color = 'black' if np.around(trained.activate([value,100,i,j]))[0] == np.float32(1.0): color = 'red' else: color = 'blue' x = i y = j plt.scatter(x,y,c=color,s = 20, label = color, alpha=0.9, edgecolor = 'none') plt.grid(True) plt.figure(3) plt.title("["+str(value)+",150"+",x,"+"y"+"]") for i in range(50,500, 5): print i for j in range(50, 500, 5): color = 'black' if np.around(trained.activate([value,150,i,j]))[0] == np.float32(1.0): color = 'red' else: color = 'blue' x = i y = j plt.scatter(x,y,c=color,s = 20, label = color, alpha=0.9, edgecolor = 'none') plt.grid(True) plt.show()
""" Configuration variables """ import configparser import __root__ # Root path root_path = __root__.path() # Properties file CONFIGURATION_FILE = "application_conf/settings.conf" ENV_CONF_FILE = "conf/settings.conf" # Config file parser parser = configparser.RawConfigParser(allow_no_value=True) parser.read([CONFIGURATION_FILE, ENV_CONF_FILE]) # Service host service_host = parser.get("SERVICE", "service_host") # Service port number service_port = int(parser.get("SERVICE", "service_port")) mongo_uri = parser.get("MONGO", "mongo_uri") mongo_username = parser.get("MONGO", "mongo_username") mongo_password = parser.get("MONGO", "mongo_password") mongo_port = int(parser.get("MONGO", "mongo_port")) mongo_host = parser.get("MONGO", "mongo_host")
# Response keys success_key = "success" failure_key = "failed" import os import __root__ from bin.common import AppConfigurations CONFIGURATION_FILE = os.path.join(__root__.path(), "conf\\application.conf") # Methods GET = "GET" POST = "POST" # Error message constants method_not_supported = "Method not supported!" NOT_PRESENT_ERROR_MSG = " not present in input json" exception_message = '{"status":True, "status_message":"Server error, please contact your administrator"}' method_error_message = '{"status": True, "message": "Method not supported!"}' success_status = {"status": "success", "result": "Data received successfully"} def result_success_template(data, status="success"): return {"status": status, "result": data} def result_error_template(message=None, error_type="application"): if message: return {"status": "error", "type": error_type, "result": message} else: return { "status": "error",
import os import __root__ from Configuration import configreader from Scripts.Utility.Log.logger import Logger # Read the configurations config_file = os.path.join(__root__.path(), "Configuration", "service.yml") configuration = configreader.read_configuration( config_file) # parse the 'service.yml' file logger = Logger(configuration).log_obj
def getWorkingDirectory(): return __root__.path()
""" Configuration variables """ import json import configparser import os import __root__ import urllib.parse api_service_url = "/bApp/services" # Properties file CONFIGURATION_FILE = os.path.join(__root__.path() + "/config/settings.conf") # Config file parser parser = configparser.RawConfigParser() parser.read(CONFIGURATION_FILE) # Service host service_host = parser.get("SERVICE", "service_host") # Service port number service_port = int(parser.get("SERVICE", "service_port")) # Database properties MONGO_HOST = "mongodb+srv://bapp:" + urllib.parse.quote( "bapp123") + "@cluster0-hoio7.mongodb.net/test?retryWrites=true&w=majority" MONGO_DATABASE = parser.get('DATABASE', 'database_name') DATABASE_USER = parser.get('DATABASE', 'database_user')
from sklearn.metrics import classification_report from sklearn.metrics import confusion_matrix from sklearn.metrics import precision_score from sklearn.metrics import recall_score from sklearn.naive_bayes import GaussianNB from sklearn.neighbors import KNeighborsClassifier from sklearn.preprocessing import StandardScaler from sklearn.tree import DecisionTreeClassifier from sklearn.utils import shuffle import __root__ plt.style.use('ggplot') # %matplotlib inline PROJECT_ROOT = __root__.path() with warnings.catch_warnings(): warnings.simplefilter("ignore") class Data: def __init__(self): self.X_train = None self.y_train = None self.X_test = None self.y_test = None self.labels = None def load_data(self, train_rows=None, test_rows=None, shfl=False, scl=True): data_folder = os.path.join(PROJECT_ROOT, "data")