Merge branch 'master' of git.0x2620.org:/dd-re
This commit is contained in:
commit
52d87d4265
6 changed files with 31 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
json/*
|
json/*
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
*.swp
|
||||||
|
|
8
README.md
Normal file
8
README.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# Recommendation Engine Example
|
||||||
|
|
||||||
|
## Install dependencies and run:
|
||||||
|
|
||||||
|
python3 -m venv ./venv --system-site-packages
|
||||||
|
./venv/bin/pip install -r requirements.txt
|
||||||
|
|
||||||
|
./venv/bin/python server.py
|
13
etc/systemd/system/dd-re.service
Normal file
13
etc/systemd/system/dd-re.service
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=dd-re
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
Restart=always
|
||||||
|
User=dd
|
||||||
|
Group=dd
|
||||||
|
WorkingDirectory=/srv/dd/re
|
||||||
|
ExecStart=/srv/dd/re/server.py
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -9,6 +9,8 @@ import random
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
|
|
||||||
|
from utils import run_async
|
||||||
|
|
||||||
class Engine:
|
class Engine:
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
|
@ -111,6 +113,10 @@ class Engine:
|
||||||
with open(os.path.join(self.path, 'playlists.json'), 'w') as f:
|
with open(os.path.join(self.path, 'playlists.json'), 'w') as f:
|
||||||
f.write(json.dumps(self.playlists, indent=4, sort_keys=True))
|
f.write(json.dumps(self.playlists, indent=4, sort_keys=True))
|
||||||
|
|
||||||
|
@run_async
|
||||||
|
def update_async(self):
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
|
||||||
class Pandora:
|
class Pandora:
|
||||||
|
|
||||||
|
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
tornado
|
||||||
|
ox
|
7
server.py
Executable file → Normal file
7
server.py
Executable file → Normal file
|
@ -94,12 +94,7 @@ def main(prefix='json/'):
|
||||||
app.listen(settings['port'], settings['address'])
|
app.listen(settings['port'], settings['address'])
|
||||||
main = IOLoop.instance()
|
main = IOLoop.instance()
|
||||||
|
|
||||||
@run_async
|
update_cb = PeriodicCallback(engine.update_async, 15*60*1000)
|
||||||
def update():
|
|
||||||
engine.update()
|
|
||||||
|
|
||||||
update_cb = PeriodicCallback(update, 60000)
|
|
||||||
|
|
||||||
#main.spawn_callback(update, engine)
|
#main.spawn_callback(update, engine)
|
||||||
|
|
||||||
#fixme run periodically
|
#fixme run periodically
|
||||||
|
|
Loading…
Reference in a new issue