Skip to content

Commit

Permalink
Revert the in-progress country selection work
Browse files Browse the repository at this point in the history
Moved to it's own branch.
  • Loading branch information
davesteele committed Sep 7, 2023
1 parent 23a8f32 commit 40f755d
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 140 deletions.
47 changes: 0 additions & 47 deletions comitup/crda.py

This file was deleted.

1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"web/templates/index.html",
"web/templates/connect.html",
"web/templates/confirm.html",
"web/templates/countries.js",
],
),
(
Expand Down
56 changes: 0 additions & 56 deletions test/test_crda.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,3 @@
# License-Filename: LICENSE
#

from pathlib import Path
from typing import NamedTuple

import pytest

from comitup.crda import crda_get, crda_put


class TestCase(NamedTuple):
teststr: str
result: str


read_cases = [
TestCase("", ""),
TestCase("REGDOMAIN=", ""),
TestCase("REGDOMAIN=US", "US"),
TestCase("REGDOMAIN = US", "US"),
TestCase("REGDOMAIN=US ", "US"),
TestCase("foo\nREGDOMAIN=US\nfoo", "US"),
]


@pytest.fixture(params=read_cases)
def crda_env(request, tmp_path):
case = request.param
crda_path = tmp_path / "crda"
crda_path.write_text(case.teststr)

class CrdaFixtureCase(NamedTuple):
path: Path
result: str

return CrdaFixtureCase(crda_path, case.result)


def test_crda_null():
pass


def test_crda_get(crda_env):
assert crda_get(str(crda_env.path)) == crda_env.result


def test_crda_put(crda_env):
crda_put("CA", path=str(crda_env.path))

assert crda_get(path=str(crda_env.path)) == "CA"


def test_crda_nofile_put(crda_env):
crda_put("CA", path=str(crda_env.path.parent / "bogus"))


def test_crda_nofile_get(crda_env):
crda_get(path=str(crda_env.path.parent / "bogus"))
21 changes: 2 additions & 19 deletions web/comitupweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@
# or later
#

import json
import logging
import sys
import time
import urllib
from logging.handlers import TimedRotatingFileHandler
from multiprocessing import Process
from pathlib import Path

from cachetools import TTLCache, cached
from flask import (
Expand All @@ -39,13 +37,6 @@
ciu_client = None # type: ignore
LOG_PATH = "/var/log/comitup-web.log"
TEMPLATE_PATH = "/usr/share/comitup/web/templates"
SERVER_PORT = 80
DEBUG = False

# LOG_PATH = "/tmp/comitup-web.log"
# TEMPLATE_PATH = "./templates"
# SERVER_PORT = 8000
# DEBUG=True

ttl_cache: TTLCache = TTLCache(maxsize=10, ttl=5)

Expand Down Expand Up @@ -96,16 +87,8 @@ def index():
point["ssid"]
)
log.info("index.html - {} points".format(len(points)))

with open(str(Path(TEMPLATE_PATH) / "countries.json"), "r") as fp:
countries = json.load(fp)

return render_template(
"index.html",
points=points,
can_blink=ciu.can_blink(),
default_country="",
countries=countries,
"index.html", points=points, can_blink=ciu.can_blink()
)

@app.route("/confirm")
Expand Down Expand Up @@ -193,7 +176,7 @@ def main():
ciu_client.ciu_points()

app = create_app(log)
app.run(host="0.0.0.0", port=SERVER_PORT, debug=DEBUG, threaded=True)
app.run(host="0.0.0.0", port=80, debug=False, threaded=True)


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion web/templates/countries.json

This file was deleted.

16 changes: 0 additions & 16 deletions web/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,6 @@
{% endif %}
</div>
</div>
<div class="uk-width-1-1 uk-text-center">
<p class="uk-text-large">Set the WiFi country code</p>
</div>
<form action="/country" method="get">
<div class="uk-grid uk-grid-small">
<div class="uk-width-2-3">
<input class="uk-input" list="countries" name="country" id="country" value="United States of America" autocomplete="on">
<datalist id="countries">{% for country in countries %}
<option value="{{ country.name }}"/>{% endfor %}
</datalist>
</div>
<div class="uk-width-1-3">
<button type="submit" value="submit" class="uk-button uk-button-primary uk-width-expand">Submit</button>
</div>
</div>
</form>
</div>
</div>

Expand Down

0 comments on commit 40f755d

Please sign in to comment.