text
stringlengths
1
93.6k
# IF FULL PATH
if x.startswith('/'):
up = b'/' + b'/'.join(y[:-1])
z = {'case': 1, 'ign': y[-1], 'up': up}
# IF ONLY SINGLE DIRECTORY NAME
elif len(y) == 1:
z = {'case': 2, 'ign': y[-1], 'up': ''}
# IF PARENT/TARGET
elif len(y) == 2:
z = {'case': 3, 'ign': y[-1], 'up': y[-2]}
if z:
PREP_EXCLUDED.append(z)
if settings.value('conditional_mounts_for_autoupdate'):
q = settings.value('conditional_mounts_for_autoupdate').strip().split()
MOUNTS_NEEDED = [x for x in q]
if settings.value('notifications'):
q = settings.value('notifications')
if q.lower() in ['false', 'no', '0', 'n', 'none', 'nope']:
NOTIFICATIONS_ENABLED = False
def test_conditional_mounts_for_autoupdate():
missing_mount = False
missing_mounts_list = []
for x in MOUNTS_NEEDED:
if not os.path.ismount(x):
missing_mount = True
missing_mounts_list.append(x)
if missing_mount is True:
notify_text = 'aborting automatic update'
for x in missing_mounts_list:
notify_text = notify_text + '\n<b>{}</b> missing'.format(x)
show_notification(notify_text)
print('angrysearch: ' + ', '.join(notify_text.split('\n')))
sys.exit(0)
def show_notification(text):
global NOTIFY_AVAILABLE
global NOTIFICATIONS_ENABLED
if NOTIFY_AVAILABLE is False or NOTIFICATIONS_ENABLED is False:
print('angrysearch: Desktop notifications disabled or unavailable')
return
Notify.init('angrysearch')
n = Notify.Notification.new('ANGRYsearch:', text)
possible_image_locations = [
'angrysearch.svg',
'/usr/share/pixmaps/angrysearch.svg',
'/usr/share/angrysearch/angrysearch.svg',
'/opt/angrysearch/angrysearch.svg'
]
for x in possible_image_locations:
if os.path.exists(x):
icon = GdkPixbuf.Pixbuf.new_from_file(x)
n.set_image_from_pixbuf(icon)
break
else:
n.set_property('icon-name', 'drive-harddisk')
n.show()
def crawling_drives():
def error(err):
print(err)
root_dir = b'/'
table = []
dir_list = []
file_list = []
if SCANDIR_AVAILABLE:
ror = scandir
else:
ror = os
for root, dirs, files in ror.walk(root_dir, onerror=error):
dirs.sort()
files.sort()
if root == b'/' and b'proc' in dirs:
dirs.remove(b'proc')
dirs[:] = remove_excluded_dirs(dirs, root, PREP_EXCLUDED)
for dname in dirs:
path = os.path.join(root, dname)
utf_path = path.decode(encoding='utf-8', errors='ignore')
try:
stats = os.lstat(path)