def init_config():
    config_obj = config.Config()
    [
        setattr(config_obj, variable, getattr(config, variable, ''))
        for variable in dir(config) if not variable.startswith("__")
    ]
    return config_obj
Ejemplo n.º 2
0
 def __init__(self):
     self.tmdb = movieinfo.TMDB()
     self.config = config.Config()
     self.metadata = library.Metadata()
     self.predb = predb.PreDB()
     self.searcher = searcher.Searcher()
     self.score = searchresults.Score()
     self.snatcher = snatcher.Snatcher()
     self.version = version.Version()
Ejemplo n.º 3
0
 def __init__(self):
     self.omdb = Omdb()
     self.config = config.Config()
     self.predb = predb.PreDB()
     self.searcher = searcher.Searcher()
     self.sql = sqldb.SQL()
     self.poster = poster.Poster()
     self.snatcher = snatcher.Snatcher()
     self.update = updatestatus.Status()
Ejemplo n.º 4
0
 def __init__(self):
     self.itunes = ITunes()
     self.config = config.Config()
     self.library = library.ImportDirectory()
     self.predb = predb.PreDB()
     self.plugins = plugins.Plugins()
     self.searcher = searcher.Searcher()
     self.score = scoreresults.ScoreResults()
     self.sql = sqldb.SQL()
     self.musicinfo = musicinfo.ITunes()
     self.snatcher = snatcher.Snatcher()
     self.update = updatestatus.Status()
Ejemplo n.º 5
0
 def __init__(self):
     self.tmdb = TMDB()
     self.config = config.Config()
     self.library = library.ImportDirectory()
     self.predb = predb.PreDB()
     self.plugins = plugins.Plugins()
     self.searcher = searcher.Searcher()
     self.score = scoreresults.ScoreResults()
     self.sql = sqldb.SQL()
     self.poster = poster.Poster()
     self.snatcher = snatcher.Snatcher()
     self.update = updatestatus.Status()
Ejemplo n.º 6
0
    def __init__(self):
        # basic variables
        self.start_time = time.time()
        self.running = True
        self.do_restart = False

        # stores all queued messages from all connections
        self.queued_messages = queue.Queue()
        # format: [{
        #   "conn": BotConnection, "raw": str, "prefix": str, "command": str, "params": str, "nick": str,
        #   "user": str, "host": str, "mask": str, "paramlist": list[str], "lastparam": str
        # }]

        # stores each bot server connection
        self.connections = []

        # set up logging
        self.logger = get_logger()
        self.logger.debug("Logging system initialised.")

        # declare and create data folder
        self.data_dir = os.path.abspath('data')
        if not os.path.exists(self.data_dir):
            self.logger.debug("Data folder not found, creating.")
            os.mkdir(self.data_dir)

        # set up config
        self.config = config.Config(self)
        self.logger.debug("Config system initialised.")

        # setup db
        db_path = self.config.get('database', 'sqlite:///cloudbot.db')
        self.db_engine = create_engine(db_path)
        self.db_factory = sessionmaker(bind=self.db_engine)
        self.db_session = scoped_session(self.db_factory)
        self.db_metadata = MetaData()
        # set botvars.metadata so plugins can access when loading
        botvars.metadata = self.db_metadata
        self.logger.debug("Database system initialised.")

        # Bot initialisation complete
        self.logger.debug("Bot setup completed.")

        self.threads = {}

        # create bot connections
        self.create_connections()

        # run plugin loader
        self.plugin_manager = PluginManager(self)

        self.loader = PluginLoader(self)
Ejemplo n.º 7
0
 def __init__(self):
     self.tmdb = TMDB()
     self.config = config.Config()
     self.metadata = library.Metadata()
     self.predb = predb.PreDB()
     self.plugins = plugins.Plugins()
     self.searcher = searcher.Searcher()
     self.score = searchresults.Score()
     self.sql = sqldb.SQL()
     self.library = library
     self.poster = poster.Poster()
     self.snatcher = snatcher.Snatcher()
     self.update = library.Status()
Ejemplo n.º 8
0
def main():
    args = docopt.docopt(__doc__, version='Jenkins Helper 1.0')
    # print(args)
    cfg = config.Config()
    cfg.root_dir = ROOT_DIR
    if not cfg.load("./config.json"):
        exit(1)

    cmd = command_factory.create(args)
    if cmd:
        cmd.process_args(cfg, args)
        cmd.do_command()
    else:
        print('command not found.')
Ejemplo n.º 9
0
    def setup(self):
        """create the logger and config objects"""
        # logging
        self.logger = get_logger()
        self.logger.debug("Logging engine started.")

        # data folder
        self.data_dir = os.path.abspath('persist')
        if not os.path.exists(self.data_dir):
            self.logger.debug("Data folder not found, creating.")
            os.mkdir(self.data_dir)
            self.logger.debug("Created data folder.")

        # config
        self.config = config.Config(self.logger)
        self.logger.debug("Config object created.")
Ejemplo n.º 10
0
    def __init__(self):
        self.api = None
        self.module = None
        self.module_name = None
        self.final_url = None
        self.port = None
        self.enable_2fa = None
        self.seen = set()
        self.verbose = False
        self.hostname = None

        #app = Flask(
        #__name__,
        #static_url_path='/modules/{}/templates/'.format(self.module_name)
        #)

        self.validate_args()
        self.prepare_storage()
        self.prepare_module()
        self.prepare_api()

        # TODO: Move parameters to a config for sharing
        self.config = config.Config()
Ejemplo n.º 11
0
import string
import datetime
import json
import urllib.request
import urllib.error
import traceback
from core import config, common, database, tags, lastfm, spotify, CONFIG_PATH

# ############################################################################
# 1. Inizializzazione
# ############################################################################

print("* initialization...")

# configuration intialization
cfg = config.Config(CONFIG_PATH)

# drop old db
common.delete(cfg.getDb())

# istanza db
db = database.Database(cfg.getDb())
db.open()

# inizializzazione e caricamento schema logico
with open(cfg.getSchema()) as sh:
    ddl = sh.read()
db.executeScript(ddl)

# count operazioni
added, errors = 0, 0
Ejemplo n.º 12
0
    def __init__(self, verbose=False):
        try:
            if args.directory:
                os.chdir(args.directory)
        except:
            pass

        self.config = cfg.Config(verbose=verbose, colored=True)
        self.config.load()
        self.config.fallback = {
            "aliases": {},
            "colored": True,
            "prompt": "<base>┏━━(</base><user>${USER}</user> <base>at</base> <user>${DOMAIN}</user><base>)━[</base><path>${PATH}</path><base>]━[</base><style fg='${green-yellow}'>${REPO}</style><base>]━[</base><style fg='yellow'>${TIME}</style><base>]\n┗━</base><pointer>${ROOT}</pointer> ",
            "style": {
                # Default style
                "": "",

                # Specific style
                "base": "#1a8cff",
                "pointer": "#ff4500",
                "path": "aqua",
                "user": "******",

                # Completer
                "completion-menu.completion": "bg:#000000 #ffffff",
                "completion-menu.completion.current": "bg:#00aaaa #000000",
                "scrollbar.background": "bg:#88aaaa",
                "scrollbar.button": "bg:#222222"
            },
            "dialog_style": {
                "dialog": "bg:#88ff88",
                "dialog frame-label": "bg:#ffffff #000000",
                "dialog.body": "bg:#000000 #00ff00",
                "dialog shadow": "bg:#00aa00",
            }
        }
        self.config.colored = self.config["colored"]
        self.style = Style.from_dict(self.config["style"])
        self.dialog_style = Style.from_dict(self.config["dialog_style"])
        self.manager = manager
        self.file = None
        self.mode = None
        self.userInput = None

        if platform.system() == "Windows":
            self.histfile = os.environ["userprofile"] + \
                r"\.voidhistory"  # Rename this
        else:
            # Rename this ... alternative for linux or Unix based systems
            self.histfile = os.path.expanduser("~")+r"/.voidhistory"

        self.history = FileHistory(self.histfile)

        if not args.command:
            function_completer = NestedCompleter.from_nested_dict(
                dict.fromkeys(functions))
            pth_completer = path_completer.PathCompleter(expanduser=True)
            environ_completer = env_completer.EnvCompleter(
                file_filter=filter)
            merged_completers = merge_completers(
                [function_completer, pth_completer, environ_completer])
            self.completer = ThreadedCompleter(merged_completers)
        else:
            self.completer = None

        super().__init__(completer=self.completer,
                         complete_while_typing=False,
                         auto_suggest=AutoSuggestFromHistory(),
                         search_ignore_case=True,
                         refresh_interval=0,
                         color_depth=ColorDepth.TRUE_COLOR,
                         editing_mode=EditingMode.VI,
                         style=self.style,
                         history=self.history)
