Esempio n. 1
0
def init_fundamentals():
    init_pygame()
    import platform_specific
    platform_specific.startup_hook()
    audio.init()
    commands.init()
    init_archy()
Esempio n. 2
0
def main(argv=sys.argv[1:]):

    args = parser.parse_args(argv)

    if args.command == 'add':
        add(args.paths)
    elif args.command == 'cat-file':
        try:
            cat_file(args.mode, args.hash_prefix)
        except ValueError as error:
            print(error, file=sys.stderr)
            sys.exit(1)
    elif args.command == 'commit':
        commit(args.message, author=args.author)
    elif args.command == 'diff':
        diff()
    elif args.command == 'hash-object':
        sha1 = hash_object(read_file(args.path), args.type, write=args.write)
        print(sha1)
    elif args.command == 'init':
        init(args.repo)
    elif args.command == 'ls-files':
        ls_files(details=args.stage)
    elif args.command == 'push':
        push(args.git_url, username=args.username, password=args.password)
    elif args.command == 'status':
        status()
    else:
        assert False, 'unexpected command {!r}'.format(args.command)
Esempio n. 3
0
def init_fundamentals():
    init_pygame()
    import platform_specific
    platform_specific.startup_hook()
    audio.init()
    commands.init()
    init_archy()
Esempio n. 4
0
 def testInit(self, setMetaData):
     stdout = io.StringIO()
     with contextlib.redirect_stdout(stdout):
         commands.init('NewDump')
     setMetaData.assert_called_once_with(files.MetaData('NewDump', {}, {}),
             '.')
     self.assertEqual(stdout.getvalue(),
             'Initialized new empty replica NewDump.\n')
Esempio n. 5
0
def reloadCommands(parameters=None, pipedInput=None):
    global cmd, ourShell
    try:
        reload(cmd)
        cmd.init(ourShell)
    except Exception as e:
        print(
            f"\nUhh... something went wrong reloading :(\nmosh will stay the same\n{e}"
        )
    else:
        print("Finished reload!")
    pass
Esempio n. 6
0
def init_app(loop, name):
    db = loop.run_until_complete(
        SADataBase.connect(config.DB_CONFIG, config.DB_CHARSET, loop))
    app = web.Application()
    app['db'] = db
    app.cleanup_ctx.append(context)
    cr_app = web.Application()
    shift_start_time = datetime.now() - timedelta(minutes=5)
    commands_app = commands.init(
        db,
        cr_config=config.CR_CONFIG,
        connection_timeout=config.COMMANDS_CONFIG['EXECUTION_WAITING_TIMEOUT'],
        test_without_hardware=True,
        shift_start_time=shift_start_time,
        loop=loop)

    cr_app.add_subapp('/cr_proccessing/', commands_app)
    app_admin = admin.init()
    cr_app.add_subapp('/admin/', app_admin)
    cr_app.cleanup_ctx.append(cr_app_context)
    # орпределяем корневой url до приложения кассы и его имя, они будут использоваться при фиксировании разрешений
    # на доступ к ресурсам в базе данных (чтобы не было зависимости от корневого url, который может меняться)
    cr_app['cr_app_name'] = 'cr2'
    cr_app['cr_app_prefix'] = '/cr2/'
    app.add_subapp(cr_app['cr_app_prefix'], cr_app)
    return app
Esempio n. 7
0
def trySetup(addr,port):
    chat = Protocol()
    site = twisted.web.server.Site(twisted.web.static.File(public))
    reactor.listenUDP(port,chat)
    reactor.listenTCP(port+1,site)
    StandardIO(ConsoleHandler(chat))
    print("Tell your friends /add [{}]:{}".format(addr,port))
    with commands.init(stdin):
        reactor.run()
Esempio n. 8
0
def trySetup(addr, port):
    chat = Protocol()
    site = twisted.web.server.Site(twisted.web.static.File(public))
    reactor.listenUDP(port, chat)
    reactor.listenTCP(port + 1, site)
    StandardIO(ConsoleHandler(chat))
    print("Tell your friends /add [{}]:{}".format(addr, port))
    with commands.init(stdin):
        reactor.run()
