Hello community,

here is the log from the commit of package openSUSE-release-tools for 
openSUSE:Factory checked in at 2018-01-29 14:58:44
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/openSUSE-release-tools (Old)
 and      /work/SRC/openSUSE:Factory/.openSUSE-release-tools.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "openSUSE-release-tools"

Mon Jan 29 14:58:44 2018 rev:45 rq:570413 version:20180126.574cfe8

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/openSUSE-release-tools/openSUSE-release-tools.changes
    2018-01-28 00:39:59.371941807 +0100
+++ 
/work/SRC/openSUSE:Factory/.openSUSE-release-tools.new/openSUSE-release-tools.changes
       2018-01-29 15:00:25.582199851 +0100
@@ -1,0 +2,10 @@
+Fri Jan 26 20:55:15 UTC 2018 - [email protected]
+
+- Update to version 20180126.574cfe8:
+  * status: provide exit code based on status.
+  * status: provide initial implementation for checking bot status.
+  * osclib/request_splitter: utilize osclib.core.request_age().
+  * devel-project: utilize osclib.core.request_age().
+  * osclib/core: provide request_age().
+
+-------------------------------------------------------------------

Old:
----
  openSUSE-release-tools-20180126.2c8c597.obscpio

New:
----
  openSUSE-release-tools-20180126.574cfe8.obscpio

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ openSUSE-release-tools.spec ++++++
--- /var/tmp/diff_new_pack.QUOORb/_old  2018-01-29 15:00:27.126127716 +0100
+++ /var/tmp/diff_new_pack.QUOORb/_new  2018-01-29 15:00:27.130127529 +0100
@@ -20,7 +20,7 @@
 %define source_dir osc-plugin-factory
 %define announcer_filename factory-package-news
 Name:           openSUSE-release-tools
-Version:        20180126.2c8c597
+Version:        20180126.574cfe8
 Release:        0
 Summary:        Tools to aid in staging and release work for openSUSE/SUSE
 License:        GPL-2.0+ AND MIT

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.QUOORb/_old  2018-01-29 15:00:27.174125474 +0100
+++ /var/tmp/diff_new_pack.QUOORb/_new  2018-01-29 15:00:27.174125474 +0100
@@ -1,6 +1,6 @@
 <servicedata>
   <service name="tar_scm">
     <param 
name="url">https://github.com/openSUSE/osc-plugin-factory.git</param>
-    <param 
name="changesrevision">2c8c5976739d9e0154bd7ceb651f1085dce01a38</param>
+    <param 
name="changesrevision">574cfe8e1245e98922150a574df1a27dbc9c98af</param>
   </service>
 </servicedata>

++++++ openSUSE-release-tools-20180126.2c8c597.obscpio -> 
openSUSE-release-tools-20180126.574cfe8.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/openSUSE-release-tools-20180126.2c8c597/devel-project.py 
new/openSUSE-release-tools-20180126.574cfe8/devel-project.py
--- old/openSUSE-release-tools-20180126.2c8c597/devel-project.py        
2018-01-26 21:42:07.000000000 +0100
+++ new/openSUSE-release-tools-20180126.574cfe8/devel-project.py        
2018-01-26 21:49:32.000000000 +0100
@@ -16,6 +16,7 @@
 from osc.core import show_project_meta
 from osclib.comments import CommentAPI
 from osclib.conf import Config
+from osclib.core import request_age
 from osclib.stagingapi import StagingAPI
 
 
@@ -95,11 +96,6 @@
         if len(intersection) != len(desired):
             print('{} missing {}'.format(devel_project, ', '.join(desired - 
intersection)))
 
-def request_age(request):
-    date = dateutil.parser.parse(request.statehistory[0].when)
-    delta = datetime.utcnow() - date
-    return delta.days
-
 def requests(args):
     apiurl = osc.conf.config['apiurl']
     devel_projects = devel_projects_load(args)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/openSUSE-release-tools-20180126.2c8c597/osclib/core.py 
