Exemplo n.º 1
0
 async def config(self, ctx, *, params: str):
     args = params.split()
     if len(args) > 3:
         await ctx.channel.send(
             'You cannot send a message with more than three arguments.')
     elif len(args) <= 1:
         await ctx.channel.send('Your message needs at least two arguments.'
                                )
     else:
         if config[args[0]] is not None and args[0] != 'token' and args[
                 0] != 'prefix':
             if len(args) == 3:
                 if config[args[0]][args[1]] is not None \
                         and args[0] != 'token' and args[0] != 'prefix':
                     config[args[0]][args[1]] = args[2]
                     write_config()
                     await ctx.channel.send(
                         'Configuration parameter {} {} has been changed to {}'
                         .format(args[0], args[1], args[2]))
             else:
                 config[args[0]] = args[1]
                 write_config()
                 await ctx.channel.send(
                     'Configuration parameter {} has been changed to {}'.
                     format(args[0], args[1]))
Exemplo n.º 2
0
def startup(cls):
	appQt = QtWidgets.QApplication([])
	
	#style
	appQt.setStyle(QtWidgets.QStyleFactory.create('Fusion'))
	appQt.setPalette(qt_theme.dark_palette)
	appQt.setStyleSheet("QToolTip { color: #ffffff; background-color: #353535; border: 1px solid white; }")
	
	win = cls()
	win.show()
	appQt.exec_()
	config.write_config("config.ini", win.cfg)
Exemplo n.º 3
0
    async def config(self, ctx, *, params: str = ""):
        args = params.split()
        if len(args) >= 2 and args[0] == 'karma' and args[1] == 'keywords':
            keywords = params.replace('karma keywords', '')
            args[2] = keywords.strip()
            args = args[:3]

        if len(args) > 3:
            await ctx.channel.send(
                'You provided too many arguments to the config command.')
            return

        if len(args) == 0:
            embed = self.build_config_embed()
            await ctx.channel.send(embed=embed)
            return

        if args[0] == 'help':
            embed = self.build_config_help_embed(args)
            await ctx.channel.send(embed=embed)
            return

        if args[0] in hidden_config:
            return

        if args[0] not in config.keys():
            await ctx.channel.send('Configuration key does not exist.')
            return

        if len(args) == 3:
            if args[1] not in config[args[0]].keys():
                await ctx.channel.send('Configuration key does not exist.')
                return

            config[args[0]][args[1]] = args[2]
            write_config()
            await ctx.channel.send(
                'Configuration parameter {} {} has been changed to {}'.format(
                    args[0], args[1], args[2]))
            return

        config[args[0]] = args[1]
        write_config()
        await ctx.channel.send(
            'Configuration parameter {} has been changed to {}'.format(
                args[0], args[1]))
Exemplo n.º 4
0
 async def config(self, ctx, *, params: str = ""):
     args = params.split()
     if len(args) >= 2 and args[0] == "karma" and args[1] == "keywords":
         keywords = params.replace("karma keywords", "")
         args[2] = keywords.strip()
         args = args[:3]
     if len(args) > 3:
         await ctx.channel.send(
             "You provided too many arguments to the config command.")
     else:
         if len(args) == 0:
             embed = self.build_config_embed()
             await ctx.channel.send(embed=embed)
         else:
             if args[0] == "help":
                 embed = self.build_config_help_embed(args)
                 await ctx.channel.send(embed=embed)
             elif args[0] not in hidden_config:
                 if len(args) == 3:
                     if (args[0] in config.keys()
                             and args[1] in config[args[0]].keys()):
                         config[args[0]][args[1]] = args[2]
                         write_config()
                         await ctx.channel.send(
                             "Configuration parameter {} {} has been changed to {}"
                             .format(args[0], args[1], args[2]))
                     else:
                         await ctx.channel.send(
                             "Configuration key does not exist.")
                 else:
                     if args[0] in config.keys():
                         config[args[0]] = args[1]
                         write_config()
                         await ctx.channel.send(
                             "Configuration parameter {} has been changed to {}"
                             .format(args[0], args[1]))
                     else:
                         await ctx.channel.send(
                             "Configuration key does not exist.")
