gramex.license

is_accepted()

If license was accepted, returns timestamp when license was accepted. If license was never accepted so far, returns None. If license was rejected, returns False.

Source code in gramex\license.py
19
20
21
22
23
24
25
def is_accepted():
    '''
    If license was accepted, returns timestamp when license was accepted.
    If license was never accepted so far, returns None.
    If license was rejected, returns False.
    '''
    return store.load('accepted', default=None)

accept(force=False)

Prints the license. Allows users to accept the license by prompting. If force=True is passed, accepts the license with no prompt. If no stdin is available, e.g. when running as a service, accept license with no prompt.

Source code in gramex\license.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def accept(force=False):
    '''
    Prints the license.
    Allows users to accept the license by prompting.
    If force=True is passed, accepts the license with no prompt.
    If no stdin is available, e.g. when running as a service, accept license with no prompt.
    '''
    if is_accepted():
        return
    gramex.console(EULA)
    result = 'y' if force or not sys.stdin else ''
    while not result:
        result = input('Do you accept the license (Y/N): ').strip()
    if result.lower().startswith('y'):
        store.dump('accepted', time.time())
        store.flush()
        gramex.console('Gramex license accepted')
    else:
        raise RuntimeError('Gramex license not accepted')

reject()

Rejects the license.

Source code in gramex\license.py
49
50
51
52
53
54
55
def reject():
    '''
    Rejects the license.
    '''
    store.dump('accepted', False)
    store.flush()
    gramex.console('Gramex license rejected')