text stringlengths 1 93.6k |
|---|
temp_db_path = TEMP_PATH + '/angry_database.db'
|
if os.path.exists(temp_db_path):
|
os.remove(temp_db_path)
|
con = sqlite3.connect(temp_db_path, check_same_thread=False)
|
cur = con.cursor()
|
if fts5_pragma_check():
|
cur.execute('''CREATE VIRTUAL TABLE angry_table
|
USING fts5(directory, path)''')
|
cur.execute('''PRAGMA user_version = 4;''')
|
else:
|
cur.execute('''CREATE VIRTUAL TABLE angry_table
|
USING fts4(directory, path)''')
|
cur.execute('''PRAGMA user_version = 3;''')
|
cur.executemany('''INSERT INTO angry_table VALUES (?, ?)''', table)
|
con.commit()
|
replace_old_db_with_new()
|
def replace_old_db_with_new():
|
global DATABASE_PATH
|
temp_db_path = TEMP_PATH + '/angry_database.db'
|
dir_path = os.path.dirname(DATABASE_PATH)
|
if not os.path.exists(temp_db_path):
|
return
|
if not os.path.exists(dir_path):
|
cmd = ['install', '-d', dir_path]
|
p = subprocess.Popen(cmd)
|
p.wait()
|
cmd = ['mv', '-f', temp_db_path, DATABASE_PATH]
|
p = subprocess.Popen(cmd, stderr=subprocess.PIPE)
|
p.wait()
|
def time_difference(nseconds):
|
mins, secs = divmod(nseconds, 60)
|
return '{:0>2d}:{:0>2d}'.format(mins, secs)
|
def fts5_pragma_check():
|
with sqlite3.connect(':memory:') as conn:
|
cur = conn.cursor()
|
cur.execute('pragma compile_options;')
|
available_pragmas = cur.fetchall()
|
if ('ENABLE_FTS5', ) in available_pragmas:
|
return True
|
else:
|
return False
|
if __name__ == '__main__':
|
load_settings()
|
test_conditional_mounts_for_autoupdate()
|
if LITE is True:
|
crawling_drives_lite()
|
else:
|
crawling_drives()
|
total_time = datetime.now() - START_TIME
|
noti_text = '{} | database updated'.format(
|
time_difference(total_time.seconds))
|
try:
|
show_notification(noti_text)
|
except Exception as err:
|
print(err)
|
log_path = TEMP_PATH + '/angrysearch_cron.log'
|
with open(log_path, 'a') as log:
|
t = '{:%Y-%b-%d | %H:%M | } '.format(datetime.now())
|
log.write(t + str(err) + os.linesep)
|
# <FILESEP>
|
#!/usr/bin/python
|
from binman import *
|
from fragtype import Fragtype
|
def getMacType(in_pdu):
|
""" Return multiframeness of a PDU (see Fragtype class) """
|
bitstream = hex_to_binary(in_pdu)
|
macpdutype = int(bitstream[:2], 2)
|
if macpdutype == 0:
|
subidx = 7
|
macpdulen = int(bitstream[subidx:subidx + 6], 2)
|
if macpdulen == 63:
|
return Fragtype.MAC_START
|
else:
|
return Fragtype.MAC_SINGLE
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.