1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-01-09 14:28:03 +00:00
py-i2phosts/py-i2phosts-builder
Hidden Z 16b875177f py-i2phosts-builder: bugfix: add newline after each record
Since 2858ba6084 base64 hashes appearing
in DB without newlines, so fix builder behavior.
2010-10-24 16:15:51 +00:00

22 lines
561 B
Python
Executable File

#!/usr/bin/python
import os
import sys
# django setup
DJANGO_SETTINGS_MODULE = 'settings'
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/web'
sys.path.insert(1, DJANGO_PROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
from web.postkey.models import i2phost
# result hosts.txt
hostsfile = 'hosts.txt'
f = open(hostsfile, 'w')
# select name and hash for all activated hosts
l = i2phost.objects.filter(activated=True).values('name', 'b64hash')
for entry in l:
f.write(entry['name'] + '=' + entry['b64hash'] + '\n')
f.close()