Skip to content

Commit

Permalink
legal: Only wait 2 hours for legal reviews for openSUSE:Factory
Browse files Browse the repository at this point in the history
The churn rate of openSUSE:Factory is too high for legal to catch up
these days, so we turn the default. Legal reviews for Factory are no longer
blocking, but if we need the same package for another project or
product, the lawyers had some time to look at it.

And if we find a package not acceptable, we'll delete it from Factory
later on. This may get painful, but the current legal situation is
painful too.
  • Loading branch information
coolo committed Mar 30, 2021
1 parent 75c001c commit a9a3247
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions legal-auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
import logging
from optparse import OptionParser
import cmdln
from dateutil.parser import parse
from datetime import timezone, timedelta
import requests as REQ
import json
import time
import yaml

from urllib.error import HTTPError

try:
from xml.etree import cElementTree as ET
except ImportError:
import cElementTree as ET
from lxml import etree as ET

import osc.conf
import osc.core
Expand All @@ -30,7 +28,6 @@

http_GET = osc.core.http_GET


class LegalAuto(ReviewBot.ReviewBot):

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -87,6 +84,18 @@ def create_db_entry(self, src_project, src_package, src_rev):
request = REQ.post(url, headers=self.legaldb_headers).json()
return [package['id']]

def valid_for_opensuse(self, target_project, report):
if target_project != "openSUSE:Factory":
return False
indexed = report.get('indexed', None)
if not indexed:
return False
datetime = parse(indexed)
# give the legaldb 2 hours to find a match (so we prefer acceptable/correct over preliminary)
if datetime.now(timezone.utc) - datetime < timedelta(hours=2):
return False
return True

def check_source_submission(self, src_project, src_package, src_rev, target_project, target_package):
self.logger.info("%s/%s@%s -> %s/%s" % (src_project,
src_package, src_rev, target_project, target_package))
Expand All @@ -97,6 +106,7 @@ def check_source_submission(self, src_project, src_package, src_rev, target_proj
src_project, src_package, src_rev)
if not to_review:
return None
self.message = None
for pack in to_review:
url = osc.core.makeurl(self.legaldb, ['package', str(pack)])
report = REQ.get(url, headers=self.legaldb_headers).json()
Expand All @@ -112,6 +122,14 @@ def check_source_submission(self, src_project, src_package, src_rev, target_proj
package = REQ.post(url, headers=self.legaldb_headers).json()
# reopen
return None
if state == 'new' and self.valid_for_opensuse(target_project, report):
self.message = 'The legal review is accepted preliminary. The package may require actions later on.'
# reduce legal review priority - we're no longer waiting
url = osc.core.makeurl(
self.legaldb, ['package', str(pack)], {'priority': 1})
if not self.dryrun:
REQ.patch(url, headers=self.legaldb_headers)
continue
if not state in ['acceptable', 'correct', 'unacceptable']:
return None
if state == 'unacceptable':
Expand All @@ -129,7 +147,8 @@ def check_source_submission(self, src_project, src_package, src_rev, target_proj
return None
return False
# print url, json.dumps(report)
self.message = 'ok'
if not self.message:
self.message = 'ok'
return True

def check_one_request(self, req):
Expand Down

0 comments on commit a9a3247

Please sign in to comment.