mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
ttrss: Minor refactoring
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
028a3ad207
commit
00d8e03d90
@ -77,18 +77,23 @@ def enable_api_access():
|
|||||||
import psycopg2 # Only available post installation
|
import psycopg2 # Only available post installation
|
||||||
|
|
||||||
aug = load_augeas()
|
aug = load_augeas()
|
||||||
dbuser = aug.get('/files' + DATABASE_FILE + '/$dbuser').strip("'")
|
|
||||||
dbpass = aug.get('/files' + DATABASE_FILE + '/$dbpass').strip("'")
|
def get_value(variable_name):
|
||||||
dbname = aug.get('/files' + DATABASE_FILE + '/$dbname').strip("'")
|
"""Return the value of a variable from database configuration file."""
|
||||||
dbserver = aug.get('/files' + DATABASE_FILE + '/$dbserver').strip("'")
|
return aug.get('/files' + DATABASE_FILE + '/$' + variable_name) \
|
||||||
|
.strip("'\"")
|
||||||
|
|
||||||
|
user = get_value('dbuser')
|
||||||
|
password = get_value('dbpass')
|
||||||
|
database = get_value('dbname')
|
||||||
|
host = get_value('dbserver')
|
||||||
|
|
||||||
connection = psycopg2.connect(
|
connection = psycopg2.connect(
|
||||||
database=dbname, user=dbuser, password=dbpass, host=dbserver)
|
database=database, user=user, password=password, host=host)
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
cursor.execute(
|
cursor.execute("UPDATE ttrss_prefs SET def_value=true "
|
||||||
"update ttrss_prefs set def_value=true \
|
"WHERE pref_name='ENABLE_API_ACCESS';")
|
||||||
where pref_name='ENABLE_API_ACCESS';")
|
|
||||||
|
|
||||||
connection.commit()
|
connection.commit()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user