Ejemplo n.º 13
0
 def __init__(self):
     self.config = config.Config()
     self.tmdb = TMDB()
     self.sql = sqldb.SQL()
     self.ajax = ajax.Ajax()
     return
Ejemplo n.º 14
0
class Tucan:
    """"""
    def __init__(self):
        """"""
        #parse options
        parser = optparse.OptionParser()
        parser.add_option("-w",
                          "--wizard",
                          dest="wizard",
                          help="setup: accounts, services, updates",
                          metavar="TYPE")
        parser.add_option("-d",
                          "--daemon",
                          action="store_true",
                          dest="daemon",
                          default=False,
                          help="no interaction interface (URL)")
        parser.add_option("-c",
                          "--cli",
                          action="store_true",
                          dest="cli",
                          default=False,
                          help="command line interface (URL)")
        parser.add_option("-C",
                          "--clean",
                          action="store_true",
                          dest="clean",
                          default=False,
                          help="remove ~/.tucan")
        parser.add_option("-i",
                          "--input-links",
                          dest="links_file",
                          help="import links from FILE",
                          metavar="FILE")
        parser.add_option("-v",
                          "--verbose",
                          action="store_true",
                          dest="verbose",
                          default=False,
                          help="print log to stdout")
        parser.add_option("-V",
                          "--version",
                          action="store_true",
                          dest="version",
                          default=False,
                          help="print version and exit")
        self.options, self.args = parser.parse_args()

        if self.options.version:
            sys.exit("%s %s" % (cons.TUCAN_NAME, cons.TUCAN_VERSION))

        if self.options.clean:
            try:
                misc.remove_conf_dir()
            except Exception, e:
                sys.exit(e)

        if not os.path.exists(cons.CONFIG_PATH):
            os.mkdir(cons.CONFIG_PATH)

        #check for previous running instance
        self.pid_file = pid_file.PidFile(cons.PID_FILE)
        if self.pid_file.start():
            #config
            shared.configuration = config.Config()
            self.config = shared.configuration
            sys.path.append(cons.PLUGIN_PATH)

            #logging
            if os.path.exists(cons.LOG_FILE):
                if os.path.exists("%s.old" % cons.LOG_FILE):
                    os.remove("%s.old" % cons.LOG_FILE)
                os.rename(cons.LOG_FILE, "%s.old" % cons.LOG_FILE)
            logging.basicConfig(level=logging.DEBUG,
                                format=cons.LOG_FORMAT,
                                filename=cons.LOG_FILE,
                                filemode='w')
            self.logger = logging.getLogger(self.__class__.__name__)
        else:
            if self.options.wizard or self.options.daemon or self.options.cli:
                sys.exit(
                    "Already running or could not open ~/.tucan/tucan.pid")
            else:
                self.start_gui(False)
                sys.exit()
Ejemplo n.º 15
0
#!/bin/env python3
from flask import Flask
from core import config
from core import db
from apis import api

app = Flask(__name__)
app.config.from_object(config.Config())
db.init_app(app)
api.init_app(app)

if __name__ == '__main__':
    app.run(host='0.0.0.0')
