2018-11-21 16:07:29 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import time
|
2019-04-25 12:39:38 +00:00
|
|
|
import datetime
|
2019-11-05 14:18:03 +00:00
|
|
|
|
2022-11-23 10:02:33 +00:00
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
|
|
from lib import ConfigLoader
|
2018-11-21 16:07:29 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
start_deb = time.time()
|
|
|
|
|
2019-11-05 14:18:03 +00:00
|
|
|
config_loader = ConfigLoader.ConfigLoader()
|
|
|
|
|
|
|
|
PASTES_FOLDER = os.path.join(os.environ['AIL_HOME'], config_loader.get_config_str("Directories", "pastes")) + '/'
|
|
|
|
|
|
|
|
r_serv = config_loader.get_redis_conn("ARDB_DB")
|
|
|
|
r_serv_onion = config_loader.get_redis_conn("ARDB_Onion")
|
|
|
|
config_loader = None
|
2018-11-21 16:07:29 +00:00
|
|
|
|
|
|
|
print()
|
|
|
|
print('Updating ARDB_Onion ...')
|
|
|
|
index = 0
|
|
|
|
start = time.time()
|
|
|
|
|
2019-04-25 12:39:38 +00:00
|
|
|
# update crawler queue
|
2018-12-19 08:28:46 +00:00
|
|
|
for elem in r_serv_onion.smembers('onion_crawler_queue'):
|
|
|
|
if PASTES_FOLDER in elem:
|
|
|
|
r_serv_onion.srem('onion_crawler_queue', elem)
|
|
|
|
r_serv_onion.sadd('onion_crawler_queue', elem.replace(PASTES_FOLDER, '', 1))
|
|
|
|
index = index +1
|
2019-04-25 12:39:38 +00:00
|
|
|
for elem in r_serv_onion.smembers('onion_crawler_priority_queue'):
|
|
|
|
if PASTES_FOLDER in elem:
|
|
|
|
r_serv_onion.srem('onion_crawler_queue', elem)
|
|
|
|
r_serv_onion.sadd('onion_crawler_queue', elem.replace(PASTES_FOLDER, '', 1))
|
|
|
|
index = index +1
|
2018-11-21 16:07:29 +00:00
|
|
|
|
|
|
|
end = time.time()
|
|
|
|
print('Updating ARDB_Onion Done => {} paths: {} s'.format(index, end - start))
|
|
|
|
print()
|
2019-04-25 12:39:38 +00:00
|
|
|
|
2021-01-22 16:03:43 +00:00
|
|
|
# Add background update
|
|
|
|
r_serv.sadd('ail:to_update', 'v1.5')
|
|
|
|
|
2019-04-25 12:39:38 +00:00
|
|
|
#Set current ail version
|
|
|
|
r_serv.set('ail:version', 'v1.5')
|
|
|
|
|
|
|
|
#Set current ail version
|
|
|
|
r_serv.set('ail:update_date_v1.5', datetime.datetime.now().strftime("%Y%m%d"))
|
|
|
|
|
2018-11-21 16:07:29 +00:00
|
|
|
print('Done in {} s'.format(end - start_deb))
|