app config, parallel filelist generation
This commit is contained in:
commit
242896ba37
2 changed files with 69 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*.pyc
|
||||
__pycache__
|
||||
over
|
66
find-orphans.py
Executable file
66
find-orphans.py
Executable file
|
@ -0,0 +1,66 @@
|
|||
#! /bin/env python3
|
||||
# encoding: utf-8
|
||||
|
||||
# library imports
|
||||
import os
|
||||
import over
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
# --------------------------------------------------
|
||||
|
||||
prefix = over.core.textui.prefix
|
||||
_print = over.core.textui.Output('Find Orphans')
|
||||
|
||||
# --------------------------------------------------
|
||||
# Functions
|
||||
|
||||
# --------------------------------------------------
|
||||
# Classes
|
||||
|
||||
# --------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
main = over.core.app.Main('Find Orphans', None, 'AWARE-Overwatch Joint Software License')
|
||||
main.add_option('filter', 'str', ['/home/*', '/var/*', '*.pyc'], 'Shell globs that should be filtered out.', plural=True)
|
||||
main.add_option('null-separated', 'bool', False, 'Output each filename separated with a null character. Otherwise use a newline.', short_name='0')
|
||||
main.add_help('Description', ['Finds files on Gentoo systems that aren\'t owned by any installed package and lists them.'])
|
||||
main.enable_help('h')
|
||||
main.parse()
|
||||
|
||||
if not main.targets:
|
||||
_print('specify at least one directory to work on, e.g. \'/\'', prefix.fail)
|
||||
main.exit(silent=True)
|
||||
|
||||
# --------------------------------------------------
|
||||
# Create a file list
|
||||
|
||||
file_list = []
|
||||
threads = [] # {proc, output_buffer}
|
||||
|
||||
for root in main.targets:
|
||||
proc = over.core.cmd.Command('find', root, '-print0')
|
||||
proc.run()
|
||||
threads.append({'proc': proc, 'output_buffer': []})
|
||||
|
||||
_print('gathering file list using %d processes' %(len(threads)), prefix.start)
|
||||
|
||||
while True:
|
||||
at_least_one_lives = False
|
||||
|
||||
for thread in threads:
|
||||
tmp = thread['proc'].get_output()
|
||||
|
||||
if not tmp is None:
|
||||
thread['output_buffer'].append(tmp)
|
||||
at_least_one_lives = True
|
||||
|
||||
if at_least_one_lives:
|
||||
time.sleep(1)
|
||||
else:
|
||||
break
|
||||
|
||||
_print('post-processing file list')
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue