Fix database creation;
Thank you. roughnecks.
This commit is contained in:
parent
13b7c94f17
commit
5fe4e3b211
9 changed files with 54 additions and 59 deletions
|
@ -52,7 +52,7 @@ class Feed:
|
||||||
os.mkdir(dir_cache + '/' + ext)
|
os.mkdir(dir_cache + '/' + ext)
|
||||||
filename = os.path.join(
|
filename = os.path.join(
|
||||||
dir_cache, ext, 'slixfeed_' + DateAndTime.timestamp() + '.' + ext)
|
dir_cache, ext, 'slixfeed_' + DateAndTime.timestamp() + '.' + ext)
|
||||||
db_file = os.path.join(dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(dir_data, jid_bare)
|
||||||
results = sqlite.get_feeds(db_file)
|
results = sqlite.get_feeds(db_file)
|
||||||
match ext:
|
match ext:
|
||||||
# case 'html':
|
# case 'html':
|
||||||
|
@ -1273,7 +1273,7 @@ class FeedTask:
|
||||||
# print('Scanning for updates for JID {}'.format(jid_bare))
|
# print('Scanning for updates for JID {}'.format(jid_bare))
|
||||||
logger.info('Scanning for updates for JID {}'.format(jid_bare))
|
logger.info('Scanning for updates for JID {}'.format(jid_bare))
|
||||||
while True:
|
while True:
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
urls = sqlite.get_active_feeds_url_sorted_by_last_scanned(db_file)
|
urls = sqlite.get_active_feeds_url_sorted_by_last_scanned(db_file)
|
||||||
for url in urls:
|
for url in urls:
|
||||||
#Message.printer('Scanning updates for URL {} ...'.format(url))
|
#Message.printer('Scanning updates for URL {} ...'.format(url))
|
||||||
|
|
|
@ -48,6 +48,7 @@ import os
|
||||||
import random
|
import random
|
||||||
import slixfeed.fetch as fetch
|
import slixfeed.fetch as fetch
|
||||||
from slixfeed.log import Logger
|
from slixfeed.log import Logger
|
||||||
|
import slixfeed.sqlite as sqlite
|
||||||
import sys
|
import sys
|
||||||
from urllib.parse import (
|
from urllib.parse import (
|
||||||
parse_qs,
|
parse_qs,
|
||||||
|
@ -138,31 +139,23 @@ class Config:
|
||||||
class Database:
|
class Database:
|
||||||
|
|
||||||
|
|
||||||
def instantiate(jid_bare):
|
def instantiate(dir_data, jid_bare):
|
||||||
"""
|
"""
|
||||||
Callback function to instantiate action on database.
|
Instantiate action on database and return its filename location.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
|
dir_data : str
|
||||||
|
Directory.
|
||||||
jid_file : str
|
jid_file : str
|
||||||
Filename.
|
Jabber ID.
|
||||||
callback : ?
|
|
||||||
Function name.
|
|
||||||
message : str, optional
|
|
||||||
Optional kwarg when a message is a part or
|
|
||||||
required argument. The default is None.
|
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
object
|
db_file
|
||||||
Coroutine object.
|
Filename.
|
||||||
"""
|
"""
|
||||||
db_dir = Config.get_default_data_directory()
|
db_file = os.path.join(dir_data, 'sqlite', f'{jid_bare}.db')
|
||||||
if not os.path.isdir(db_dir):
|
|
||||||
os.mkdir(db_dir)
|
|
||||||
if not os.path.isdir(db_dir + "/sqlite"):
|
|
||||||
os.mkdir(db_dir + "/sqlite")
|
|
||||||
db_file = os.path.join(db_dir, "sqlite", r"{}.db".format(jid_bare))
|
|
||||||
sqlite.create_tables(db_file)
|
sqlite.create_tables(db_file)
|
||||||
return db_file
|
return db_file
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
__version__ = '0.1.105'
|
__version__ = '0.1.106'
|
||||||
__version_info__ = (0, 1, 105)
|
__version_info__ = (0, 1, 106)
|
||||||
|
|
|
@ -33,7 +33,7 @@ from slixfeed.fetch import Http
|
||||||
from slixfeed.log import Logger
|
from slixfeed.log import Logger
|
||||||
import slixfeed.sqlite as sqlite
|
import slixfeed.sqlite as sqlite
|
||||||
from slixfeed.syndication import FeedTask
|
from slixfeed.syndication import FeedTask
|
||||||
from slixfeed.utilities import Documentation, Html, MD, Task, Url
|
from slixfeed.utilities import Database, Documentation, Html, MD, Task, Url
|
||||||
from slixfeed.xmpp.commands import XmppCommands
|
from slixfeed.xmpp.commands import XmppCommands
|
||||||
from slixfeed.xmpp.message import XmppMessage
|
from slixfeed.xmpp.message import XmppMessage
|
||||||
from slixfeed.xmpp.presence import XmppPresence
|
from slixfeed.xmpp.presence import XmppPresence
|
||||||
|
@ -130,7 +130,7 @@ class XmppChat:
|
||||||
return
|
return
|
||||||
|
|
||||||
response = None
|
response = None
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
match command_lowercase:
|
match command_lowercase:
|
||||||
case 'help':
|
case 'help':
|
||||||
|
|
||||||
|
@ -635,7 +635,7 @@ class XmppChatAction:
|
||||||
"""
|
"""
|
||||||
function_name = sys._getframe().f_code.co_name
|
function_name = sys._getframe().f_code.co_name
|
||||||
logger.debug(f'{function_name}: jid: {jid_bare} num: {num}')
|
logger.debug(f'{function_name}: jid: {jid_bare} num: {num}')
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
encrypt_omemo = Config.get_setting_value(self, jid_bare, 'omemo')
|
encrypt_omemo = Config.get_setting_value(self, jid_bare, 'omemo')
|
||||||
encrypted = True if encrypt_omemo else False
|
encrypted = True if encrypt_omemo else False
|
||||||
jid = JID(jid_bare)
|
jid = JID(jid_bare)
|
||||||
|
@ -875,7 +875,7 @@ class XmppChatTask:
|
||||||
|
|
||||||
|
|
||||||
async def task_message(self, jid_bare):
|
async def task_message(self, jid_bare):
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -51,7 +51,7 @@ import slixfeed.fetch as fetch
|
||||||
from slixfeed.log import Logger
|
from slixfeed.log import Logger
|
||||||
import slixfeed.sqlite as sqlite
|
import slixfeed.sqlite as sqlite
|
||||||
from slixfeed.syndication import Feed, FeedDiscovery, FeedTask, Opml
|
from slixfeed.syndication import Feed, FeedDiscovery, FeedTask, Opml
|
||||||
from slixfeed.utilities import DateAndTime, Html, String, Task, Toml, Url, Utilities
|
from slixfeed.utilities import Database, DateAndTime, Html, String, Task, Toml, Url, Utilities
|
||||||
from slixfeed.version import __version__
|
from slixfeed.version import __version__
|
||||||
from slixfeed.xmpp.bookmark import XmppBookmark
|
from slixfeed.xmpp.bookmark import XmppBookmark
|
||||||
from slixfeed.xmpp.chat import XmppChat, XmppChatTask
|
from slixfeed.xmpp.chat import XmppChat, XmppChatTask
|
||||||
|
@ -429,7 +429,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
for result in await XmppPubsub.get_pubsub_services(self):
|
for result in await XmppPubsub.get_pubsub_services(self):
|
||||||
jid_bare = result['jid']
|
jid_bare = result['jid']
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
#await XmppPubsubTask.task_publish(self, jid_bare)
|
#await XmppPubsubTask.task_publish(self, jid_bare)
|
||||||
#await FeedTask.check_updates(self, jid_bare)
|
#await FeedTask.check_updates(self, jid_bare)
|
||||||
|
@ -491,7 +491,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
message_log = '{}: jid_full: {}'
|
message_log = '{}: jid_full: {}'
|
||||||
logger.debug(message_log.format(function_name, jid_full))
|
logger.debug(message_log.format(function_name, jid_full))
|
||||||
jid_bare = message['from'].bare
|
jid_bare = message['from'].bare
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
if jid_bare == self.boundjid.bare:
|
if jid_bare == self.boundjid.bare:
|
||||||
|
@ -1130,7 +1130,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid_bare)
|
value=jid_bare)
|
||||||
num = 100
|
num = 100
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
results = sqlite.get_entries(db_file, num)
|
results = sqlite.get_entries(db_file, num)
|
||||||
subtitle = 'Recent {} updates'.format(num)
|
subtitle = 'Recent {} updates'.format(num)
|
||||||
if results:
|
if results:
|
||||||
|
@ -1392,7 +1392,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
logger.debug('{}: jid_full: {}'
|
logger.debug('{}: jid_full: {}'
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
form = self['xep_0004'].make_form('form', 'Profile')
|
form = self['xep_0004'].make_form('form', 'Profile')
|
||||||
|
@ -1489,7 +1489,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
chat_type = await XmppUtilities.get_chat_type(self, jid_bare)
|
chat_type = await XmppUtilities.get_chat_type(self, jid_bare)
|
||||||
if XmppUtilities.is_access(self, jid, chat_type):
|
if XmppUtilities.is_access(self, jid, chat_type):
|
||||||
jid = session['from'].bare
|
jid = session['from'].bare
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
form = self['xep_0004'].make_form('form', 'Filters')
|
form = self['xep_0004'].make_form('form', 'Filters')
|
||||||
form['instructions'] = ('Filters allow you to skip news items '
|
form['instructions'] = ('Filters allow you to skip news items '
|
||||||
'that you may not be interested at. Use '
|
'that you may not be interested at. Use '
|
||||||
|
@ -1564,7 +1564,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
# form = self['xep_0004'].make_form('result', 'Done')
|
# form = self['xep_0004'].make_form('result', 'Done')
|
||||||
# form['instructions'] = ('✅️ Filters have been updated')
|
# form['instructions'] = ('✅️ Filters have been updated')
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
# In this case (as is typical), the payload is a form
|
# In this case (as is typical), the payload is a form
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
for key in values:
|
for key in values:
|
||||||
|
@ -1717,7 +1717,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
form.add_field(var='jid',
|
form.add_field(var='jid',
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid_bare)
|
value=jid_bare)
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
num = 100
|
num = 100
|
||||||
match values['action']:
|
match values['action']:
|
||||||
case 'all':
|
case 'all':
|
||||||
|
@ -1777,7 +1777,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
form.add_field(var='jid',
|
form.add_field(var='jid',
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid)
|
value=jid)
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
title = sqlite.get_entry_title(db_file, ix)
|
title = sqlite.get_entry_title(db_file, ix)
|
||||||
title = title[0] if title else 'Untitled'
|
title = title[0] if title else 'Untitled'
|
||||||
form['instructions'] = title
|
form['instructions'] = title
|
||||||
|
@ -1853,7 +1853,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
form.add_field(var='jid',
|
form.add_field(var='jid',
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid_bare)
|
value=jid_bare)
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if identifier and sqlite.check_identifier_exist(db_file, identifier):
|
if identifier and sqlite.check_identifier_exist(db_file, identifier):
|
||||||
form['title'] = 'Conflict'
|
form['title'] = 'Conflict'
|
||||||
form['instructions'] = ('Name "{}" already exists. Choose a '
|
form['instructions'] = ('Name "{}" already exists. Choose a '
|
||||||
|
@ -2056,7 +2056,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
if XmppUtilities.is_operator(self, jid_bare) and 'jid' in values:
|
if XmppUtilities.is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid_bare = values['jid'][0]
|
jid_bare = values['jid'][0]
|
||||||
del values['jid']
|
del values['jid']
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
for key in values:
|
for key in values:
|
||||||
value = 1 if values[key] else 0
|
value = 1 if values[key] else 0
|
||||||
await sqlite.set_enabled_status(db_file, key, value)
|
await sqlite.set_enabled_status(db_file, key, value)
|
||||||
|
@ -2081,7 +2081,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
if XmppUtilities.is_operator(self, jid_bare) and 'jid' in values:
|
if XmppUtilities.is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid_bare = values['jid'][0]
|
jid_bare = values['jid'][0]
|
||||||
del values['jid']
|
del values['jid']
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
subscriptions = ''
|
subscriptions = ''
|
||||||
ixs = values['subscriptions']
|
ixs = values['subscriptions']
|
||||||
for ix in ixs:
|
for ix in ixs:
|
||||||
|
@ -2314,7 +2314,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
form.add_field(ftype='hidden',
|
form.add_field(ftype='hidden',
|
||||||
value=jid_bare,
|
value=jid_bare,
|
||||||
var='jid')
|
var='jid')
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
match values['action']:
|
match values['action']:
|
||||||
case 'browse':
|
case 'browse':
|
||||||
form['instructions'] = 'Editing subscriptions'
|
form['instructions'] = 'Editing subscriptions'
|
||||||
|
@ -2408,7 +2408,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
form.add_field(ftype='hidden',
|
form.add_field(ftype='hidden',
|
||||||
value=jid_bare,
|
value=jid_bare,
|
||||||
var='jid')
|
var='jid')
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
tag_id = values['tag']
|
tag_id = values['tag']
|
||||||
tag_name = sqlite.get_tag_name(db_file, tag_id)[0]
|
tag_name = sqlite.get_tag_name(db_file, tag_id)[0]
|
||||||
form['instructions'] = 'Subscriptions tagged with "{}"'.format(tag_name)
|
form['instructions'] = 'Subscriptions tagged with "{}"'.format(tag_name)
|
||||||
|
@ -2446,7 +2446,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
form.add_field(ftype='hidden',
|
form.add_field(ftype='hidden',
|
||||||
value=jid_bare,
|
value=jid_bare,
|
||||||
var='jid')
|
var='jid')
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if 'subscription' in values: urls = values['subscription']
|
if 'subscription' in values: urls = values['subscription']
|
||||||
elif 'subscriptions' in values: urls = values['subscriptions']
|
elif 'subscriptions' in values: urls = values['subscriptions']
|
||||||
url_count = len(urls)
|
url_count = len(urls)
|
||||||
|
@ -2539,7 +2539,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
if XmppUtilities.is_operator(self, jid_bare) and 'jid' in values:
|
if XmppUtilities.is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid_bare = values['jid'][0]
|
jid_bare = values['jid'][0]
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
# url = values['url']
|
# url = values['url']
|
||||||
# feed_id = sqlite.get_feed_id(db_file, url)
|
# feed_id = sqlite.get_feed_id(db_file, url)
|
||||||
# feed_id = feed_id[0]
|
# feed_id = feed_id[0]
|
||||||
|
@ -2940,7 +2940,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
if XmppUtilities.is_operator(self, jid_bare) and 'jid' in values:
|
if XmppUtilities.is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid']
|
jid = values['jid']
|
||||||
jid_bare = jid[0] if isinstance(jid, list) else jid
|
jid_bare = jid[0] if isinstance(jid, list) else jid
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
result = await fetch.http(self.settings_network, url)
|
result = await fetch.http(self.settings_network, url)
|
||||||
count = await Opml.import_from_file(db_file, result)
|
count = await Opml.import_from_file(db_file, result)
|
||||||
try:
|
try:
|
||||||
|
@ -3465,7 +3465,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
if key:
|
if key:
|
||||||
jid_bare = key
|
jid_bare = key
|
||||||
value = values[key]
|
value = values[key]
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
await Config.set_setting_value(
|
await Config.set_setting_value(
|
||||||
|
@ -3728,7 +3728,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await XmppUtilities.get_chat_type(self, jid_bare)
|
chat_type = await XmppUtilities.get_chat_type(self, jid_bare)
|
||||||
if XmppUtilities.is_access(self, jid, chat_type):
|
if XmppUtilities.is_access(self, jid, chat_type):
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
form = self['xep_0004'].make_form('form', 'Settings')
|
form = self['xep_0004'].make_form('form', 'Settings')
|
||||||
|
@ -3845,7 +3845,7 @@ class XmppClient(slixmpp.ClientXMPP):
|
||||||
logger.debug('{}: jid_full: {}'
|
logger.debug('{}: jid_full: {}'
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
# In this case (as is typical), the payload is a form
|
# In this case (as is typical), the payload is a form
|
||||||
|
|
|
@ -9,7 +9,7 @@ import slixfeed.fetch as fetch
|
||||||
from slixfeed.log import Logger
|
from slixfeed.log import Logger
|
||||||
import slixfeed.sqlite as sqlite
|
import slixfeed.sqlite as sqlite
|
||||||
from slixfeed.syndication import Feed, FeedDiscovery, Opml
|
from slixfeed.syndication import Feed, FeedDiscovery, Opml
|
||||||
from slixfeed.utilities import DateAndTime, Documentation, String, Url, Utilities
|
from slixfeed.utilities import Database, DateAndTime, Documentation, String, Url, Utilities
|
||||||
from slixfeed.version import __version__
|
from slixfeed.version import __version__
|
||||||
from slixfeed.xmpp.bookmark import XmppBookmark
|
from slixfeed.xmpp.bookmark import XmppBookmark
|
||||||
from slixfeed.xmpp.muc import XmppMuc
|
from slixfeed.xmpp.muc import XmppMuc
|
||||||
|
@ -266,12 +266,12 @@ class XmppCommands:
|
||||||
async def restore_default(self, jid_bare, key=None):
|
async def restore_default(self, jid_bare, key=None):
|
||||||
if key:
|
if key:
|
||||||
self.settings[jid_bare][key] = None
|
self.settings[jid_bare][key] = None
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
await sqlite.delete_setting(db_file, key)
|
await sqlite.delete_setting(db_file, key)
|
||||||
message = f'Setting {key} has been restored to default value.'
|
message = f'Setting {key} has been restored to default value.'
|
||||||
else:
|
else:
|
||||||
del self.settings[jid_bare]
|
del self.settings[jid_bare]
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
await sqlite.delete_settings(db_file)
|
await sqlite.delete_settings(db_file)
|
||||||
message = 'Default settings have been restored.'
|
message = 'Default settings have been restored.'
|
||||||
return message
|
return message
|
||||||
|
@ -381,7 +381,7 @@ class XmppCommands:
|
||||||
jid = info[0]
|
jid = info[0]
|
||||||
if '/' not in jid:
|
if '/' not in jid:
|
||||||
url = info[1]
|
url = info[1]
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid}.db')
|
db_file = Database.instantiate(self.dir_data, jid)
|
||||||
if len(info) > 2:
|
if len(info) > 2:
|
||||||
identifier = info[2]
|
identifier = info[2]
|
||||||
else:
|
else:
|
||||||
|
@ -470,7 +470,8 @@ class XmppCommands:
|
||||||
async def fetch_http(self, url, db_file, jid_bare):
|
async def fetch_http(self, url, db_file, jid_bare):
|
||||||
if url.startswith('feed:/') or url.startswith('rss:/'):
|
if url.startswith('feed:/') or url.startswith('rss:/'):
|
||||||
url = Url.feed_to_http(url)
|
url = Url.feed_to_http(url)
|
||||||
url = (await Url.replace_hostname(self.dir_config, self.proxies, self.settings_network, url, 'feed')) or url
|
url = (await Url.replace_hostname(
|
||||||
|
self.dir_config, self.proxies, self.settings_network, url, 'feed') or url)
|
||||||
counter = 0
|
counter = 0
|
||||||
while True:
|
while True:
|
||||||
identifier = String.generate_identifier(url, counter)
|
identifier = String.generate_identifier(url, counter)
|
||||||
|
@ -703,7 +704,7 @@ class XmppCommands:
|
||||||
# response = (
|
# response = (
|
||||||
# f'Every update will contain {response} news items.'
|
# f'Every update will contain {response} news items.'
|
||||||
# )
|
# )
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
await Config.set_setting_value(
|
await Config.set_setting_value(
|
||||||
self, jid_bare, db_file, 'quantum', val_new)
|
self, jid_bare, db_file, 'quantum', val_new)
|
||||||
message = f'Next update will contain {val_new} news items (was: {val_old}).'
|
message = f'Next update will contain {val_new} news items (was: {val_old}).'
|
||||||
|
|
|
@ -12,6 +12,7 @@ socket (i.e. clients[fd]) from the respective client.
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
from slixfeed.syndication import FeedTask
|
from slixfeed.syndication import FeedTask
|
||||||
|
from slixfeed.utilities import Database
|
||||||
from slixfeed.xmpp.chat import XmppChatTask
|
from slixfeed.xmpp.chat import XmppChatTask
|
||||||
from slixfeed.xmpp.commands import XmppCommands
|
from slixfeed.xmpp.commands import XmppCommands
|
||||||
from slixfeed.xmpp.chat import XmppChatAction
|
from slixfeed.xmpp.chat import XmppChatAction
|
||||||
|
@ -84,7 +85,7 @@ class XmppIpcServer:
|
||||||
if '~' in data:
|
if '~' in data:
|
||||||
data_list = data.split('~')
|
data_list = data.split('~')
|
||||||
jid_bare = data_list[0]
|
jid_bare = data_list[0]
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
command = data_list[1]
|
command = data_list[1]
|
||||||
else:
|
else:
|
||||||
command = data
|
command = data
|
||||||
|
|
|
@ -16,7 +16,7 @@ from slixfeed.config import Config
|
||||||
from slixfeed.log import Logger
|
from slixfeed.log import Logger
|
||||||
import slixfeed.sqlite as sqlite
|
import slixfeed.sqlite as sqlite
|
||||||
from slixfeed.syndication import Feed
|
from slixfeed.syndication import Feed
|
||||||
from slixfeed.utilities import String, Url, Utilities
|
from slixfeed.utilities import Database, String, Url, Utilities
|
||||||
from slixfeed.xmpp.iq import XmppIQ
|
from slixfeed.xmpp.iq import XmppIQ
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ class XmppPubsubAction:
|
||||||
async def send_selected_entry(self, jid_bare, node_id, entry_id):
|
async def send_selected_entry(self, jid_bare, node_id, entry_id):
|
||||||
function_name = sys._getframe().f_code.co_name
|
function_name = sys._getframe().f_code.co_name
|
||||||
logger.debug('{}: jid_bare: {}'.format(function_name, jid_bare))
|
logger.debug('{}: jid_bare: {}'.format(function_name, jid_bare))
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
feed_id = sqlite.get_feed_id_by_entry_index(db_file, entry_id)
|
feed_id = sqlite.get_feed_id_by_entry_index(db_file, entry_id)
|
||||||
feed_id = feed_id[0]
|
feed_id = feed_id[0]
|
||||||
node_id, node_title, node_subtitle = sqlite.get_feed_properties(db_file, feed_id)
|
node_id, node_title, node_subtitle = sqlite.get_feed_properties(db_file, feed_id)
|
||||||
|
@ -298,7 +298,7 @@ class XmppPubsubAction:
|
||||||
"""
|
"""
|
||||||
function_name = sys._getframe().f_code.co_name
|
function_name = sys._getframe().f_code.co_name
|
||||||
logger.debug('{}: jid_bare: {}'.format(function_name, jid_bare))
|
logger.debug('{}: jid_bare: {}'.format(function_name, jid_bare))
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
report = {}
|
report = {}
|
||||||
subscriptions = sqlite.get_active_feeds_url(db_file)
|
subscriptions = sqlite.get_active_feeds_url(db_file)
|
||||||
for url in subscriptions:
|
for url in subscriptions:
|
||||||
|
@ -372,7 +372,7 @@ class XmppPubsubTask:
|
||||||
|
|
||||||
|
|
||||||
async def loop_task(self, jid_bare):
|
async def loop_task(self, jid_bare):
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
while True:
|
while True:
|
||||||
|
@ -393,7 +393,7 @@ class XmppPubsubTask:
|
||||||
|
|
||||||
|
|
||||||
def restart_task(self, jid_bare):
|
def restart_task(self, jid_bare):
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
if jid_bare not in self.task_manager:
|
if jid_bare not in self.task_manager:
|
||||||
|
@ -411,7 +411,7 @@ class XmppPubsubTask:
|
||||||
|
|
||||||
|
|
||||||
async def task_publish(self, jid_bare):
|
async def task_publish(self, jid_bare):
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self, jid_bare, db_file)
|
Config.add_settings_jid(self, jid_bare, db_file)
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -29,7 +29,7 @@ class XmppStatus:
|
||||||
status_text = '📜️ Slixfeed RSS News Bot'
|
status_text = '📜️ Slixfeed RSS News Bot'
|
||||||
enabled = Config.get_setting_value(self, jid_bare, 'enabled')
|
enabled = Config.get_setting_value(self, jid_bare, 'enabled')
|
||||||
if enabled:
|
if enabled:
|
||||||
db_file = os.path.join(self.dir_data, 'sqlite', f'{jid_bare}.db')
|
db_file = Database.instantiate(self.dir_data, jid_bare)
|
||||||
jid_task = self.pending_tasks[jid_bare] if jid_bare in self.pending_tasks else None
|
jid_task = self.pending_tasks[jid_bare] if jid_bare in self.pending_tasks else None
|
||||||
if jid_task and len(jid_task):
|
if jid_task and len(jid_task):
|
||||||
# print('status dnd for ' + jid_bare)
|
# print('status dnd for ' + jid_bare)
|
||||||
|
|
Loading…
Reference in a new issue