Exemple #1
0
 def parser(self):
     commands = [
         {
             'name': "info",
             'description': "Show server info",
             'func': self.serverInfo,
         },
         {
             'name': "register",
             'args': [
                 "username",
             ],
             'description': "Register user with specified username",
             'func': self.register,
         },
         {
             'name': "kill",
             'args': [
                 "username",
             ],
             'description': "Completely remove user from server",
             'func': self.kill,
         },
         {
             'name': "clear",
             'args': [
                 "username",
             ],
             'description': "Clear user's dir content",
             'func': self.purge,
         },
         {
             'name': "reset",
             'args': [
                 "username",
                 "password",
             ],
             'description': "Set user's password",
             'func': self.reset,
         },
         {
             'name': "quota",
             'args': [
                 "username",
             ],
             'description': "Show user's dir size",
             'func': self.quota,
         },
     ]
     return argparser.ArgParser("manage.py", commands)
def start():
    '''
    Main function starts processing, use python3 mgenerator.py arguments
    :return: None
    '''

    log = create_logger()

    if not os.path.exists(config_file):
        log.warning("Cannot find configuration file: {}".format(config_file))
        sys.exit(1)

    # Parsing data from configuration file
    config = configparser.ConfigParser()
    config.read(config_file)
    default_ini_ = config['DEFAULT']

    # Test keys from Default.ini
    if not all(
            i == j
            for i, j in zip([k
                             for k in default_ini_.keys()], default_ini_args)):
        log.warning(
            "Cannot validate Default.ini. Possible wrong or incomplete values "
        )
        sys.exit(1)

    # Parsing program arguments as input parameter - dictionary with values from config file
    arg_parser = t.ArgParser(default_ini_)
    args = arg_parser.parse_args()

    if len(args) == 0:
        log.warning(
            "Cannot run process. Wrong or incomplete program arguments.")
        sys.exit(1)

    # Cleaning output path
    if args["clear_data"] == 1:
        log.warning("Removing all files matched to base name: {} ...".format(
            args["filename"]))
        clear_folder(args["output_path"], args["filename"])

    # Generating output data, as input parameters - dictionary with parsed values
    pr.DataProcessor(args).run_process()
Exemple #3
0
    def test_get_to_method(self):
        """Tests get_to() method."""
        pars = argparser.ArgParser()

        self.assertEqual(sys.argv[2], pars.get_to())
Exemple #4
0
    def test_get_from_method(self):
        """Test get_from() method."""
        pars = argparser.ArgParser()

        self.assertEqual(sys.argv[1], pars.get_from())
Exemple #5
0
    print('total %d n_items to train!' % (sum(items_checks)))

    tr_params = {
        'batch_size': tr_batch_size,
        'shuffle': True,
        'num_workers': tr_batch_size
    }

    for (n_epoch, n_train_item) in zip(n_epochs, n_train_items):
        drumstem_dataset = inst_dataset.TxtDrumstemDataset(
            txt_path=os.path.join(DRUMSTEM_PATH, 'files.txt'),
            src_path=DRUMSTEM_PATH,
            duration=DURATION,
            sr_wav=SR_WAV,
            ext=None)

        train_loader = DataLoader(drumstem_dataset, **tr_params)
        # training and eval
        trainer.train_many_epochs(n_epoch, train_loader, n_train_item)

    # after training
    print('ALL DONE!')


if __name__ == '__main__':
    my_arg_parser = argparser.ArgParser()
    args = my_arg_parser.parse()

    print(args)
    main(args)
Exemple #6
0
import os
import sqlite3
import subprocess
import traceback
from datetime import datetime

from colorama import Fore, init
from discord import Client, Message
from discord.utils import find

import argparser
from logbot_data import owner_id, token

CLIENT = Client(max_messages=1000000)
init()
PURGE_PARSER = argparser.ArgParser("&&", "=")
SQL = sqlite3.connect(f"{os.getcwd()}\\Discord Logs\\SETTINGS\\logbot.db")
CURSOR = SQL.cursor()
EXITING = False


def log_error(error_text: str):
    """
	Logs errors to errors.txt.
	:param error_text: The exception message.
	"""
    file = f"{os.getcwd()}\\error_log.txt"
    prev_text = ""
    try:
        reader = open(file, 'r')
        prev_text = reader.read()
Exemple #7
0
UP_WIN_M = 1

# wxPythonでイメージをスムージングしつつサイズ変更する際に用いるフラグ
if 3 <= wx.VERSION[0]:
    RESCALE_QUALITY = wx.IMAGE_QUALITY_BILINEAR
else:
    RESCALE_QUALITY = wx.IMAGE_QUALITY_HIGH

# プレイログの区切り線の長さ
LOG_SEPARATOR_LEN_LONG = 80
LOG_SEPARATOR_LEN_MIDDLE = 60
LOG_SEPARATOR_LEN_SHORT = 45

# 起動オプション
_argparser = argparser.ArgParser(
    appname=APP_NAME,
    description=u"%s %s\n\nオープンソースのCardWirthエンジン" %
    (APP_NAME, ".".join(map(lambda a: str(a), APP_VERSION))))
_argparser.add_argument("-h",
                        type=bool,
                        nargs=0,
                        help=u"このメッセージを表示して終了します。",
                        arg2="--help")
_argparser.add_argument("-debug", type=bool, nargs=0, help=u"デバッグモードで起動します。")
_argparser.add_argument("-yado",
                        type=str,
                        nargs=1,
                        default="",
                        help=u"起動と同時に<YADO>のパスにある宿を読み込みます。")
_argparser.add_argument("-party",
                        type=str,
                        nargs=1,