Fix some flakes8 warnings
This commit is contained in:
parent
08bc219dc5
commit
7a656153fc
@ -1,7 +1,5 @@
|
||||
|
||||
import collections
|
||||
import subprocess
|
||||
|
||||
|
||||
from port_stats import rpm_ffi
|
||||
|
||||
|
@ -9,20 +9,20 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from port_stats import reports
|
||||
from port_stats import tasks
|
||||
from port_stats import colorize
|
||||
from port_stats import lists
|
||||
from port_stats import reports
|
||||
from port_stats import tasks
|
||||
from port_stats import utils
|
||||
|
||||
LOG = logging.getLogger('daily')
|
||||
|
||||
|
||||
def main(out_dir, config_path):
|
||||
os.makedirs(out_dir, mode=0755)
|
||||
os.makedirs(out_dir, mode=0o755)
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s %(levelname)-5s %(name)s - %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S',
|
||||
@ -40,7 +40,7 @@ def main(out_dir, config_path):
|
||||
|
||||
for r in config['colorize']:
|
||||
r_dir = os.path.join(out_dir, r['name'])
|
||||
os.makedirs(r_dir, mode=0755)
|
||||
os.makedirs(r_dir, mode=0o755)
|
||||
daily_report(r_dir, r, repos, all_tasks)
|
||||
_unmets(config['repos'][r['new']], os.path.join(r_dir, 'unmets.txt'))
|
||||
|
||||
@ -61,7 +61,6 @@ def _unmets(repo, out_file):
|
||||
os.unlink(fname)
|
||||
|
||||
|
||||
|
||||
def daily_report(out_dir, what, repos, all_tasks):
|
||||
LOG.info("Writing daily report for %s", what['name'])
|
||||
now = datetime.datetime.utcnow()
|
||||
@ -119,7 +118,9 @@ def daily_report(out_dir, what, repos, all_tasks):
|
||||
# TSV for packages
|
||||
with open(os.path.join(out_dir, 'colorized.tsv'), 'w') as out:
|
||||
for name in sorted(by_name):
|
||||
print(reports.package_one_line(name, by_name, package_tasks), file=out)
|
||||
print(reports.package_one_line(name, by_name, package_tasks),
|
||||
file=out)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(*sys.argv[1:]))
|
||||
|
@ -30,19 +30,17 @@ import logging
|
||||
import os
|
||||
import re
|
||||
import readline
|
||||
import rlcompleter
|
||||
import sys
|
||||
|
||||
from pydoc import pager
|
||||
|
||||
from port_stats import colorize
|
||||
from port_stats import lists
|
||||
from port_stats import tasks
|
||||
from port_stats import task_predicates as tp
|
||||
from port_stats import reports
|
||||
from port_stats import utils
|
||||
from port_stats import logs as m_logs
|
||||
|
||||
from port_stats import reports
|
||||
from port_stats import task_predicates as tp
|
||||
from port_stats import tasks
|
||||
from port_stats import utils
|
||||
|
||||
|
||||
LOG = logging.getLogger('port_stats.interactive')
|
||||
@ -60,23 +58,25 @@ def package_tasks(pkg, data):
|
||||
return '\n'.join(tasks.format_task(t) for t in ts)
|
||||
|
||||
|
||||
## To targets ##
|
||||
# {{{ to= targets
|
||||
|
||||
def dump(string):
|
||||
print(string)
|
||||
|
||||
|
||||
def append_to(filename):
|
||||
def _write(string):
|
||||
if os.path.exists(filename):
|
||||
LOG.info('File %s already exists, appending', filename)
|
||||
def _write(string):
|
||||
with open(filename, 'a') as f:
|
||||
f.write(string)
|
||||
f.write('\n')
|
||||
return _write
|
||||
|
||||
|
||||
## The Interactive Part ##
|
||||
# }}}
|
||||
|
||||
# The Interactive Part
|
||||
|
||||
CONFIG = None
|
||||
CURRENT = None
|
||||
@ -97,7 +97,8 @@ def use(repo=None):
|
||||
global PACKAGE_TASKS, BY_NAME, BY_COLOR, CURRENT
|
||||
if repo is not None:
|
||||
try:
|
||||
CURRENT = (c for c in CONFIG['colorize'] if c['name'] == repo).next()
|
||||
CURRENT = (c for c in CONFIG['colorize']
|
||||
if c['name'] == repo).next()
|
||||
except StopIteration:
|
||||
raise ValueError('Unknown repo: ' + repo)
|
||||
elif CURRENT is None:
|
||||
@ -139,7 +140,6 @@ def _spi_by_predicate(pred, colors):
|
||||
reports.package_one_line(name, BY_NAME, PACKAGE_TASKS)
|
||||
for name in sorted(BY_NAME)
|
||||
if pred(name) and BY_NAME[name][0] in colors)
|
||||
to(lines)
|
||||
|
||||
|
||||
def gspi(pattern, colors=None, to=print):
|
||||
@ -225,6 +225,7 @@ def interactive_setup():
|
||||
global CONFIG
|
||||
CONFIG = json.load(f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
interactive_setup()
|
||||
print(__doc__)
|
||||
|
@ -1,9 +1,8 @@
|
||||
|
||||
import logging
|
||||
import subprocess
|
||||
import collections
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
import rpm
|
||||
@ -84,7 +83,6 @@ def _read_pkglist_rpm(path):
|
||||
return (NEVR.from_header(h) for h in read_pkglist_headers_rpm(path))
|
||||
|
||||
|
||||
|
||||
_PKGLIST_QUERY_FORMAT = '%{NAME}\t%{EPOCH}\t%{VERSION}\t%{RELEASE}\n'
|
||||
|
||||
|
||||
@ -125,4 +123,3 @@ def read_srclists(prefix, arches):
|
||||
def read_all_srclists(repos):
|
||||
return dict((name, read_srclists(v['path'], v['arch']))
|
||||
for name, v in repos.items())
|
||||
|
||||
|
@ -7,7 +7,6 @@ import errno
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from port_stats import lists
|
||||
@ -16,6 +15,8 @@ from port_stats import tasks
|
||||
from port_stats import utils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def subtask_srpm_nevr(task, subtask_id):
|
||||
try:
|
||||
|
@ -2,8 +2,8 @@
|
||||
import logging
|
||||
|
||||
from port_stats import colorize
|
||||
from port_stats import tasks
|
||||
from port_stats import lists
|
||||
from port_stats import tasks
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -72,7 +72,6 @@ def evr_cmp(evr1, evr2, mode):
|
||||
p_e2, p_v2, p_r2, dep)
|
||||
|
||||
|
||||
|
||||
def _tests():
|
||||
assert parse_evr('3:42.8.4-alt1.mipsel0') == (3, '42.8.4', 'alt1.mipsel0')
|
||||
assert parse_evr('0:42.8.4-alt1.mipsel0') == (0, '42.8.4', 'alt1.mipsel0')
|
||||
@ -86,16 +85,16 @@ def _tests():
|
||||
assert evr_cmp((3, '42.8.4', 'alt1'), (3, '42.8.4', 'alt1'), 'pkg') == 0
|
||||
assert evr_cmp((3, '42.9.4', 'alt1'), (5, '42.8.4', 'alt1'), 'pkg') < 0
|
||||
|
||||
assert evr_cmp((1, '1.20.0', 'alt1'), (None, '1.20.0', 'alt1_1'), 'pkg') > 0
|
||||
assert evr_cmp((None, '1.20.0', 'alt1_1'), (1, '1.20.0', 'alt1'), 'pkg') < 0
|
||||
assert evr_cmp((1, '1.2.0', 'alt1'), (None, '1.2.0', 'alt1_1'), 'pkg') > 0
|
||||
assert evr_cmp((None, '1.2.0', 'alt1_1'), (1, '1.2.0', 'alt1'), 'pkg') < 0
|
||||
|
||||
# 'deps' mode means that first argument satisfies requirement
|
||||
# specified as second argument; here, if epoch is absent on the right
|
||||
# side, it's ignored
|
||||
assert evr_cmp((1, '1.20.0', 'alt1'), (None, '1.20.0', 'alt1_1'), 'deps') < 0
|
||||
assert evr_cmp((None, '1.20.0', 'alt1_1'), (1, '1.20.0', 'alt1'), 'deps') < 0
|
||||
assert evr_cmp((1, '1.21.0', 'alt1'), (None, '1.20.0', 'alt1_1'), 'deps') > 0
|
||||
assert evr_cmp((None, '1.21.0', 'alt1_1'), (1, '1.20.0', 'alt1'), 'deps') < 0
|
||||
assert evr_cmp((1, '1.2.0', 'alt1'), (None, '1.2.0', 'alt1_1'), 'deps') < 0
|
||||
assert evr_cmp((None, '1.2.0', 'alt1_1'), (1, '1.2.0', 'alt1'), 'deps') < 0
|
||||
assert evr_cmp((1, '1.3.0', 'alt1'), (None, '1.2.0', 'alt1_1'), 'deps') > 0
|
||||
assert evr_cmp((None, '1.3.0', 'alt1_1'), (1, '1.2.0', 'alt1'), 'deps') < 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -2,7 +2,6 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from collections import defaultdict
|
||||
@ -83,7 +82,6 @@ def load_tasks(prefixes, repo=None, cache=None):
|
||||
return sorted(tasks, key=lambda t: t.get('taskid'))
|
||||
|
||||
|
||||
|
||||
_FORMAT_SUBTASK = {
|
||||
'srpm': lambda st: 'srpm ' + st.get('srpm'),
|
||||
'delete': lambda st: 'delete ' + st.get('package'),
|
||||
@ -91,6 +89,7 @@ _FORMAT_SUBTASK = {
|
||||
st.get('tag') or st.get('tag_name'))
|
||||
}
|
||||
|
||||
|
||||
def format_subtask(subtask, extra_info=None):
|
||||
stype = subtask.get('type')
|
||||
result = _FORMAT_SUBTASK.get(stype, utils.format_dict)(subtask)
|
||||
@ -152,9 +151,8 @@ def tasks_by_package(task_list):
|
||||
try:
|
||||
for p in task_packages(task):
|
||||
result[p].append(task)
|
||||
except Exception as ex:
|
||||
except Exception:
|
||||
LOG.error('Failed to parse task: %s',
|
||||
utils.format_dict(task), exc_info=True)
|
||||
return dict((p, sorted(l, key=lambda t: utils.maybe_int(t['taskid'])))
|
||||
for p, l in result.iteritems())
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
def format_timestamp(ts, fmt='%Y-%m-%d %H:%M:%S'):
|
||||
|
Loading…
Reference in New Issue
Block a user