Ejemplo n.º 1
0
 def test_add(self):
     conf = Conf('primtux')
     lines = startup.split('\n')
     lines = [line + '\n' for line in lines]
     conf.load(lines[:-1])
     soft = Soft('firefox', 'firefox', '', '')
     conf.add(soft)
     assert str(conf) == startup_add
Ejemplo n.º 2
0
    for alias, command in aliases.items():
        print '{0:<20}: {1}'.format(alias, command)

elif args.command == 'show':
    if len(args.arguments) != 1:
        debug(
            'Too few/many arguments. One needed: moodle alias show aliasName')
        sys.exit(1)
    alias = C.get('aliases.%s' % args.arguments[0])
    if alias != None:
        debug(alias)

elif args.command == 'add':
    if len(args.arguments) < 2:
        debug(
            'Too few/many arguments. Two needed: moodle alias add aliasName Command To Perform'
        )
        sys.exit(1)
    alias = args.arguments[0]
    command = ' '.join(args.arguments[1:])
    C.add('aliases.%s' % alias, command)

elif args.command == 'remove':
    if len(args.arguments) != 1:
        debug(
            'Too few/many arguments. One needed: moodle alias remove aliasName'
        )
        sys.exit(1)
    alias = args.arguments[0]
    C.remove('aliases.%s' % alias)
Ejemplo n.º 3
0
parser.add_argument('arguments', type=str, metavar='arguments', default=None, nargs=argparse.REMAINDER, help='arguments for the command')
args = parser.parse_args()

if args.command == 'list':
    aliases = C.get('aliases')
    for alias, command in aliases.items():
        print '{0:<20}: {1}'.format(alias, command)

elif args.command == 'show':
    if len(args.arguments) != 1:
        debug('Too few/many arguments. One needed: moodle alias show aliasName')
        sys.exit(1)
    alias = C.get('aliases.%s' % args.arguments[0])
    if alias != None:
        debug(alias)

elif args.command == 'add':
    if len(args.arguments) < 2:
        debug('Too few/many arguments. Two needed: moodle alias add aliasName Command To Perform')
        sys.exit(1)
    alias = args.arguments[0]
    command = ' '.join(args.arguments[1:])
    C.add('aliases.%s' % alias, command)

elif args.command == 'remove':
    if len(args.arguments) != 1:
        debug('Too few/many arguments. One needed: moodle alias remove aliasName')
        sys.exit(1)
    alias = args.arguments[0]
    C.remove('aliases.%s' % alias)