<s> from optparse import make_option <EOL> from django . core . management . base import BaseCommand , CommandError <EOL> from django . utils . translation import ugettext_lazy as _t , ugettext as _ <EOL> from desktop . conf import LDAP <EOL> from useradmin import ldap_access <EOL> from useradmin . views import import_ldap_users <EOL> class Command ( BaseCommand ) : <EOL> """<STR_LIT>""" <EOL> option_list = BaseCommand . option_list + ( <EOL> make_option ( "<STR_LIT>" , help = _t ( "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False ) , <EOL> make_option ( "<STR_LIT>" , help = _t ( "<STR_LIT>" ) , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False ) , <EOL> make_option ( "<STR_LIT>" , help = _t ( "<STR_LIT>" ) , <EOL> action = "<STR_LIT:store>" , <EOL> default = None ) , <EOL> ) <EOL> args = "<STR_LIT:username>" <EOL> def handle ( self , user = None , ** options ) : <EOL> if user is None : <EOL> raise CommandError ( _ ( "<STR_LIT>" ) ) <EOL> import_by_dn = options [ '<STR_LIT>' ] <EOL> sync_groups = options [ '<STR_LIT>' ] <EOL> server = options [ '<STR_LIT>' ] <EOL> connection = ldap_access . get_connection_from_server ( server ) <EOL> import_ldap_users ( connection , user , sync_groups , import_by_dn ) </s>