Esempio n. 9
0
 def __init__(self):
     asyncore.dispatcher.__init__(self)
     self.logpath = os.path.join(world.logDir, 'server')
     self.events = []
     # Uncomment the below line if you want IPV6, or if your host operating system
     # allows mapped IPV4->IPV6 nativly.  Windows 7 doesn't do this (probably
     # without some flag I'm not setting....... I know Linux works.
     # self.create_socket(AF_INET6, SOCK_STREAM)
     self.create_socket(AF_INET, SOCK_STREAM)
     self.set_reuse_addr()
     self.bind(('', 4000))
     self.listen(5)
     helpsys.init()
     races.init()
     commands.init()
     event.init()
     area.init()
     event.init_events_server(self)
     print('APM is up and running in {0:,.3f} seconds.'.format(time.time() - startup))
Esempio n. 10
0
def main():

    if contains_confgit_command(): # if user has specified confgit command

        args = vars(parse_confgit_args())

        if args['debug']:
            debug_mode = True

        print_debug(args)

        if args['command'] == 'init':
            init(args['init_path'], args['CONFIG_PATH'])

        config = load_config(args['CONFIG_PATH'])
        print_debug(config)

        if args['command'] == 'include':
            for i in args['paths']:
                include(i, config, args['CONFIG_PATH'])

        if args['command'] == 'exclude':
            for i in args['paths']:
                exclude(i, config, args["CONFIG_PATH"])

        if args['command'] == 'sync':
            sync(config)

        if args['command'] == 'update':
            update(config)

        if args['command'] == 'backup':
            backup(config, args['backup_path'])

    else: # if user has not specified confgit command
        #! doesn't check if it's a valid git command, could be problem later - g3ner1c
        config, git_command = parse_git_args()
        print_debug(git_command)
        cd(config["repo_dir"])
        send_to_git(git_command)
Esempio n. 11
0
def parseArgs(args=None):
    parser = argparse.ArgumentParser(description='''Synchronize directory
        replicas using version vectors.''')
    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True

    initP = subparsers.add_parser('init', help='''Initialize a new replica
        in the current directory''')
    initP.add_argument('ID', help='ID for the new Replica')
    initP.set_defaults(func=lambda args: commands.init(args.ID))

    syncP = subparsers.add_parser('sync', help='''Synchronize with another
        replica''')
    syncP.add_argument('path', help='path/to/another replica')
    syncP.set_defaults(func=lambda args: commands.sync(args.path))

    parsedArgs = parser.parse_args(args)
    parsedArgs.func(parsedArgs)
Esempio n. 12
0
def main(Arguments=None):
    global ourShell, lastCmd, up_index
    printMOTD()
    # create a new instance so we can set up the class for later reference
    cmd.init(ourShell)
    while not isDone:
        # get the global nextCmd
        global nextCmd
        # read user input
        nextCmd = readCmd()
        # if we have too much in history, keep it 10 items long
        if len(lastCmd) > 10:
            del (lastCmd[-1])
        # append the command we just read from user input
        lastCmd.append(nextCmd)

        # stupid workaround to print a newline without changing readCmd()
        print()
        # if we didn't get a None/null input
        regExp = r'(?!\B"[^"]*)\|(?![^"]*"\B)(?<!\\\|)'
        # this absolute behemoth of a regex is a mix of https://stackoverflow.com/questions/21105360/regex-find-comma-not-inside-quotes/21106122
        # and my own workings to detect pipes that aren't escaped or in quotes
        try:
            splitCmd = list(re.split(regExp, nextCmd))
        except:
            continue
        pipedInput = ""
        for i, item in enumerate(splitCmd):
            nextCmd = item.strip()
            if nextCmd != None:
                # get the command name (without parameters)
                nextCmdName = nextCmd.split(' ')[0]
                # check if the current cmd instance knows the command or if it's a shell command
                if nextCmdName in cmd.getCommands(
                ) or nextCmdName in localCommands:
                    # if it exists, and is the only/last command
                    #print(len(splitCmd), i)
                    #print(i == (len(splitCmd)-1))
                    if (len(splitCmd) <= 1) or (i == (len(splitCmd) - 1)):
                        #doCommand(nextCmdName, nextCmd, pipedInput)
                        doCommand(nextCmd, pipedInput)
                        #print(lastCmd)
                        # reset up_index after executing so our up arrow works properly
                        up_index = 0
                        # if the command doesn't exist, error out
                    else:
                        #print("piped")
                        # source: https://www.kite.com/python/answers/how-to-redirect-print-output-to-a-variable-in-python
                        # store the reference to stdout
                        old_stdout = sys.stdout
                        # create a new stdout as a StringIO
                        new_stdout = StringIO()
                        # assign stdout to the StringIO instance
                        sys.stdout = new_stdout
                        # run command
                        #doCommand(nextCmdName, nextCmd, pipedInput)
                        doCommand(nextCmd, pipedInput)
                        # store output in pipedInput
                        pipedInput = new_stdout.getvalue()
                        # restore stdout so we're back to normal
                        sys.stdout = old_stdout
                else:
                    print("{0}: {1}: command not found".format(
                        ourShell.shellName, nextCmd))
    else:
        print("Goodbye!")
        return 0
    return 0
