Example #1
0
def init():
    """
    Initialization of different component for application to run.

    It can consist of db/logging/networ, etc initilization.
    """
    logger.initialize()  # initializing logging
Example #2
0
def main():
    import os.path

    # init setting
    from utils import setting, num
    with open(os.path.join(os.path.dirname(__file__), "conf.yaml")) as _f:
        setting.load(_f)

    # init logger
    from utils import logger
    logger.initialize()

    # pid file
    with open(
            os.path.join(
                os.path.dirname(__file__),
                setting.conf.get("system").get("project_name") + ".pid"),
            'w') as pid:
        pid.write(str(os.getpid()))

    conf = setting.conf.get("inotiftpsync")
    _Sync(path=conf.get("watch_path"),
          ftp_server=conf.get("ftp_server"),
          ftp_username=conf.get("ftp_username"),
          ftp_password=conf.get("ftp_password"),
          ftp_use_ssl=num.safe_int(conf.get("ftp_use_ssl")) == 1,
          ftp_port=conf.get("ftp_port"),
          ftp_root=conf.get("ftp_root")).start()
Example #3
0
def initialize(appName=None):
    """ This method must be called to initialize the settings,
     otherwise the properties will be None.

    @return: Nothing
    """
    global AgentName
    global AgentVersion
    global AgentDescription
    global AgentInstallDate

    global _config
    global ServerAddress
    global ServerHostname
    global ServerIpAddress
    global ServerPort
    global AgentPort
    global AgentId
    global LogLevel
    global _logger
    global Username
    global Password
    global Customer

    _create_directories()

    _config = ConfigParser.ConfigParser()
    _config.read(_app_config_file)

    ServerPort = int(_config.get(_app_settings_section, 'serverport'))
    AgentPort = int(_config.get(_app_settings_section, 'agentport'))
    LogLevel = _config.get(_app_settings_section, 'loglevel')
    AgentId = _config.get(_app_settings_section, 'agentid')
    Username = _config.get(_app_settings_section, 'nu')
    Password = _config.get(_app_settings_section, 'wp')
    Customer = _config.get(_app_settings_section, 'customer')

    AgentName = _config.get(_agent_info_section, 'name')
    AgentVersion = _config.get(_agent_info_section, 'version')
    AgentDescription = _config.get(_agent_info_section, 'description')
    AgentInstallDate = _config.get(_agent_info_section, 'installdate')

    if not appName:
        appName = 'agent'

    logger.initialize(appName, LogDirectory, LogLevel)

    ServerHostname, ServerIpAddress = _get_server_addresses()

    if ServerHostname != '':
        ServerAddress = ServerHostname
    else:
        ServerAddress = ServerIpAddress
Example #4
0
def initialize(appName=None):
    """ This method must be called to initialize the settings,
     otherwise the properties will be None.

    @return: Nothing
    """
    global AgentName
    global AgentVersion
    global AgentDescription
    global AgentInstallDate

    global _config
    global ServerAddress
    global ServerHostname
    global ServerIpAddress
    global ServerPort
    global AgentPort
    global AgentId
    global LogLevel
    global _logger
    global Username
    global Password
    global Customer

    _create_directories()

    _config = ConfigParser.ConfigParser()
    _config.read(_app_config_file)

    ServerPort = int(_config.get(_app_settings_section, 'serverport'))
    AgentPort = int(_config.get(_app_settings_section, 'agentport'))
    LogLevel = _config.get(_app_settings_section, 'loglevel')
    AgentId = _config.get(_app_settings_section, 'agentid')
    Username = _config.get(_app_settings_section, 'nu')
    Password = _config.get(_app_settings_section, 'wp')
    Customer = _config.get(_app_settings_section, 'customer')

    AgentName = _config.get(_agent_info_section, 'name')
    AgentVersion = _config.get(_agent_info_section, 'version')
    AgentDescription = _config.get(_agent_info_section, 'description')
    AgentInstallDate = _config.get(_agent_info_section, 'installdate')

    if not appName:
        appName = 'agent'

    logger.initialize(appName, LogDirectory, LogLevel)

    ServerHostname, ServerIpAddress = _get_server_addresses()

    if ServerHostname != '':
        ServerAddress = ServerHostname
    else:
        ServerAddress = ServerIpAddress
Example #5
0
def main():
    # parse argument
    ArgumentParser.parse()

    # init setting
    from utils import setting
    with open(ArgumentParser.args['config']) as _f:
        setting.load(_f)

    # init logger
    from utils import logger
    logger.initialize()

    # check config
    if ArgumentParser.args['test']:
        ConfigParser(setting.conf).check()
        logger.info('Test successfully, ' + str(len(setting.conf.get('dns_servers', []))) + ' server(s) found.')
        sys.exit()

    pid_file = os.path.join(os.path.dirname(__file__), setting.conf.get('system').get('project_name') + '.pid')
    with DnsRouter(pid_file):
        # signal
        from utils import system
        if os.name == 'posix':
            system.register_sighandler(DNSServerLoader.stop, 2, 3, 15)
            system.register_sighandler(DNSServerLoader.reload, 10)
        else:
            system.register_sighandler(DNSServerLoader.stop, 2, 15)
        try:
            # start server threads
            DNSServerLoader.daemon()
        except IOError as e:
            import errno
            # skip Interrupted function call in Windows
            if e.errno != errno.EINTR:
                raise
Example #6
0
        if model_answer in KNOWN_TIMEOUT_PS:
            runner.timed_out.append(model_answer)
            runner.timed_out_count += 1
            continue
        print(model_answer)
        synth.set_specs(examples)
        # synth.synthesize(examples, problem['prediction'])
        # runner.solve(synth, examples, problem['prediction'], model_answer)
    # return runner.statistics()
    return dict()


def run(p_size, data_set):
    runner = TimedSolver()
    annotated_problems = get_annotated_problems(p_size, data_set)
    dsl = Dsl()
    return solve_problems(dsl, annotated_problems, runner)


if __name__ == "__main__":
    FLAGS = parse_args()
    logger.logger = logger.initialize()
    if FLAGS.logfile:
        logger.logger = logger.set_logfile(get_log_filename(FLAGS.logfile))
        logger.logger.debug(
            'Starting script python -m run --program-size=%s --data-set=%s --synthesizer=%s'
            % (FLAGS.p_size, FLAGS.set, FLAGS.synthesizer))

    statistics = run(FLAGS.p_size, FLAGS.set)
    # save_run_statistics(statistics, synthesizer=FLAGS.synthesizer, p_size=FLAGS.p_size)
Example #7
0
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# File Description:
#       Main application entry point, also used for testing.
#

from utils import logger
from utils.logger import get_logger as logging
from utils import utility
from config import GeneralCfg

from data_parsing.midi_reader import MidiReader

if __name__ == '__main__':
    logger.initialize("Orchestrion", GeneralCfg.log_to_disk.value,
                      utility.get_root_dir())
    log = logging("App")
    log.info("Starting Orchestrion Application:\n"
             "\n"
             "Application Details:\n"
             "__________________________________________________\n\n"
             "\t> Version: {}\n"
             "\t> Author: {}\n"
             "\t> Copyright Year: {}\n"
             "__________________________________________________\n".format(
                 GeneralCfg.version.value, GeneralCfg.author.value,
                 GeneralCfg.copyright_year.value))

    midi_root = utility.get_root_dir() + "/data/midis/"
    midi_reader = MidiReader(
        midi_root, "{}/data/generated".format(utility.get_root_dir()))