new/openSUSE-release-tools-20180126.574cfe8/osclib/core.py
--- old/openSUSE-release-tools-20180126.2c8c597/osclib/core.py  2018-01-26 
21:42:07.000000000 +0100
+++ new/openSUSE-release-tools-20180126.574cfe8/osclib/core.py  2018-01-26 
21:49:32.000000000 +0100
@@ -1,6 +1,6 @@
 from collections import namedtuple
 from datetime import datetime
-import dateutil.parser
+from dateutil.parser import parse as date_parse
 import re
 from xml.etree import cElementTree as ET
 from urllib2 import HTTPError
@@ -78,7 +78,7 @@
         if project in history.comment:
             when = history.when
 
-    return dateutil.parser.parse(when)
+    return date_parse(when)
 
 def request_staged(request):
     for review in request.reviews:
@@ -164,3 +164,8 @@
                 project = project.split(':', 1)[1]
 
     return project, package
+
+def request_age(request):
+    created = date_parse(request.find('history').get('when'))
+    delta = datetime.utcnow() - created
+    return delta.total_seconds()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/openSUSE-release-tools-20180126.2c8c597/osclib/request_splitter.py 
new/openSUSE-release-tools-20180126.574cfe8/osclib/request_splitter.py
--- old/openSUSE-release-tools-20180126.2c8c597/osclib/request_splitter.py      
2018-01-26 21:42:07.000000000 +0100
+++ new/openSUSE-release-tools-20180126.574cfe8/osclib/request_splitter.py      
2018-01-26 21:49:32.000000000 +0100
@@ -5,6 +5,7 @@
 from osc import conf
 from osc.core import show_project_meta
 from osclib.core import devel_project_fallback
+from osclib.core import request_age
 import re
 
 class RequestSplitter(object):
@@ -106,9 +107,8 @@
 
         history = request.find('history')
         if history is not None:
-            created = 
dateutil.parser.parse(request.find('history').get('when'))
-            delta = datetime.utcnow() - created
-            request.set('aged', str(delta.total_seconds() >= 
self.request_age_threshold))
+            age = request_age(request)
+            request.set('aged', str(age >= self.request_age_threshold))
 
         request_type = request.find('./action').get('type')
         target = request.find('./action/target')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/openSUSE-release-tools-20180126.2c8c597/status.py 