Esempio n. 13
0
import sys


os.chdir(os.path.dirname(os.path.realpath(__file__)))

logging.basicConfig(level=logging.DEBUG)
handler = logging.FileHandler('debug.log', 'w', 'utf-8')

root_logger= logging.getLogger()
root_logger.addHandler(handler)

logger = logging.getLogger('claptrap')

bot = telegram.Bot(conf.botID)

commands.init(bot.getMe()['username'])


def handle(bot,msg):
	logger.debug(json.dumps(msg)+"\n")
	#if not msg.has_key("text") and not msg.has_key("chat"):
	try:	
		#logging.debug("test\n")
		chat_id = msg['chat']['id']
		text	= msg['text']
	
		logger.info("Mensaje recibido: "+ text)
	
		for comando in commands.list:
			if comando[0].match(text):
				bot.sendMessage(chat_id,comando[1]())
Esempio n. 14
0
import os
import sys

os.chdir(os.path.dirname(os.path.realpath(__file__)))

logging.basicConfig(level=logging.DEBUG)
handler = logging.FileHandler('debug.log', 'w', 'utf-8')

root_logger = logging.getLogger()
root_logger.addHandler(handler)

logger = logging.getLogger('claptrap')

bot = telegram.Bot(conf.botID)

commands.init(bot.getMe()['username'])


