forked from freedomofpress/securedrop-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_dev_data.py
executable file
·41 lines (36 loc) · 1.17 KB
/
create_dev_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
import json
import os
from sqlalchemy.orm.exc import NoResultFound
import sys
from securedrop_client.config import Config
from securedrop_client import db
sdc_home = sys.argv[1]
session = db.make_session_maker(sdc_home)()
db.Base.metadata.create_all(bind=session.get_bind())
with open(os.path.join(sdc_home, Config.CONFIG_NAME), "w") as f:
f.write(
json.dumps(
{"journalist_key_fingerprint": "65A1B5FF195B56353CC63DFFCC40EF1228271441"}
)
)
for reply_send_status in db.ReplySendStatusCodes:
try:
reply_status = (
session.query(db.ReplySendStatus)
.filter_by(name=reply_send_status.value)
.one()
)
except NoResultFound:
reply_status = db.ReplySendStatus(reply_send_status.value)
session.add(reply_status)
session.commit()
for download_error in db.DownloadErrorCodes:
try:
download_error = (
session.query(db.DownloadError).filter_by(name=download_error.name).one()
)
except NoResultFound:
download_error = db.DownloadError(download_error.name)
session.add(download_error)
session.commit()