def __init__(self, scraper_configuration, local_machine): "scraper_configuration은 static, local_machine은 dynamic 성격을 가짐." self.__file_scraper_configuration = scraper_configuration self.__manager_scraper_configuration = ConfigManager( self.__file_scraper_configuration) self.__file_local_machine = local_machine self.__manager_local_machine = ConfigManager(self.__file_local_machine)
def __init__(self, site, category, scraper_configuration, local_machine): "scraper_configuration은 static, local_machine은 dynamic 성격을 가짐." self.__site = site self.__category = category self.__file_scraper_configuration = scraper_configuration self.__manager_scraper_configuration = ConfigManager(self.__file_scraper_configuration) self.__file_local_machine = local_machine self.__manager_local_machine = ConfigManager(self.__file_local_machine) self.__url = self.get_base_url() + self.get_config_scraper('url')
def __init__(self): super(SocketServer, self).__init__() self.config_manager = ConfigManager() self.sock_connection = socket(AF_INET, SOCK_STREAM) self.sock_connection.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.__start__()
def __init__(self, site, scraper_configuration, local_machine): "scraper_configuration은 static, local_machine은 dynamic 성격을 가짐." self.__site = site self.__file_scraper_configuration = scraper_configuration self.__manager_scraper_configuration = ConfigManager(self.__file_scraper_configuration) self.__file_local_machine = local_machine self.__manager_local_machine = ConfigManager(self.__file_local_machine) self.__url_updated = None self.__url = self.get_base_url()
def __init__(self): super(SocketClientTCP, self).__init__() self.config_manager = ConfigManager() self.sock = socket(AF_INET, SOCK_STREAM) self.sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.__connect__()
class SocketClientTCP: def __init__(self): super(SocketClientTCP, self).__init__() self.config_manager = ConfigManager() self.sock = socket(AF_INET, SOCK_STREAM) self.sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.__connect__() def __connect__(self): """ this function try connection to server :param: :return: """ print(Colors.FORE_YELLOW + "[+] try connection to ChatApp server ...") response_code = self.sock.connect_ex(( self.config_manager.get().socket_server.IP, self.config_manager.get().socket_server.PORT, )) if response_code == 0: CommandHandler(client_socket=self.sock).start() elif response_code == 111: print(Colors.FORE_GREEN + "[-] ChatApp server not respod, maybe it is down...")
def __init__(self, parent=None): super(SocketServer, self).__init__(parent=parent) self.socket_server = socket(AF_INET, SOCK_STREAM) self.socket_server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.config_manager = ConfigManager()
class SocketServer: """ This class creates socket stream on TCP protocol """ def __init__(self): super(SocketServer, self).__init__() self.config_manager = ConfigManager() self.sock_connection = socket(AF_INET, SOCK_STREAM) self.sock_connection.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) self.__start__() def __start__(self): """ This method creates socket connection :params: :return: """ self.sock_connection.bind(( self.config_manager.get().socket_server.IP, # TODO: change get() => property self.config_manager.get().socket_server.PORT )) self.sock_connection.listen( self.config_manager.get().socket_server.LISTEN_CLIENT ) print(str(datetime.now()).split('.')[0] + " => [+] Server is ready to listening") def run(self): """ start server for listening clients :params: :return: """ client, client_address = self.sock_connection.accept() # we create new thread per client that connect to server ClientHandler( client, client_address ).start() self.run()
def __init__(self, model_name, action_space, reward_range, state_height, state_width): self.model_name = model_name self.action_space = action_space self.reward_range = reward_range self.state_height = state_height self.state_width = state_width self.model_config = ConfigManager('models_config.json').get( self.model_name)
class ScraperConfig(): def __init__(self, site, scraper_configuration, local_machine): "scraper_configuration은 static, local_machine은 dynamic 성격을 가짐." self.__site = site self.__file_scraper_configuration = scraper_configuration self.__manager_scraper_configuration = ConfigManager( self.__file_scraper_configuration) self.__file_local_machine = local_machine self.__manager_local_machine = ConfigManager(self.__file_local_machine) self.__url = self.get_base_url() def get_base_url(self): return self.get_config_scraper('url') def get_url(self): return self.__url def get_site(self): return self.__site def get_config_local(self, attr): attr = "%s-%s" % (self.__site, attr) return self.__manager_local_machine.get_attr_config(attr) def set_config_local(self, attr, value): attr = "%s-%s" % (self.__site, attr) self.__manager_local_machine.set_attr_config(attr, value) def get_config_scraper(self, attr): attr = "%s-%s" % (self.__site, attr) return self.__manager_scraper_configuration.get_attr_config(attr) def set_config_scraper(self, attr, value): attr = "%s-%s" % (self.__site, attr) self.__manager_scraper_configuration.set_attr_config(attr, value)
class ScraperConfig(): def __init__(self, site, scraper_configuration, local_machine): "scraper_configuration은 static, local_machine은 dynamic 성격을 가짐." self.__site = site self.__file_scraper_configuration = scraper_configuration self.__manager_scraper_configuration = ConfigManager(self.__file_scraper_configuration) self.__file_local_machine = local_machine self.__manager_local_machine = ConfigManager(self.__file_local_machine) self.__url_updated = None self.__url = self.get_base_url() def get_base_url(self): if self.__url_updated is None: ret = self.get_config_scraper('url') else: ret = self.__url_updated return ret def set_base_url(self, base_url): ''' 이것은 임시 설정임. persistent data가 아님 url 숫자 올라갔을때, 임시로 변경하기 위한 설정. ''' self.__url_updated = base_url self.__url = self.get_base_url() def get_url(self): return self.__url def get_site(self): return self.__site def get_config_local(self, attr): attr = "%s-%s" % (self.__site, attr) return self.__manager_local_machine.get_attr_config(attr) def set_config_local(self, attr, value): attr = "%s-%s" % (self.__site, attr) self.__manager_local_machine.set_attr_config(attr, value) def get_config_scraper(self, attr): attr = "%s-%s" % (self.__site, attr) return self.__manager_scraper_configuration.get_attr_config(attr) def set_config_scraper(self, attr, value): attr = "%s-%s" % (self.__site, attr) self.__manager_scraper_configuration.set_attr_config(attr, value)
class SystemConfig(): def __init__(self, scraper_configuration, local_machine): "scraper_configuration은 static, local_machine은 dynamic 성격을 가짐." self.__file_scraper_configuration = scraper_configuration self.__manager_scraper_configuration = ConfigManager( self.__file_scraper_configuration) self.__file_local_machine = local_machine self.__manager_local_machine = ConfigManager(self.__file_local_machine) def get_config_local(self, attr): return self.__manager_local_machine.get_attr_config(attr) def set_config_local(self, attr, value): self.__manager_local_machine.set_attr_config(attr, value) def get_config_scraper(self, attr): return self.__manager_scraper_configuration.get_attr_config(attr) def set_config_scraper(self, attr, value): self.__manager_scraper_configuration.set_attr_config(attr, value)
import logging from discord.ext import commands from utils.config_manager import ConfigManager # Init logger. logger = logging.getLogger('CoreDump') # Load config manager. cm = ConfigManager() class UtilityCommands(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command(name='clean') @commands.has_role(cm.get_admin_role()) async def _cmd_clean(self, ctx, qty: int): if not qty or qty <= 0: raise commands.BadArgument with ctx.channel.typing(): msgs = await ctx.channel.history(limit=qty).flatten() await ctx.channel.delete_messages(msgs) await ctx.send( "**LIMPIEZA >>** ¡Has borrado {} mensajes correctamente! {}". format(len(msgs), ctx.author.mention))
""" wp_img_post.py -ImagePost class will post the image to the wordpress and return then post number. """ from utils.config_manager import ConfigManager config_obj = ConfigManager.get_instance() config = config_obj.dataMap from .auth import BasicAuth import urllib.request import json import os import requests import base64 class ImagePost(object): def __init__(self): self.mediaurl = config['wp_mediaurl'] self.reqsesion = requests.session() self.basic_auth = BasicAuth.auth def is_downloadable(self, imgurl): """ Does the url contain a downloadable resource """ h = requests.head(imgurl, allow_redirects=True) header = h.headers content_type = header.get('content-type') if 'text' in content_type.lower(): return None if 'html' in content_type.lower():
False), 'Choose one gap filling mode.' weighted = not args.best binary = args.binary fill_gaps = args.fill_mode_max or args.fill_mode_next fix_jumps = args.fix_jumps fill_mode = f"{f'max' * args.fill_mode_max}{f'next' * args.fill_mode_next}" filling_tag = f"{f'(max)' * args.fill_mode_max}{f'(next)' * args.fill_mode_next}" tag_description = ''.join([ f'{"_weighted" * weighted}{"_best" * (not weighted)}', f'{"_binary" * binary}', f'{"_filled" * fill_gaps}{filling_tag}', f'{"_fix_jumps" * fix_jumps}' ]) writer_tag = f'DurationExtraction{tag_description}' print(writer_tag) config_manager = ConfigManager(config_path=args.config, model_kind='autoregressive', session_name=args.session_name) config = config_manager.config meldir = config_manager.train_datadir / 'mels' target_dir = config_manager.train_datadir / f'forward_data' train_target_dir = target_dir / 'train' val_target_dir = target_dir / 'val' train_predictions_dir = target_dir / f'train_predictions_{config_manager.session_name}' val_predictions_dir = target_dir / f'val_predictions_{config_manager.session_name}' target_dir.mkdir(exist_ok=True) train_target_dir.mkdir(exist_ok=True) val_target_dir.mkdir(exist_ok=True) train_predictions_dir.mkdir(exist_ok=True) val_predictions_dir.mkdir(exist_ok=True) config_manager.dump_config()
parser.add_argument('--reset_dir', dest='clear_dir', action='store_true', help="deletes everything under this config's folder.") parser.add_argument('--reset_logs', dest='clear_logs', action='store_true', help="deletes logs under this config's folder.") parser.add_argument('--reset_weights', dest='clear_weights', action='store_true', help="deletes weights under this config's folder.") parser.add_argument('--session_name', dest='session_name', default=None) args = parser.parse_args() config_manager = ConfigManager(config_path=args.config, model_kind='autoregressive', session_name=args.session_name) config = config_manager.config config_manager.create_remove_dirs(clear_dir=args.clear_dir, clear_logs=args.clear_logs, clear_weights=args.clear_weights) config_manager.dump_config() config_manager.print_config() train_samples, _ = load_files( metafile=str(config_manager.train_datadir / 'train_metafile.txt'), meldir=str(config_manager.train_datadir / 'mels'), num_samples=config['n_samples']) # (phonemes, mel) val_samples, _ = load_files( metafile=str(config_manager.train_datadir / 'test_metafile.txt'), meldir=str(config_manager.train_datadir / 'mels'),
from utils.config_manager import ConfigManager from persistence.db import MongoDBPersistenceManager from model.odm import ODMModel from model import Building from utils.logger import Logger from analysis import DXFAnalysis from analysis import FloorMergeAnalysis from analysis import BuildingIdAnalysis persistence = MongoDBPersistenceManager(ConfigManager("config/general.json")) ODMModel.set_pm( persistence ) def data_and_percent(value, total, num_padding = 3,): if(total > 0): return ("{:0>"+str(num_padding)+"} ({:>0.1f}%)").format(value, value/total*100.0) else: return ("{:0>"+str(num_padding)+"} ").format(value) class GeneralReport: merge_tuples = [ ("edilizia", "dxf"), ("edilizia", "easyroom"), ("easyroom", "dxf"), ("easyroom", "edilizia") ] @classmethod def report_building(klass, building): BuildingIdAnalysis.analyse_building_id(building)
import os import logging.config import ast from utils.config_manager import ConfigManager APP_NAME = "notifyme" APP_CHARSET = 'UTF-8' # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Config file paths CONFIGURATION_JSON_FILE = './config.json' CONFIGURATION_JOSN_FILE_DEV = './config_development.json' config = ConfigManager(CONFIGURATION_JSON_FILE, CONFIGURATION_JOSN_FILE_DEV) LOG_ROOT_PATH = config.load('LOG_ROOT_PATH', 'logging', 'root_path') RABBITMQ_SERVER = config.load('RABBITMQ_SERVER', 'bus', 'host') RABBITMQ_USER = config.load('RABBITMQ_USER', 'bus', 'user') RABBITMQ_PASSWORD = config.load('RABBITMQ_PASSWORD', 'bus', 'password') RABBITMQ_QUEUE = config.load('RABBITMQ_QUEUE', 'bus', 'queue_name') RABBIRMQ_EXCHANGE_ERROR = config.load('RABBIRMQ_EXCHANGE_ERROR', 'bus', 'error_exchange') SMTP_EMAIL = config.load('SMTP_EMAIL', 'smtp', 'email') SMTP_HOST = config.load('SMTP_HOST', 'smtp', 'server') SMTP_PORT = config.load('SMTP_PORT', 'smtp', 'port') SMTP_FROM_NAME = config.load('SMTP_FROM_NAME', 'smtp', 'name') SMTP_PASS = config.load('SMTP_PASS', 'smtp', 'password') SEND_EMAILS = config.load('SMTP_SEND', 'smtp', 'name')