def handle(bot, msg):
    logger.debug(json.dumps(msg) + "\n")
    #if not msg.has_key("text") and not msg.has_key("chat"):
    try:
        #logging.debug("test\n")
        chat_id = msg['chat']['id']
        text = msg['text']

        logger.info("Mensaje recibido: " + text)

        for comando in commands.list:
            if comando[0].match(text):
                bot.sendMessage(chat_id,
Esempio n. 15
0
from discord.ext import commands

import commands as bot_commands

# Add bot key here.
bot_key: Optional[str] = None

# Debug logging mode?
debug: bool = False

if debug:
    logging.basicConfig(level=logging.DEBUG)
else:
    logging.basicConfig(level=logging.INFO)

bot = commands.Bot(command_prefix=",", description="Performance Analytics bot")


@bot.event
async def on_ready():

    print('Logged in as')
    print(bot.user.name)


bot_commands.init(bot)

if __name__ == "__main__":
    bot.run(bot_key)
Esempio n. 16
0
            raise BaconError._from_error_code(result)

    return f


# Initialize library now

lib = native.load(function_wrapper=_error_wrapper)

if not native._mock_native:
    _log_callback_handle = lib.LogCallback(_log_callback)
    lib.SetLogCallback(_log_callback_handle)
    lib.Init()

    import commands
    commands.init()

    # Expose library version
    major_version = c_int()
    minor_version = c_int()
    patch_version = c_int()
    lib.GetVersion(byref(major_version), byref(minor_version),
                   byref(patch_version))
    major_version = major_version.value  #: Major version number of the Bacon dynamic library that was loaded, as an integer.
    minor_version = minor_version.value  #: Minor version number of the Bacon dynamic library that was loaded, as an integer.
    patch_version = patch_version.value  #: Patch version number of the Bacon dynamic library that was loaded, as an integer.
else:
    major_version, minor_version, patch_version = (0, 1, 0)

#: Version of the Bacon dynamic library that was loaded, in the form ``"major.minor.patch"``.
version = '%d.%d.%d' % (major_version, minor_version, patch_version)
Esempio n. 17
0
 def robotInit(self):
     subsystems.init()
     oi.init()
     commands.init()
Esempio n. 18
0
 def robotInit(self):
     subsystems.init()
     inputs.oi.init()
     commands.init()
     print(type(inputs.oi.A))
Esempio n. 19
0
import os

x = r'{}'.format(input("Enter directory path: "))
repo_dir = x.replace("\\", "/")
print(repo_dir)

repo_name = repo_dir.split("/")[-1].replace(" ", "_")
print(repo_name)

e = False
while not e:
    command = input("$>").split(" ")

    if command[0] == "init":
        try:
            commands.init(repo_name, repo_dir)
            os.chdir(os.path.join(repo_dir, ".vcr"))
        except FileExistsError:
            print("This folder is already a repository")
    try:
        os.chdir(os.path.join(repo_dir, ".vcr"))

    except:
        pass

    if command[0] == "add":
        files = []
        try:
            if command[1] == "*":
                ignoreExt = input(
                    "Enter the file extensions you want to ignore (separated by a comma (,). \n For example, if you wish to ignore all .pyc files, please enter 'pyc' only: "
Esempio n. 20
0
        if result != native.ErrorCodes.none:
            raise BaconError._from_error_code(result)
    return f


# Initialize library now

lib = native.load(function_wrapper = _error_wrapper)

if not native._mock_native:
    _log_callback_handle = lib.LogCallback(_log_callback)
    lib.SetLogCallback(_log_callback_handle)
    lib.Init()

    import commands
    commands.init()

    # Expose library version
    major_version = c_int()
    minor_version = c_int()
    patch_version = c_int()
    lib.GetVersion(byref(major_version), byref(minor_version), byref(patch_version))
    major_version = major_version.value     #: Major version number of the Bacon dynamic library that was loaded, as an integer.
    minor_version = minor_version.value     #: Minor version number of the Bacon dynamic library that was loaded, as an integer.
    patch_version = patch_version.value     #: Patch version number of the Bacon dynamic library that was loaded, as an integer.
else:
    major_version, minor_version, patch_version = (0, 1, 0)


#: Version of the Bacon dynamic library that was loaded, in the form ``"major.minor.patch"``.
version = '%d.%d.%d' % (major_version, minor_version, patch_version)
Esempio n. 21
0
parser = argparse.ArgumentParser(
    prog='pistol',
    description='A Python package manager that shoots from the hip!',
)

subparsers = parser.add_subparsers(title='pistol',
                                   description='',
                                   prog='pistol',
                                   help='help help help')

import commands

init_parser = subparsers.add_parser(
    'init', help='Initialize and empty pistol project.')
init_parser.set_defaults(func=commands.init())


def project_name():
    import os
    current_dir = os.path.dirname(__file__)
    project_name = current_dir.split('/')[-1:][0]
    return project_name


init_parser.add_argument('--name', default=project_name())
init_parser.add_argument('--version')
init_parser.add_argument('--author')
init_parser.add_argument('--description')
init_parser.add_argument('--keyword')
init_parser.add_argument('--bin')
Esempio n. 22
0
File: run.py Progetto: smilliken/mut
def main():
    if not sys.argv:
        raise InvalidUsageException()
    argv = sys.argv[1:] # chop off script name as first arg
    try:
        command = argv[0]
    except IndexError:
        raise InvalidUsageException()
    if command == '--help':
        usage()
    elif argv[-1] == '--help':
        usage(command)
    elif command == 'init':
        try:
            repo_name = argv[1]
        except IndexError:
            raise InvalidUsageException('repo_name is required.')
        commands.init(repo_name)
    elif command == 'switch':
        try:
            repo_name = argv[1]
        except IndexError:
            raise InvalidUsageException('repo_name is required.')
        commands.switch(repo_name)
    elif command == 'add-remote':
        try:
            repo_uri = argv[1]
        except IndexError:
            raise InvalidUsageException('repo_uri is required.')
        try:
            remote_name = argv[2]
        except IndexError:
            remote_name = None
        commands.add_remote(repo_uri, remote_name=remote_name)
    elif command == 'drop-remote':
        try:
            remote_name = argv[1]
        except IndexError:
            raise InvalidUsageException('remote_name is required.')
        commands.drop_remote(remote_name)
    elif not active_repo:
        raise InvalidUsageException('no active repository, must init or switch to a repository.')
    elif command == 'ls':
        flags = _parse_flags(argv[1:])
        commands.ls(tags=flags['tags'], neg_tags=flags['neg_tags'])
    elif command == 'add':
        try:
            description = argv[1]
        except IndexError:
            raise InvalidUsageException('Task description is required.')
        flags = _parse_flags(argv[2:])
        if flags['neg_tags']:
            raise InvalidUsageException('Negative tags not valid when adding task.')
        for tag in flags['tags']:
            if tag in reserved_tags:
                raise InvalidUsageException('That tag is reserved. The following tags are automatically attached to tasks: %s.' % ', '.join(reserved_tags))
        commands.add(description, priority=flags['priority'], tags=flags['tags'])
    elif command == 'mod':
        try:
            id = argv[1]
        except IndexError:
            raise InvalidUsageException('id is required.')
        flags = _parse_flags(argv[2:])
        for tag in flags['tags'] + flags['neg_tags']:
            if tag in reserved_tags:
                raise InvalidUsageException('That tag is reserved. The following tags are automatically attached to tasks: %s.' % ', '.join(reserved_tags))
        commands.mod(id, priority=flags['priority'], tags=flags['tags'], neg_tags=flags['neg_tags'])
    elif command == 'edit':
        try:
            id = argv[1]
        except IndexError:
            raise InvalidUsageException('id is required.')
        flags = _parse_flags(argv[2:])
        if flags['priority'] or flags['tags'] or flags['neg_tags']:
            raise InvalidUsageException('Invalid options specified.')
        commands.edit(id)
    elif command == 'start':
        try:
            id = argv[1]
        except IndexError:
            raise InvalidUsageException('id is required.')
        flags = _parse_flags(argv[2:])
        if flags['priority'] or flags['tags'] or flags['neg_tags']:
            raise InvalidUsageException('Invalid options specified.')
        commands.start(id)
    elif command == 'stop':
        try:
            id = argv[1]
        except IndexError:
            raise InvalidUsageException('id is required.')
        flags = _parse_flags(argv[2:])
        if flags['priority'] or flags['tags'] or flags['neg_tags']:
            raise InvalidUsageException('Invalid options specified.')
        commands.stop(id)
    elif command == 'finish':
        try:
            id = argv[1]
        except IndexError:
            raise InvalidUsageException('id is required.')
        flags = _parse_flags(argv[2:])
        if flags['priority'] or flags['tags'] or flags['neg_tags']:
            raise InvalidUsageException('Invalid options specified.')
        commands.finish(id)
    elif command == 'rm':
        try:
            id = argv[1]
        except IndexError:
            raise InvalidUsageException('id is required.')
        flags = _parse_flags(argv[2:])
        if flags['priority'] or flags['tags'] or flags['neg_tags']:
            raise InvalidUsageException('Invalid options specified.')
        commands.rm(id)
    else:
        raise InvalidUsageException('Unrecognized command: %s.' % command)