Ejemplo n.º 16
0
def compDPK(fn_conf, chem=None, sc_Kw_paras=None, sc_D_paras=None, disp=1, wk_path= '.\\simu\\'):
    """Compute DPK
    Args:
        fn_conf -- the .cfg file, which gives the configuration of the simulation
        chem -- if given, it overrides the values given in fn_conf
        wk_path -- path to save simulation results
    """
    # --------------------------------------------------------------------------------------------------------------
    import os
    import numpy as np
    from importlib import reload
    from core import chemical
    reload(chemical)
    from core import config
    reload(config)
    from core import vehicle
    reload(vehicle)
    from core import viaepd
    reload(viaepd)
    from core import dermis
    reload(dermis)
    from core import skin_setup
    reload(skin_setup)
    from core.saveMass_hobin import saveMass #Can not reload the saveMass since saveMass is not module
    wk_path = os.path.join(os.path.split(os.path.split(fn_conf)[0])[0],wk_path)
    # --------------------------------------------------------------------------------------------------------------
    # Read the .cfg, i.e. configuration, file to set up simulation
    _conf = config.Config(fn_conf)
    if sc_Kw_paras is not None:
        _conf.Kw_sc_paras = sc_Kw_paras
    if sc_D_paras is not None:
        _conf.D_sc_paras = sc_D_paras

        # Setup the chemical
    if chem is not None:
        _chem = chem
    else:
        _chem = chemical.Chemical(_conf)

    # Setup skin and create compartments
    _skin = skin_setup.Skin_Setup(_chem, _conf)
    _skin.createComps(_chem, _conf)

    # Simulation time (in seconds) and steps
    t_start, t_end, Nsteps = [0, 3600 * 24, 145]
    # t_start, t_end, Nsteps = [0, 1800, 181]
    t_range = np.linspace(t_start, t_end, Nsteps)
    # t_range = np.r_[np.linspace(0, 1000, 2), np.linspace(1200, 1800, 21),\
    #                np.linspace(1800, 3600, 21),np.linspace(7200, 3600*24, 23)]
    # Nsteps = len(t_range)

    nComps = _skin.nxComp * _skin.nyComp
    total_mass = np.sum(_skin.compMass_comps())

    # Create directory to save results
    newpath = wk_path
    if not os.path.exists(newpath):
        os.makedirs(newpath)
    fn = wk_path + 'MassFrac.csv'
    saveMass(total_mass, fn, b_1st_time=True)

    for i in range(Nsteps):

        mass = _skin.compMass_comps()
        m_v = _skin.comps[0].getMass_OutEvap()
        m_all = np.insert(mass, 0, m_v) / total_mass

        if disp >= 2:
            np.set_printoptions(precision=2)
            # print('Time = ', t_range[i], '% mass: ', m_all)

        # Create directory to save results
        newpath = wk_path + str(t_range[i])
        if not os.path.exists(newpath):
            os.makedirs(newpath)

        # Save fraction of mass in all compartments
        fn = wk_path + 'MassFrac.csv'
        saveMass(np.insert(m_all, 0, t_range[i]), fn)

        # Save current concentrations
        for j in range(nComps):
            fn = newpath + '/comp' + str(j) + '_' + _conf.comps_geom[j].name
            _skin.comps[j].saveMeshConc(True, fn)

        if i == Nsteps - 1:
            break

        # Simulate
        _skin.solveMoL(t_range[i], t_range[i + 1])

        # return mass
Ejemplo n.º 17
0
    parser.add_argument('-b', '--browser', help='Open browser on launch.',
                        action='store_true')
    parser.add_argument('-c', '--conf', help='Location of config file.',
                        type=str)
    parser.add_argument('-l', '--log',
                        help='Directory in which to create log files.', type=str)
    passed_args = parser.parse_args()

    # Set up conf file
    if passed_args.conf:
        core.CONF_FILE = passed_args.conf
    if passed_args.log:
        core.LOG_DIR = passed_args.log

    # set up config file on first launch
    conf = config.Config()
    if not os.path.isfile(core.CONF_FILE):
        print 'Config file not found. Creating new basic config {}. ' \
            'Please review settings.'.format(core.CONF_FILE)
        conf.new_config()
    else:
        print 'Config file found, merging any new options.'
        conf.merge_new_options()
    conf.stash()

    # Set up logging
    if passed_args.log:
        core.LOG_DIR = passed_args.log
    log.start(core.LOG_DIR)
    logging = logging.getLogger(__name__)
    cherrypy.log.error_log.propagate = True
Ejemplo n.º 18
0
import re
import subprocess
import tensorflow as tf
import numpy as np
import os
import core.loader as ld
import core.trainer as tn
import core.network as nw
import core.config as cf
import core.evaluator as ev
from LaTeXTools.LATEXwriter import LATEXwriter as TeXwriter
import lime.lime_text
import lime.lime_tabular
from multiprocessing import Process

cf = cf.Config()


def launchTensorBoard(path):
    import os
    os.system(
        "bash -c \"source /home/chambroc/miniconda3/bin/activate bob && tensorboard --logdir="
        + path + "\"")
    return


os.mkdir(cf.tb_dir)
os.mkdir(cf.tb_dir + "/train")
os.mkdir(cf.tb_dir + "/test")
os.mkdir(cf.tb_dir + "/lime")
os.mkdir(cf.tb_dir + "/log")