Add setup (this is only temporary for the hackathon)
This commit is contained in:
parent
f83a5e90ae
commit
447a52b684
7 changed files with 10936 additions and 2 deletions
12
README.md
12
README.md
|
@ -10,3 +10,15 @@ There is a [changelog](CHANGELOG.md) available with the most important changes d
|
|||
*Please note that this project is released with a [Code of Conduct](CODE_OF_CONDUCT.md) that applies to all project-related communication. By participating in this project you agree to abide by its terms.*
|
||||
|
||||
*You can support c3nav development [on Patreon](https://www.patreon.com/c3nav).*
|
||||
|
||||
## Setup guide for Hackathon Schenna
|
||||
|
||||
- `./install.sh` installs the env
|
||||
- `./start_db.sh` recreates the DB and runs the server
|
||||
- `./start_db.sh skipdb` runs the server without recreating the DB
|
||||
|
||||
<!-- - `./start_db.sh` to setup a local psql docker db
|
||||
- `export C3NAV_DATABASE=postgres://mindshub:test@localhost:5432/insignorocketdb` in the repo (otherwise server uses sqlite!)
|
||||
- Follow https://github.com/c3nav/c3nav/wiki#install-as-local-small-instance-without-containers (as local small instance without containers)
|
||||
- `yay -S librsvg`
|
||||
- `pip install psycopg2` to use Postgresql -->
|
||||
|
|
85
auth_user.sql
Normal file
85
auth_user.sql
Normal file
|
@ -0,0 +1,85 @@
|
|||
--
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 17.5 (Debian 17.5-1.pgdg120+1)
|
||||
-- Dumped by pg_dump version 17.5
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
SET transaction_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SELECT pg_catalog.set_config('search_path', '', false);
|
||||
SET check_function_bodies = false;
|
||||
SET xmloption = content;
|
||||
SET client_min_messages = warning;
|
||||
SET row_security = off;
|
||||
|
||||
SET default_tablespace = '';
|
||||
|
||||
SET default_table_access_method = heap;
|
||||
|
||||
--
|
||||
-- Name: auth_user; Type: TABLE; Schema: public; Owner: mindshub
|
||||
--
|
||||
|
||||
CREATE TABLE public.auth_user (
|
||||
id integer NOT NULL,
|
||||
password character varying(128) NOT NULL,
|
||||
last_login timestamp with time zone,
|
||||
is_superuser boolean NOT NULL,
|
||||
username character varying(150) NOT NULL,
|
||||
first_name character varying(150) NOT NULL,
|
||||
last_name character varying(150) NOT NULL,
|
||||
email character varying(254) NOT NULL,
|
||||
is_staff boolean NOT NULL,
|
||||
is_active boolean NOT NULL,
|
||||
date_joined timestamp with time zone NOT NULL
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.auth_user OWNER TO mindshub;
|
||||
|
||||
--
|
||||
-- Name: auth_user_id_seq; Type: SEQUENCE; Schema: public; Owner: mindshub
|
||||
--
|
||||
|
||||
ALTER TABLE public.auth_user ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
|
||||
SEQUENCE NAME public.auth_user_id_seq
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: auth_user auth_user_pkey; Type: CONSTRAINT; Schema: public; Owner: mindshub
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.auth_user
|
||||
ADD CONSTRAINT auth_user_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: auth_user auth_user_username_key; Type: CONSTRAINT; Schema: public; Owner: mindshub
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.auth_user
|
||||
ADD CONSTRAINT auth_user_username_key UNIQUE (username);
|
||||
|
||||
|
||||
--
|
||||
-- Name: auth_user_username_6821ab7c_like; Type: INDEX; Schema: public; Owner: mindshub
|
||||
--
|
||||
|
||||
CREATE INDEX auth_user_username_6821ab7c_like ON public.auth_user USING btree (username varchar_pattern_ops);
|
||||
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
10780
dump.sql
Normal file
10780
dump.sql
Normal file
File diff suppressed because one or more lines are too long
10
install.sh
Executable file
10
install.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
set -e
|
||||
|
||||
# python3 -m venv .env
|
||||
# source ./.env/bin/activate
|
||||
# pip install -r src/requirements/production.txt -r src/requirements/dev.txt
|
||||
# pip install psycopg2
|
||||
# sudo pacman -Sy librsvg
|
||||
|
||||
./start_db.sh db
|
||||
./start_db.sh stop
|
2
src/c3nav/mapdata/utils/cache/indexed.py
vendored
2
src/c3nav/mapdata/utils/cache/indexed.py
vendored
|
@ -65,7 +65,7 @@ class GeometryIndexed:
|
|||
cls._read_metadata(f, kwargs)
|
||||
|
||||
# noinspection PyTypeChecker
|
||||
kwargs['data'] = np.fromstring(f.read(width * height * cls.dtype().itemsize), cls.dtype).reshape(
|
||||
kwargs['data'] = np.frombuffer(f.read(width * height * cls.dtype().itemsize), cls.dtype).reshape(
|
||||
(height, width))
|
||||
return cls(**kwargs)
|
||||
|
||||
|
|
2
src/c3nav/mapdata/utils/cache/local.py
vendored
2
src/c3nav/mapdata/utils/cache/local.py
vendored
|
@ -28,7 +28,7 @@ class LocalCacheProxy:
|
|||
try:
|
||||
# first check out cache
|
||||
result = self._items.get()[key]
|
||||
except KeyError:
|
||||
except (KeyError, LookupError):
|
||||
# not in our cache
|
||||
result = cache.get(key, default=NoneFromCache)
|
||||
if result is not NoneFromCache:
|
||||
|
|
47
start_db.sh
Executable file
47
start_db.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
set -o xtrace # print commands being executed
|
||||
|
||||
source ./.env/bin/activate
|
||||
export C3NAV_DATABASE=postgres://mindshub:test@localhost:5432/insignorocketdb
|
||||
export C3NAV_DEBUG=True
|
||||
|
||||
if [[ $# == 0 ]] || [[ $1 != "skipdb" ]]; then
|
||||
|
||||
sudo docker stop postgres
|
||||
sudo docker container rm -f postgres
|
||||
if [[ $# == 1 ]] && [[ $1 == "stop" ]]; then
|
||||
echo "Just stopping the postgres container"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
sudo docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=test -e POSTGRES_USER=mindshub postgres
|
||||
until psql "postgres://mindshub:test@localhost:5432" <<< "CREATE DATABASE insignorocketdb;"; do
|
||||
sleep 0.5;
|
||||
done;
|
||||
psql "postgres://mindshub:test@localhost:5432/insignorocketdb" < auth_user.sql
|
||||
psql "postgres://mindshub:test@localhost:5432/insignorocketdb" < dump.sql
|
||||
pushd src
|
||||
python manage.py migrate
|
||||
python manage.py processupdates
|
||||
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | python manage.py shell
|
||||
popd
|
||||
|
||||
#& $($(echo "$(cargo tarpaulin --print-rust-flags --target-dir=target/tarpaulin)" | grep -v INFO)) cargo build
|
||||
#$(cargo tarpaulin --print-rust-flags | grep -v INFO)
|
||||
#cargo tarpaulin --command build --skip-clean --target-dir=target/tarpaulin
|
||||
#DATABASE_URL=
|
||||
|
||||
if [[ $# != 1 ]]; then
|
||||
# terminate gracefully when the user uses Ctrl+C (unless an argument was passed)
|
||||
#trap 'sudo docker stop postgres; sudo docker container rm -f postgres; exit' INT
|
||||
echo
|
||||
elif [[ $1 == "db" ]]; then
|
||||
echo "Skipping tests and leaving database open"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
pushd src
|
||||
python manage.py runserver
|
||||
popd
|
Loading…
Add table
Add a link
Reference in a new issue