示例#1
0
 def get_initial(self):
     """Get initial form data."""
     return {
         'network_topology':
         kvstore.get_default(networks.NETWORK_TOPOLOGY_TYPE_KEY,
                             'to_router')
     }
示例#2
0
 def get_initial(self):
     """Return initial data for the form."""
     return {
         'router_config':
         kvstore.get_default(networks.ROUTER_CONFIGURATION_TYPE_KEY,
                             'not_configured')
     }
示例#3
0
 def get_initial(self):
     """Return initial data for the form."""
     return {
         'internet_connection_type':
         kvstore.get_default(networks.INTERNET_CONNECTION_TYPE_KEY,
                             'unknown')
     }
示例#4
0
def certificate_get_last_seen_modified_time(lineage):
    """Return the last seen expiry date of a certificate."""
    from plinth import kvstore
    info = kvstore.get_default('letsencrypt_certificate_info', '{}')
    info = json.loads(info)
    try:
        return info[str(lineage)]['last_seen_modified_time']
    except KeyError:
        return 0
示例#5
0
def is_completed():
    """Return whether first boot process is completed."""
    from plinth import kvstore

    global _is_completed
    if _is_completed is None:
        _is_completed = kvstore.get_default('firstboot_completed', 0)

    return bool(_is_completed)
示例#6
0
    def dispatch(self, request, *args, **kwargs):
        """Don't show wizard step if FreedomBox is not behind a router."""
        network_topology = kvstore.get_default(
            networks.NETWORK_TOPOLOGY_TYPE_KEY, 'to_router')
        if network_topology != 'to_router':
            first_boot.mark_step_done('router_setup_wizard')
            return HttpResponseRedirect(reverse_lazy(first_boot.next_step()))

        return super().dispatch(request, *args, *kwargs)
示例#7
0
def is_completed():
    """Return whether first boot process is completed."""
    from plinth import kvstore

    global _is_completed
    if _is_completed is None:
        _is_completed = kvstore.get_default('firstboot_completed', 0)

    return bool(_is_completed)
示例#8
0
def index(request):
    """Show connection list."""
    connections = network.get_connection_list()

    network_topology = kvstore.get_default(networks.NETWORK_TOPOLOGY_TYPE_KEY,
                                           'to_router')
    internet_connection_type = kvstore.get_default(
        networks.INTERNET_CONNECTION_TYPE_KEY, 'unknown')
    return TemplateResponse(
        request, 'networks_configuration.html', {
            'app_id': 'networks',
            'app_info': networks.app.info,
            'title': _('Network Connections'),
            'has_diagnostics': True,
            'is_enabled': True,
            'connections': connections,
            'network_topology': network_topology,
            'internet_connectivity_type': internet_connection_type,
        })
示例#9
0
def next_step_or_none():
    """Return the next first boot step required to run.

    If there are no more step remaining, return None.
    """
    from plinth import kvstore

    for step in _get_steps():
        done = kvstore.get_default(step['id'], 0)
        if not done:
            return step.get('url')
示例#10
0
def next_step_or_none():
    """Return the next first boot step required to run.

    If there are no more step remaining, return None.
    """
    from plinth import kvstore

    for step in _get_steps():
        done = kvstore.get_default(step['id'], 0)
        if not done:
            return step.get('url')
示例#11
0
    def process_request(request):
        """Handle a request as Django middleware request handler."""
        state = kvstore.get_default('firstboot_state', 0)
        firstboot_index_url = reverse('first_boot:index')
        user_requests_firstboot = request.path.startswith(firstboot_index_url)

        # Setup is complete: Forbid accessing firstboot
        if state >= 10 and user_requests_firstboot:
            return HttpResponseRedirect(reverse('index'))

        # Setup is not complete: Forbid accessing anything but firstboot
        if state < 10 and not user_requests_firstboot:
            return HttpResponseRedirect(reverse('first_boot:state%d' % state))
示例#12
0
文件: store.py 项目: JoKeyser/Plinth
def get_storages(storage_type=None):
    """Get all repositories from store."""
    storages = kvstore.get_default(STORAGE_KEY, {})
    if storages:
        storages = json.loads(storages)

    if storage_type:
        storages = {
            uuid: storage
            for uuid, storage in storages.items()
            if storage['storage_type'] == storage_type
        }

    return storages
示例#13
0
def certificate_set_last_seen_modified_time(lineage):
    """Write to store a certificate's last seen expiry date."""
    lineage = pathlib.Path(lineage)
    output = actions.superuser_run(
        'letsencrypt', ['get-modified-time', '--domain', lineage.name])
    modified_time = int(output)

    from plinth import kvstore
    info = kvstore.get_default('letsencrypt_certificate_info', '{}')
    info = json.loads(info)

    certificate_info = info.setdefault(str(lineage), {})
    certificate_info['last_seen_modified_time'] = modified_time

    kvstore.set('letsencrypt_certificate_info', json.dumps(info))
示例#14
0
def is_backports_requested():
    """Return whether user has chosen to activate backports."""
    from plinth import kvstore
    return kvstore.get_default(BACKPORTS_REQUESTED_KEY, False)
示例#15
0
 def is_enabled(self):
     """Return whether all leader components are enabled and flag is set."""
     from plinth import kvstore
     enabled = super().is_enabled()
     return enabled and kvstore.get_default('wireguard-enabled', False)
示例#16
0
def get_advanced_mode():
    """Get whether option is enabled."""
    from plinth import kvstore
    return kvstore.get_default(ADVANCED_MODE_KEY, False)
示例#17
0
 def is_enabled(self):
     """Return whether the app/component is enabled."""
     from plinth import kvstore
     return kvstore.get_default(self.key, False)
示例#18
0
def test_get_default():
    """Verify that either a set value or its default can be retrieved."""
    expected = 'default'
    actual = kvstore.get_default('bad_key', expected)
    assert expected == actual
示例#19
0
def get_internet_connection_type():
    """Return the currently configured internet connection type or default."""
    return kvstore.get_default('networks_internet_type', 'unknown')
示例#20
0
 def test_get_default(self):
     """Verify that either a set value or its default can be retrieved."""
     expected = 'default'
     actual = kvstore.get_default('bad_key', expected)
     self.assertEqual(expected, actual)
示例#21
0
 def test_get_default(self):
     """Verify that either a set value or its default can be retrieved."""
     expected = 'default'
     actual = kvstore.get_default('bad_key', expected)
     self.assertEqual(expected, actual)
示例#22
0
def get_router_configuration_type():
    """Return the currently configured router configuration type or default."""
    return kvstore.get_default('networks_router_configuration_type',
                               'not_configured')
示例#23
0
def get_network_topology_type():
    """Return the currently configured network topology type or default."""
    return kvstore.get_default('networks_topology_type', 'to_router')
def firstboot_is_finished():
    """Return whether firstboot process is completed."""
    state = kvstore.get_default('firstboot_state', 0)
    return state >= 10
示例#25
0
def is_dist_upgrade_enabled():
    """Return whether user has enabled dist upgrade."""
    return kvstore.get_default(DIST_UPGRADE_ENABLED_KEY, False)