new/openSUSE-release-tools-20180126.574cfe8/status.py
--- old/openSUSE-release-tools-20180126.2c8c597/status.py       1970-01-01 
01:00:00.000000000 +0100
+++ new/openSUSE-release-tools-20180126.574cfe8/status.py       2018-01-26 
21:49:32.000000000 +0100
@@ -0,0 +1,141 @@
+#!/usr/bin/python
+
+import argparse
+from datetime import datetime
+from osc import conf
+from osc.core import ET
+from osc.core import search
+from osc.core import xpath_join
+from osclib.comments import CommentAPI
+from osclib.core import request_age
+from osclib.memoize import memoize
+import sys
+
+def print_debug(message):
+    if conf.config['debug']:
+        print(message)
+
+def request_debug(request, age, threshold):
+    print_debug('{}: {} {} [{}]'.format(request.get('id'), age, threshold, age 
<= threshold))
+
+@memoize(session=True)
+def check_comment(apiurl, bot, **kwargs):
+    if not len(kwargs):
+        return False
+
+    api = CommentAPI(apiurl)
+    comments = api.get_comments(**kwargs)
+    comment = api.comment_find(comments, bot)[0]
+    if comment:
+        return (datetime.utcnow() - comment['when']).total_seconds()
+
+    return False
+
+def check(apiurl, entity, entity_type='group', comment=False, bot=None,
+          threshold=2 * 3600, threshold_require=True):
+    queries = {'request': {'limit': 1000, 'withfullhistory': 1}}
+    xpath = 'state[@name="new"] or state[@name="review"]'
+
+    if entity == 'staging-bot':
+        xpath = xpath_join(
+            xpath, 'review[starts-with(@by_project, "openSUSE:") and 
@state="new"]', op='and')
+        xpath = xpath_join(
+            xpath, 'history/@who="{}"'.format(entity), op='and')
+
+        requests = search(apiurl, queries, request=xpath)['request']
+        for request in requests:
+            age = request_age(request)
+            request_debug(request, age, threshold)
+
+            if age <= threshold:
+                return True
+
+        return False
+
+    xpath = xpath_join(
+        xpath, 'review[@by_{}="{}" and @state="new"]'.format(entity_type, 
entity), op='and')
+    requests = search(apiurl, queries, request=xpath)['request']
+
+    print_debug('{:,} requests'.format(len(requests)))
+    if not len(requests):
+        # Could check to see that a review has been performed in the last week.
+        return True
+
+    if not comment:
+        return False
+
+    all_comment = True
+    for request in requests:
+        kwargs = {}
+        if comment == 'project':
+            # Would be a lot easier with lxml, but short of reparsing or 
monkey.
+            for review in request.findall('review[@by_project]'):
+                if review.get('by_project').startswith('openSUSE:'):
+                    kwargs['project_name'] = review.get('by_project')
+            # TODO repo-checker will miss stagings where delete only problem so
+            # comment on request, but should be fixed by #1084.
+        elif comment:
+            kwargs['request_id'] = request.get('id')
+
+        age = request_age(request)
+        request_debug(request, age, threshold)
+        comment_age = check_comment(apiurl, bot, **kwargs)
+        if comment_age:
+            if comment_age <= threshold:
+                print_debug('comment found below threshold')
+                return True
+        elif age > threshold:
+            print_debug('no comment found and above threshold')
+            all_comment = False
+            if threshold_require:
+                return False
+            else:
+                continue
+        else:
+            print_debug('no comment found, but below threshold')
+
+    print_debug('all comments: {}'.format(all_comment))
+    return all_comment
+
+def status(apiurl):
+    # TODO If request ordering via api (openSUSE/open-build-service#4108) is
+    # provided this can be implemented much more cleanly by looking for 
positive
+    # activity (review changes) in threshold. Without sorting, some sampling of
+    # all requests accepted are returned which is not useful.
+    # TODO legal-auto, does not make comments so pending the above.
+    bots = [
+        # No open requests older than 2 hours.
+        ['factory-auto'],
+        # No open requests older than 2 hours or all old requests have comment.
+        ['leaper', 'user', True, 'Leaper'],
+        # As long as some comment made in last 6 hours.
+        ['repo-checker', 'user', 'project', 'RepoChecker', 6 * 3600, False],
+        # Different algorithm, any staging in last 24 hours.
+        ['staging-bot', 'user', False, None, 24 * 3600],
+    ]
+
+    all_alive = True
+    for bot in bots:
+        result = check(apiurl, *bot)
+        if not result:
+            all_alive = False
+        print('{} = {}'.format(bot[0], result))
+
+    return all_alive
+
+def main(args):
+    conf.get_config(override_apiurl=args.apiurl)
+    conf.config['debug'] = args.debug
+    apiurl = conf.config['apiurl']
+    return not status(apiurl)
+
+
+if __name__ == '__main__':
+    description = 'Check the status of the staging workflow bots.'
+    parser = argparse.ArgumentParser(description=description)
+    parser.add_argument('-A', '--apiurl', help='OBS instance API URL')
+    parser.add_argument('-d', '--debug', action='store_true', help='print 
useful debugging info')
+    parser.add_argument('-p', '--project', default='openSUSE:Factory', 
help='OBS project')
+    args = parser.parse_args()
+
+    sys.exit(main(args))

++++++ openSUSE-release-tools.obsinfo ++++++
--- /var/tmp/diff_new_pack.QUOORb/_old  2018-01-29 15:00:27.810095760 +0100
+++ /var/tmp/diff_new_pack.QUOORb/_new  2018-01-29 15:00:27.810095760 +0100
@@ -1,5 +1,5 @@
 name: openSUSE-release-tools
-version: 20180126.2c8c597
-mtime: 1516999327
-commit: 2c8c5976739d9e0154bd7ceb651f1085dce01a38
+version: 20180126.574cfe8
+mtime: 1516999772
+commit: 574cfe8e1245e98922150a574df1a27dbc9c98af
 


Reply via email to