fetchphones progress not working
This commit is contained in:
parent
7a9e31a8d3
commit
8f8b337e27
2 changed files with 45 additions and 19 deletions
25
Readme.md
25
Readme.md
|
@ -6,16 +6,15 @@
|
||||||
```
|
```
|
||||||
git clone https://git.lattuga.net/d0c/suitablephones.git
|
git clone https://git.lattuga.net/d0c/suitablephones.git
|
||||||
virtualenv .
|
virtualenv .
|
||||||
bin/pip install -r requirements.txt
|
source bin/activate
|
||||||
bin/python manage.py migrate
|
pip install -r requirements.txt
|
||||||
bin/python manage.py createsuperuser
|
python manage.py migrate
|
||||||
bin/python manage.py runserver
|
python manage.py createsuperuser
|
||||||
```
|
```
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
Download Lineage official wiki as data source.
|
Download Lineage official wiki as data source.
|
||||||
Yaml file descripting all devices are in _"lineage_wiki/_data/devices/"_
|
Yaml files descripting all devices are in _"lineage_wiki/_data/devices/"_
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com/LineageOS/lineage_wiki.git
|
git clone https://github.com/LineageOS/lineage_wiki.git
|
||||||
|
@ -27,3 +26,15 @@ es.
|
||||||
```
|
```
|
||||||
LINEAGEWIKI = '/home/d0c/lineage_wiki'
|
LINEAGEWIKI = '/home/d0c/lineage_wiki'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Populate database:
|
||||||
|
```
|
||||||
|
python manage.py fetchphones
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Run
|
||||||
|
|
||||||
|
```
|
||||||
|
python manage.py runserver
|
||||||
|
```
|
|
@ -6,31 +6,46 @@ from django.core.management.base import BaseCommand, CommandError
|
||||||
|
|
||||||
from suitablephones.models import Bluetooth, Camera, Device
|
from suitablephones.models import Bluetooth, Camera, Device
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'Closes the specified poll for voting'
|
help = 'Aiuto'
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
#def add_arguments(self, parser):
|
||||||
parser.add_argument('poll_ids', nargs='+', type=int)
|
# parser.add_argument('poll_ids', nargs='+', type=int)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
Device.objects.all().delete()
|
Device.objects.all().delete()
|
||||||
Bluetooth.objects.all().delete()
|
Bluetooth.objects.all().delete()
|
||||||
Camera.objects.all().delete()
|
Camera.objects.all().delete()
|
||||||
for filename in os.listdir(settings.LINEAGEWIKI + "/_data/devices/"):
|
devicesdir = settings.LINEAGEWIKI + "/_data/devices/"
|
||||||
with open(filename, "r") as stream:
|
for filename in os.listdir(devicesdir):
|
||||||
|
with open(os.path.join(devicesdir, filename), "r") as stream:
|
||||||
try:
|
try:
|
||||||
data = yaml.safe_load(stream)
|
data = yaml.safe_load(stream)
|
||||||
dev = Device()
|
dev = Device()
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
if key == "cameras":
|
if key == "bluetooth":
|
||||||
cam = Camera.objects.filter(*value.items())
|
bt = Bluetooth.objects.filter(*value.items())
|
||||||
if not cam.exists():
|
if not bt.exists():
|
||||||
cam = Camera()
|
bt = Bluetooth()
|
||||||
for subkey, subvalue in value.items():
|
for subkey, subvalue in value.items():
|
||||||
cam
|
bt
|
||||||
for subkey in value.items():
|
for subkey, subvalue in value.items():
|
||||||
setattr(cam, subkey, subvalue)
|
#logging.warning(type(subkey))
|
||||||
|
#logging.warning(subkey)
|
||||||
|
#print(type(subvalue) + subvalue)
|
||||||
|
setattr(bt, subkey, subvalue)
|
||||||
|
# elif key == "cameras":
|
||||||
|
# cam = []
|
||||||
|
# for c in Camera.objects.filter(*value.items())
|
||||||
|
# cam.append(c)
|
||||||
|
# if not cam.exists():
|
||||||
|
# cam = Camera()
|
||||||
|
# for subkey, subvalue in value.items():
|
||||||
|
# cam
|
||||||
|
# for subkey, subvalue in value.items():
|
||||||
|
# setattr(cam, subkey, subvalue)
|
||||||
else:
|
else:
|
||||||
setattr(dev, key, value)
|
setattr(dev, key, value)
|
||||||
dev.save()
|
dev.save()
|
||||||
|
|
Loading…
Reference in a new issue