Ejemplo n.º 1
0
def login_using_args(args, password):
    """
    Login using args from argparse added by :func:`add_login_args`.
    """
    ## Login using other form parameters and url.
    ## (just an example for setups that do not authenticate through Devilry, this one for UiO.)
    if args.url.endswith('/'):
        url = args.url[:-1]
    else:
        url = args.url

    if args.loginprofile:
        try:
            loginprofile = LOGIN_PROFILES[args.loginprofile]
        except KeyError:
            raise SystemExit('Invalid login profile: \'{0}\'. See --help for more available profiles.'
                             .format(args.loginprofile, AVAILABLE_LOGINPROFILES))
        else:
            loginpath = loginprofile['loginpath']
            kw = {loginprofile['usernamefield']: args.user,
                  loginprofile['passwordfield']: password}
    else:
        loginpath = args.loginpath
        kw = {args.usernamefield: args.user,
              args.passwordfield: password}

    login_url = '{0}{1}'.format(url, loginpath)
    logincookie = login(login_url, **kw)
    return logincookie
Ejemplo n.º 2
0
from devilryrestfullib import (login, RestfulFactory, RestfulError,
                               HttpResponseNotFound, HttpResponseBadRequest,
                               HttpResponseUnauthorized, HttpResponseForbidden,
                               JsonDecodeError)
from uiodata import subjects

# may be something like http://devilry.myorganzation.com/some/subpath/ in production
devilry_url = 'http://localhost:8000'

# Log in
# - login url may be somthing else if devilry does not handle the login,
#   however this example assumes that devilry is used for login, and the devilry
#   login form is at /authenticate/login
login_url = '{0}/authenticate/login'.format(devilry_url)
logincookie = login(login_url, username='******', password='******')

# Create proxy classes which makes it natural to program against the
# RESTful interface using python.
restful_factory = RestfulFactory(devilry_url)
SimplifiedNode = restful_factory.make("/administrator/restfulsimplifiednode/")
SimplifiedSubject = restful_factory.make(
    "/administrator/restfulsimplifiedsubject/")
SimplifiedPeriod = restful_factory.make(
    "/administrator/restfulsimplifiedperiod/")
SimplifiedAssignment = restful_factory.make(
    "/administrator/restfulsimplifiedassignment/")
SimplifiedAssignmentGroup = restful_factory.make(
    "/administrator/restfulsimplifiedassignmentgroup/")

uio = {}
matnat = {}
Ejemplo n.º 3
0
                               HttpResponseNotFound,
                               HttpResponseBadRequest,
                               HttpResponseUnauthorized,
                               HttpResponseForbidden,
                               JsonDecodeError)
from uiodata import subjects

# may be something like http://devilry.myorganzation.com/some/subpath/ in production
devilry_url = 'http://localhost:8000'

# Log in
# - login url may be somthing else if devilry does not handle the login,
#   however this example assumes that devilry is used for login, and the devilry
#   login form is at /authenticate/login
login_url = '{0}/authenticate/login'.format(devilry_url)
logincookie = login(login_url, username='******', password='******')

# Create proxy classes which makes it natural to program against the
# RESTful interface using python.
restful_factory = RestfulFactory(devilry_url)
SimplifiedNode = restful_factory.make("/administrator/restfulsimplifiednode/")
SimplifiedSubject = restful_factory.make("/administrator/restfulsimplifiedsubject/")
SimplifiedPeriod = restful_factory.make("/administrator/restfulsimplifiedperiod/")
SimplifiedAssignment = restful_factory.make("/administrator/restfulsimplifiedassignment/")
SimplifiedAssignmentGroup = restful_factory.make("/administrator/restfulsimplifiedassignmentgroup/")

uio = {}
matnat = {}
ifi = {}

Ejemplo n.º 4
0
        .format(sys.argv[0]))

devilry_url = sys.argv[1]
username = sys.argv[2]
subject_short_name = sys.argv[3]
period_short_name = sys.argv[4]
password = getpass()  # Ask user to input password
#password = '******'

####################################################################
# Common for more or less any Devilry application
####################################################################

## Log in
login_url = '{0}/authenticate/login'.format(devilry_url)
logincookie = login(login_url, username=username, password=password)

## Login using other form parameters and url.
## (just an example for setups that do not authenticate through Devilry, this one for UiO.)
#login_url = '{0}/login'.format(devilry_url)
#logincookie = login(login_url, user=username, password=password)

## Load the RESTful API
# Creates proxy classes which makes it natural to program against the RESTful
# interface using python. Exactly what you load here depends on what you want
# to access. See the _Public RESTful API_ section of the API docs at
# http://devilry.org for a complete overview and documentation for all our
# APIs:
#   http://devilry.org/devilry-django/dev/restfulapi/administrator/index.html#restful-apiadministrator
restful_factory = RestfulFactory(devilry_url)
SimplifiedPeriod = restful_factory.make(
Ejemplo n.º 5
0
    HttpResponseBadRequest,
    HttpResponseUnauthorized,
    HttpResponseForbidden,
    JsonDecodeError,
)


# may be something like http://devilry.myorganzation.com/some/subpath/ in production
devilry_url = "http://localhost:8000"

# Log in
# - login url may be somthing else if devilry does not handle the login,
#   however this example assumes that devilry is used for login, and the devilry
#   login form is at /authenticate/login
login_url = "{0}/authenticate/login".format(devilry_url)
logincookie = login(login_url, username="******", password="******")

# Create proxy classes which makes it natural to program against the
# RESTful interface using python.
restful_factory = RestfulFactory(devilry_url)
SimplifiedNode = restful_factory.make("/administrator/restfulsimplifiednode/")
SimplifiedSubject = restful_factory.make("/administrator/restfulsimplifiedsubject/")
SimplifiedPeriod = restful_factory.make("/administrator/restfulsimplifiedperiod/")
SimplifiedAssignment = restful_factory.make("/administrator/restfulsimplifiedassignment/")
SimplifiedAssignmentGroup = restful_factory.make("/administrator/restfulsimplifiedassignmentgroup/")


""" ####################################################
                    SEARCH / GET
#################################################### """
Ejemplo n.º 6
0
devilry_url = sys.argv[1]
username = sys.argv[2]
subject_short_name = sys.argv[3]
period_short_name = sys.argv[4]
password = getpass() # Ask user to input password
#password = '******'


####################################################################
# Common for more or less any Devilry application
####################################################################

## Log in
login_url = '{0}/authenticate/login'.format(devilry_url)
logincookie = login(login_url, username=username, password=password)

## Login using other form parameters and url.
## (just an example for setups that do not authenticate through Devilry, this one for UiO.)
#login_url = '{0}/login'.format(devilry_url)
#logincookie = login(login_url, user=username, password=password)

## Load the RESTful API
# Creates proxy classes which makes it natural to program against the RESTful
# interface using python. Exactly what you load here depends on what you want
# to access. See the _Public RESTful API_ section of the API docs at
# http://devilry.org for a complete overview and documentation for all our
# APIs:
#   http://devilry.org/devilry-django/dev/restfulapi/administrator/index.html#restful-apiadministrator
restful_factory = RestfulFactory(devilry_url)
SimplifiedPeriod = restful_factory.make('/administrator/restfulsimplifiedperiod/')