def setUp(self): """initialize class cluster and composites""" # cluster cl_inifile = "/home/sonja/Documents/Clustering-Forecast/ini/clusters_America_prec_t_test.ini" cl_output_path = "/home/sonja/Documents/Clustering-Forecast/tests/" cl_output_label = "TEST" cl_config = Config("Test.log") self.predictand = Predictand(cl_inifile, cl_output_path, cl_output_label, cl_config.config_dict) # composite co_inifile = "/home/sonja/Documents/Clustering-Forecast/ini/composites_America_PSL.ini" co_output_path = "/home/sonja/Documents/Clustering-Forecast/tests/" co_output_label = "TEST" co_config = Config("Test.log") self.precursors = Precursors(co_inifile, co_output_path, co_output_label, co_config.config_dict) # set cluster method parameters self.method_name = "ward" self.k = 2 self.predictand_var = "prec_t" # initialize Forecast class self.forecast_nn = ForecastNN(cl_inifile, cl_config.config_dict, self.k, self.method_name) self.initialize_data()
class GetStatus: def __init__(self): self.response = None self.token = None self.config = Config() self.header = self.__header() def __token(self): w = Token() return w.getToken() def __header(self): auth_token = self.__token() header = { 'Content-type': 'application/json', 'Authorization': 'Bearer ' + auth_token } return header def getResponse(self): dict_json = self.response if dict_json is not None: lstContatos = dict_json['Data']['contacts'] lstResponses = [] for values in lstContatos: row = values['input'] + ';' + values['status'] lstResponses.append(str(row)) return lstResponses else: return None def __url(self): return self.config.urlContact() def __proxy(self): return self.config.proxy() def request(self, dict_nu_terminal): try: body = {'contacts': dict_nu_terminal} #print(self.header) #resp = requests.post(self.__url(),proxies=self.__proxy(), json=body, headers=self.header) resp = requests.post(self.__url(), json=body, headers=self.header) if not resp is None: if 'json' in resp.headers.get('Content-Type'): self.response = resp.json() else: print('Response content is not in JSON format.') else: print('Resp is None') except requests.exceptions.HTTPError as errh: print("Http Error:", errh) except requests.exceptions.ConnectionError as errc: print("Error Connecting:", errc) except requests.exceptions.Timeout as errt: print("Timeout Error:", errt) except requests.exceptions.RequestException as err: print("OOps: Something Else", err)
def calcActionDict(cls, screenClass) -> dict: p = pygame ctrl = p.KMOD_LCTRL return { Combo(ctrl, p.K_o): Config.getInstance().readFromFile, Combo(ctrl, p.K_s): Config.getInstance().saveToFile, Combo(ctrl, p.K_t): TextBlock, # HOOOOOOOOOOOOOOOO class is function mazafaka HAAAAAAAAAAA Combo(ctrl, p.K_i): ImageBlock, # HOOOOOOOOOOOOOOOO class is function mazafaka HAAAAAAAAAAA Combo(ctrl, p.K_f): cls.switchFullscreen, Combo(ctrl, p.K_EQUALS): cls.scaleUp, Combo(ctrl, p.K_MINUS): cls.scaleDown, }
def setUp(self): """initialize class composites""" inifile = "/home/sonja/Documents/Clustering-Forecast/ini/composites_America_PSL.ini" output_path = "/home/sonja/Documents/Clustering-Forecast/tests/" output_label = "TEST" cl_config = Config("Test.log") self.composites = Composites(inifile, output_path, output_label, cl_config.config_dict)
class Token: def __init__(self): self.token = None self.config = Config() self.response = None def __url(self): return self.config.urlToken() def __proxy(self): return self.config.proxy() def __body(self): return {'user': self.config.user(), 'password': self.config.passwd()} def __request(self): try: header = header = {'Content-type': 'application/json'} #resp = requests.post(self.__url(),proxies=self.__proxy(), json=self.__body(), headers=header) resp = requests.post(self.__url(), json=self.__body(), headers=header) self.response = resp.json() #print(resp.json()) except requests.exceptions.HTTPError as errh: print("Http Error:", errh) except requests.exceptions.ConnectionError as errc: print("Error Connecting:", errc) except requests.exceptions.Timeout as errt: print("Timeout Error:", errt) except requests.exceptions.RequestException as err: print("OOps: Something Else", err) def getToken(self): self.__request() dict_json = self.response if dict_json is not None: #print(str(dict_json)) code = dict_json['Code'] description = dict_json['Description'] if code == 808: token = dict_json['Data']['token'] return token else: return description else: return None
def setUp(self): """initialize class cluster""" inifile = "/home/sonja/Documents/Clustering-Forecast/ini/clusters_America_prec_t.ini" output_path = "/home/sonja/Documents/Clustering-Forecast/tests/" output_label = "TEST" cl_config = Config("Test.log") self.clusters = Clusters(inifile, output_path, output_label, cl_config.config_dict) self.initialize_data()
def post_config(): Config.save_config({ 'host': request.form['host'], 'port': int(request.form['port']), 'user': request.form['user'], 'password': request.form['password'] }) blk = DI.get_blockchain() if blk.check(): result = 'Connection OK =)' else: result = 'FAILED' return render_template('config.html', nav='config', title='Config', result=result, data=request.form)
def cli(file, logfile): """Initialise program with given parameters.""" global df, config # Set up logging logging.basicConfig(filename=logfile, level=logging.INFO, format="%(asctime)s - %(levelname)s: %(message)s") # Make sure we have an API key for FMI's open data service config = Config("~/.fillaridata", "main.conf") api_key = config.value("FMI", "api_key") if api_key is None: click.echo("API key for FMI's open data service was not found. " "Without one, fetching new data will fail. Your API key " "will be saved in '{}'.".format(config.path)) new_key = click.prompt("Please enter your API key", type=str) config.set("FMI", "api_key", new_key) # Load the datafile df = Datafile(file)
for i in range(length_files): images_wrap[i] = import_hdf5(list_of_files_wrap[i]) images_true_2d = import_hdf5(list_of_files_true[i]) # convert 2d array in 3d array with classes k_offset = np.amin(images_true_2d) for x in range(n_xy): for y in range(n_xy): images_true[i, x, y, k_offset + images_true_2d[x, y]] = 1 images_wrap = np.expand_dims(images_wrap, axis=3) # X_train, X_test, y_train, y_test = train_test_split(images_wrap, images_true, test_size=0.33, random_state=0) logger.info("Initialize model...") # unwrapping_model = UnwrappingModel(X_train,y_train) unwrapping_model = DeepLabV3(X_train, y_train, X_test, y_test) if __name__ == '__main__': import logging.config parser = ClusteringParser() config = Config('logfile.log') logger = logging.getLogger(__name__) # read config log file from classes.Config logging.config.dictConfig(config.config_dict) logger.info("Start unwrapping program") main(parser, config.config_dict)
def main(cl_parser: ClusteringParser, cl_config: dict): # variables var = cl_parser.arguments['predictand'] output_label = cl_parser.arguments['outputlabel'] inifile = cl_parser.arguments['inifile'] output_path = cl_parser.arguments['outputpath'] pred_clusters = Clusters(inifile, output_path, output_label, cl_config) # pred_clusters = Clusters(f"ini/clusters_America_TS.ini") method_name = 'ward' # ~ for k in [3, 4, 5, 6, 7, 8, 9]: for k in [5]: pred_clusters.calculate_clusters(method_name, k) pred_clusters.plot_clusters_and_time_series() pred_clusters.plot_elbow_plot() pred_clusters.plot_fancy_dendrogram() pred_clusters.save_clusters() # pred_clusters.plot_years() if __name__ == '__main__': import logging.config parser = ClusteringParser() config = Config(parser.arguments['logfile']) logger = logging.getLogger(__name__) # read config log file from classes.Config logging.config.dictConfig(config.config_dict) logger.info("Start clustering program") main(parser, config.config_dict)
#!/usr/bin/env python # -*- coding: utf-8 -*- from classes.Config import Config from classes.Drawable.Screen.Screen import Screen from classes.TimerHandler import TimerHandler Config.getInstance() eventHandler = Screen.getInstance().makeHandler() timerHandler = TimerHandler(eventHandler) while True: timerHandler.handleFrame()
def show_config(): data = Config.get_config() return render_template('config.html', nav='config', title='Config', data=data)
import sys import argparse sys.path.append(os.path.join(os.path.dirname(__file__), '..')) from classes.Log import Log from classes.Config import Config from classes.WebServices import WebServices # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-chrono", "--chrono", required=True, help="path to file") ap.add_argument("-c", "--config", required=True, help="path to config.xml") args = vars(ap.parse_args()) if __name__ == '__main__': # Init all the var config = Config() config.load_file(args['config']) Log = Log(config.cfg['GLOBAL']['logfile']) WebService = WebServices(config.cfg['OCForMaarch']['host'], config.cfg['OCForMaarch']['user'], config.cfg['OCForMaarch']['password'], Log, config.cfg['GLOBAL']['timeout']) chrono = args['chrono'] response = WebService.check_attachment(chrono) if response: print(response['result']) else: print('KO')
def __init__(self): self.response = None self.token = None self.config = Config() self.header = self.__header()
def get_blockchain(): conf = Config.get_config() return BlockchainEmercoin(conf['host'], conf['port'], conf['user'], conf['password'])
# -*- coding: utf-8 -*- import os import inspect import importlib from OpenSSL import SSL from flask import Flask from flask_restful import Api from classes.Utils import Utils from classes.Config import Config ROOT = os.path.dirname( os.path.abspath( inspect.getfile(inspect.currentframe() ))) config = Config(ROOT, "/config/config.json") endpoints = None app = Flask(__name__) api = Api(app) try: endpoints = Utils.read_json(ROOT + "/config/endpoints.json") except Exception, ex: raise Exception('failed to load endpoints configuration: %s' %\ str(ex)) for endpoint in endpoints: ep_name = endpoint.keys()[0] ep_cname = endpoint[ep_name] ep_mod = importlib.import_module("classes." +\ ep_cname)
str(ex), self.id, self.job.get('id'), scenario.get('name')) raise Exception(msg) # ----------------------------------------------------------------------------- # This is just to: # a) be able to easily test the worker # b) be able to run a fuzzing job from the command line # ----------------------------------------------------------------------------- ROOT = os.path.dirname( os.path.abspath( inspect.getfile(inspect.currentframe() ))) config = Config(ROOT, "/../config/config.json") logger = Logger() if len(sys.argv) != 2: print "Usage: %s <job descriptor>" % sys.argv[0] sys.exit(1) w = Worker( logger, config, Utils.generate_name(), sys.argv[1]) w.start()
def __init__(self): self.token = None self.config = Config() self.response = None