Exemplo n.º 5
0
def cli(*argv):
    '''
    CLI for Image Generator. Run `./image_generator.py -h` to show help.
    
    See also the `user's manual`_.
    
    .. _user's manual:
        user_manual.html
    '''
    parser = argparse.ArgumentParser(
        description=DESCRIPTION,
        epilog=FOOTER,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        # formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    # Main options
    parser.add_argument('-n',
                        '--number',
                        default=1,
                        type=uint,
                        help='number of output images')
    parser.add_argument('-r',
                        '--resolution',
                        default='960x540',
                        type=parse_resolution,
                        help='[width]x[height] of the output images')
    parser.add_argument(
        '-o',
        '--output',
        default='output',
        type=str,
        help='output path for images (will be created if non-existing)')
    # parser.add_argument('-t', '--type',        default='depth',         choices=['depth', 'displacement'],           help='depth data type')
    parser.add_argument('-g',
                        '--ground-type',
                        default='asphalt',
                        choices=['cobblestone', 'asphalt', 'slate'],
                        help='ground style')
    parser.add_argument('-d',
                        '--defects',
                        default=0,
                        type=uint,
                        help='number of road defects')
    parser.add_argument('-D',
                        '--depth-range',
                        default='16bit',
                        choices=['8bit', '16bit'],
                        help='depth output pixel bit depth')

    # Camera options
    parser.add_argument('--camera-distance',
                        default=20.0,
                        type=float,
                        help='horizontal camera distance (in cm)')
    parser.add_argument('--camera-pitch',
                        default=12.5,
                        type=float,
                        help='camera pitch downward (in deg)')
    parser.add_argument('--camera-height',
                        default=125.0,
                        type=float,
                        help='vertical camera distance (in cm)')
    parser.add_argument(
        '--camera-inward-yaw',
        default=0.0,
        type=float,
        help=
        'camera rotation towards each other (in deg, 0° to 15° makes sense, depending on --camera-distance)'
    )

    # Setup options
    parser.add_argument('-p',
                        '--project',
                        default=project_path,
                        help='path to project directory')
    parser.add_argument('-b',
                        '--blenderpath',
                        default=blender_default,
                        help='path to blender executable')
    parser.add_argument('-f',
                        '--foreground',
                        action='store_true',
                        help='show blender UI')
    parser.add_argument('-v',
                        '--verbose',
                        default=0,
                        action='count',
                        help='increase output verbosity level')
    parser.add_argument('-q',
                        '--quiet',
                        action='store_true',
                        help='don\'t print any output')

    args = parser.parse_args(argv[1:])

    # Select config keys to pass to main.py
    ## NOTE: All '-'s become '_'s in the config object!
    config_keys = [
        'number',
        'resolution',
        'output',
        'depth-range',
        'ground-type',
        'defects',
        'camera-distance',
        'camera-height',
        'camera-pitch',
        'camera-inward-yaw',
        'verbose',
    ]

    blender_options = [
        '' if args.foreground else '--background',
        # '-noaudio',
    ]

    # run blender script
    command = [args.blenderpath] + blender_options + [
        '--python', os.path.join(args.project, 'main.py')
    ]
    if args.verbose > 0:
        print(command)
    try:
        for i in range(args.number):
            if args.verbose == 0 and not args.quiet:
                progress_bar(i, args.number, style=PROGRESS_VERTICAL)
            write_config(args, config_keys, args.project, image_index=i)
            if args.verbose > 0:
                print('generating ground textures')
                ground_textures(args.output, args.ground_type, args.defects)
                run(command)
            else:
                ground_textures(args.output, args.ground_type, args.defects)
                progress_bar(i + 0.15, args.number, style=PROGRESS_VERTICAL)
                with OutputSuppressor():
                    run(command)
        if args.verbose == 0 and not args.quiet:
            progress_bar(args.number, args.number, style=PROGRESS_VERTICAL)
            print()
    except FileNotFoundError as fnfe:
        progress_bar_clear()
        if args.blenderpath in str(fnfe):
            print(
                'Cannot locate Blender in "{}", set with --blenderpath option.'
                .format(args.blenderpath),
                file=sys.stderr)
        else:
            print(fnfe, file=sys.stderr)
    except KeyboardInterrupt:
        progress_bar_clear()
        print('Aborted')