Exemple #1
0
 def execute(self, server, argv):
     options, args = parser.parse_args(argv)
     action = get_command(args, 'list')
     actionarg = get_argument(args)
     if action == 'list' or action == 'ls':
         return list_users(server, options)
     elif action == 'create':
         return create_user(server, options, actionarg)
     elif action == 'setprop':
         username = actionarg
         propstring = get_argument(argv, 3)
         props = parse_properties(propstring)
         return set_profile_properties(server, options, username, props)
     else:
         parser.print_help()
         return USER_ERROR
Exemple #2
0
 def execute(self, server, argv):
     options, args = parser.parse_args(argv)
     action = get_command(args, 'list')
     actionarg = get_argument(args)
     if action == 'list' or action == 'ls':
         return list_users(server, options)
     elif action == 'create':
         return create_user(server, options, actionarg)
     elif action == 'setprop':
         username = actionarg
         propstring = get_argument(argv, 3)
         props = parse_properties(propstring)
         return set_profile_properties(server, options, username, props)
     else:
         parser.print_help()
         return USER_ERROR
Exemple #3
0
def test_parse_simple_prop():
    y = parse_properties("foobar=baz")
    eq_(1, len(y))
    eq_('baz', y['foobar'])
Exemple #4
0
def test_parse_quoted_number():
    y = parse_properties("answer=\"42\"")
    eq_(2, len(y))
    eq_('42', y['answer'])
    eq_('String', y['answer@TypeHint'])
Exemple #5
0
def test_parse_integer():
    y = parse_properties("nbr_dwarves=7")
    eq_(2, len(y))
    eq_('7', y['nbr_dwarves'])
    eq_('Long', y['nbr_dwarves@TypeHint'])
Exemple #6
0
def test_parse_boolean():
    y = parse_properties("should_work=true")
    eq_(2, len(y))
    eq_('true', y['should_work'])
    eq_('Boolean', y['should_work@TypeHint'])
Exemple #7
0
def test_parse_multi_props():
    y = parse_properties("first=John,last=Doe")
    eq_(2, len(y))
    eq_('John', y['first'])
    eq_('Doe', y['last'])
Exemple #8
0
def test_parse_double_quoted_prop():
    y = parse_properties('name="John \\"The machine\\" Doe"')
    eq_(2, len(y))
    eq_('John \\"The machine\\" Doe', y['name'])
    eq_('String', y['name@TypeHint'])
Exemple #9
0
def test_parse_quoted_prop():
    y = parse_properties("name=\"John Doe\"")
    eq_(2, len(y))
    eq_('John Doe', y['name'])
    eq_('String', y['name@TypeHint'])