euscanwww: Removing duplicated code

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-06-08 14:43:18 +02:00
parent 43e996d83d
commit b43bf8fa28
4 changed files with 20 additions and 22 deletions

View File

@ -271,22 +271,11 @@ def main():
output.eerror('%s: %s' % (query, str(err))) output.eerror('%s: %s' % (query, str(err)))
exit_helper(1) exit_helper(1)
if not CONFIG['quiet'] and not CONFIG['format']:
print()
if (CONFIG['format'] or CONFIG['quiet']) and isatty: if (CONFIG['format'] or CONFIG['quiet']) and isatty:
on_progress_gen.next() on_progress_gen.next()
print("\n", file=sys.stderr) print("\n", file=sys.stderr)
if ret is not None: if not ret and not CONFIG['quiet']:
if len(ret) > 0:
for cp, url, version, handler, confidence in ret:
output.result(cp, version, url, handler, confidence)
if (CONFIG['format'] or CONFIG['quiet']) and isatty:
print("\n", file=sys.stderr)
elif not CONFIG['quiet']:
output.ewarn( output.ewarn(
"Didn't find any new version, check package's homepage " + "Didn't find any new version, check package's homepage " +
"for more informations" "for more informations"

View File

@ -22,11 +22,7 @@ class ScanUpstream(object):
CONFIG["format"] = "dict" CONFIG["format"] = "dict"
output.set_query(package) output.set_query(package)
ret = scan_upstream(package) scan_upstream(package)
if ret is not None:
if len(ret) > 0:
for cp, url, version, handler, confidence in ret:
output.result(cp, version, url, handler, confidence)
out = output.get_formatted_output() out = output.get_formatted_output()
out_json = output.get_formatted_output("json") out_json = output.get_formatted_output("json")

View File

@ -68,10 +68,13 @@
var url = "{% url "apply_task" "task_name" %}"; var url = "{% url "apply_task" "task_name" %}";
$.post(url.replace("task_name", task_name), data, function() { $.post(url.replace("task_name", task_name), data, function() {
//location.reload(); alert("Submitted!");
location.reload();
}); });
}); });
setTimeout(location.reload, 10000);
}); });
})(django.jQuery); })(django.jQuery);
</script> </script>

View File

@ -1,4 +1,7 @@
from __future__ import print_function
import os import os
import sys
from datetime import datetime from datetime import datetime
import portage import portage
@ -212,4 +215,11 @@ def scan_upstream(query, on_progress=None):
if on_progress: if on_progress:
on_progress(maxval, curval) on_progress(maxval, curval)
if len(result) > 0:
if not (CONFIG['format'] or CONFIG['quiet']):
print("\n", file=sys.stderr)
for cp, url, version, handler, confidence in result:
output.result(cp, version, url, handler, confidence)
return result return result