FeedReader: now able to post multiple issues on a new version
This commit is contained in:
parent
7c5e429ae0
commit
11c3103e3b
2 changed files with 30 additions and 27 deletions
29
config.py
29
config.py
|
|
@ -18,15 +18,16 @@ import _secrets
|
||||||
class UDSClientReader(FeedReader):
|
class UDSClientReader(FeedReader):
|
||||||
'''Custom feed reader for UDSClient, whose version number appears in a .js file.'''
|
'''Custom feed reader for UDSClient, whose version number appears in a .js file.'''
|
||||||
|
|
||||||
def __init__(self, target: IssuePoster):
|
def __init__(self, targets: IssuePoster):
|
||||||
'''Creates a new UDSClient Reader.'''
|
'''Creates a new UDSClient Reader.'''
|
||||||
super().__init__("udsclient", "https://polilabs.upv.es/uds/utility/uds.js", target)
|
super().__init__("udsclient", "https://polilabs.upv.es/uds/utility/uds.js", targets)
|
||||||
|
|
||||||
def read_feed(self) -> bool | None:
|
def read_feed(self) -> bool | None:
|
||||||
'''Checks for a new version of udsclient, by checking a .js file.'''
|
'''Checks for a new version of udsclient, by checking a .js file.'''
|
||||||
get = requests.get(self.url, timeout = TIMEOUT)
|
get = requests.get(self.url, timeout = TIMEOUT)
|
||||||
if not self.target.check_req(get, self.name):
|
for target in self.targets:
|
||||||
return None
|
if not target.check_req(get, self.name):
|
||||||
|
return None
|
||||||
match = re.search(r"[/a-zA-Z_-]+udsclient\d+-(\d+\.\d+\.\d+)\.tar\.gz", get.text)
|
match = re.search(r"[/a-zA-Z_-]+udsclient\d+-(\d+\.\d+\.\d+)\.tar\.gz", get.text)
|
||||||
if not match:
|
if not match:
|
||||||
return None
|
return None
|
||||||
|
|
@ -55,7 +56,7 @@ class NCAppReader(GithubReader):
|
||||||
'''All GitHub releases readers that must alert Forgejo's `archpkgs`.'''
|
'''All GitHub releases readers that must alert Forgejo's `archpkgs`.'''
|
||||||
def __init__(self, app, project):
|
def __init__(self, app, project):
|
||||||
super().__init__(name = app, project = project,
|
super().__init__(name = app, project = project,
|
||||||
target = CGJForgejoPoster("archpkgs/" + app))
|
targets = CGJForgejoPoster("archpkgs/" + app))
|
||||||
|
|
||||||
|
|
||||||
# Issue Posters
|
# Issue Posters
|
||||||
|
|
@ -70,20 +71,18 @@ FEED_READERS = [
|
||||||
# Name FeedType Project TargetProject
|
# Name FeedType Project TargetProject
|
||||||
################################ Software used in MIST (Gitlab) ###################################
|
################################ Software used in MIST (Gitlab) ###################################
|
||||||
# LanguageTool GHTags languagetool-org/languagetool 36 (sysadmin/boira)
|
# LanguageTool GHTags languagetool-org/languagetool 36 (sysadmin/boira)
|
||||||
GithubTagReader(name = "LanguageTool", project = "languagetool-org/languagetool",
|
GithubTagReader(name = "LanguageTool", project = "languagetool-org/languagetool",
|
||||||
target = GITLAB_BOIRA_CARGAJI),
|
targets = GITLAB_BOIRA_CARGAJI),
|
||||||
# meshcentral GHReleases Ylianst/MeshCentral 36 (sysadmin/boira)
|
# meshcentral GHReleases Ylianst/MeshCentral 36 (sysadmin/boira)
|
||||||
GithubReader(name = "meshcentral", project = "Ylianst/MeshCentral",
|
# meshcentral GHReleases Ylianst/MeshCentral archpkgs/meshcentral
|
||||||
target = GITLAB_BOIRA_CARGAJI),
|
GithubReader(name = "meshcentral", project = "Ylianst/MeshCentral",
|
||||||
|
targets = [GITLAB_BOIRA_CARGAJI, CGJForgejoPoster("archpkgs/meshcentral")]),
|
||||||
# python3-snakes PIPY snakes 37 (packages/python3-snakes)
|
# python3-snakes PIPY snakes 37 (packages/python3-snakes)
|
||||||
PIPYReader(name = "python3-snakes", package = "snakes",
|
PIPYReader(name = "python3-snakes", package = "snakes",
|
||||||
target = GITLAB_SNAKES_CARGAJI),
|
targets = GITLAB_SNAKES_CARGAJI),
|
||||||
################################ Software that I package (Forgejo) ################################
|
################################ Software that I package (Forgejo) ################################
|
||||||
# pdfbooklet GHReleases Averell7/PdfBooklet archpkgs/pdfbooklet
|
# pdfbooklet GHReleases Averell7/PdfBooklet archpkgs/pdfbooklet
|
||||||
NCAppReader(app = "pdfbooklet", project = "Averell7/PdfBooklet"),
|
NCAppReader(app = "pdfbooklet", project = "Averell7/PdfBooklet"),
|
||||||
# meshcentral GHReleases Ylianst/MeshCentral archpkgs/meshcentral
|
|
||||||
GithubReader(name = "meshcentral", project = "Ylianst/MeshCentral",
|
|
||||||
target = CGJForgejoPoster("archpkgs/meshcentral")),
|
|
||||||
# nc-cospend GHReleases eneiluj/cospend-nc archpkgs/nextcloud-app-cospend
|
# nc-cospend GHReleases eneiluj/cospend-nc archpkgs/nextcloud-app-cospend
|
||||||
NCAppReader(app = "nextcloud-app-cospend", project = "eneiluj/cospend-nc"),
|
NCAppReader(app = "nextcloud-app-cospend", project = "eneiluj/cospend-nc"),
|
||||||
# nc-f_autotagging GHReleases
|
# nc-f_autotagging GHReleases
|
||||||
|
|
@ -103,7 +102,7 @@ FEED_READERS = [
|
||||||
# nc-socialsharing GHReleases nextcloud/socialsharing archpkgs/nextcloud-app-socialsharing
|
# nc-socialsharing GHReleases nextcloud/socialsharing archpkgs/nextcloud-app-socialsharing
|
||||||
NCAppReader(app = "nextcloud-app-socialsharing", project = "nextcloud/socialsharing"),
|
NCAppReader(app = "nextcloud-app-socialsharing", project = "nextcloud/socialsharing"),
|
||||||
# udsclient Custom --- archpkgs/udsclient
|
# udsclient Custom --- archpkgs/udsclient
|
||||||
UDSClientReader(target = CGJForgejoPoster(project="archpkgs/udsclient")),
|
UDSClientReader(targets = CGJForgejoPoster(project="archpkgs/udsclient")),
|
||||||
# vigil GHReleases valeriansaliou/vigil archpkgs/vigil
|
# vigil GHReleases valeriansaliou/vigil archpkgs/vigil
|
||||||
NCAppReader(app = "vigil", project = "valeriansaliou/vigil"),
|
NCAppReader(app = "vigil", project = "valeriansaliou/vigil"),
|
||||||
# vigil-local GHReleases valeriansaliou/vigil-local archpkgs/vigil-local
|
# vigil-local GHReleases valeriansaliou/vigil-local archpkgs/vigil-local
|
||||||
|
|
|
||||||
|
|
@ -157,11 +157,11 @@ class ForgejoPoster(IssuePoster):
|
||||||
class FeedReader:
|
class FeedReader:
|
||||||
'''Class to read an RSS/Atom feed and post an issue if a new version is found.'''
|
'''Class to read an RSS/Atom feed and post an issue if a new version is found.'''
|
||||||
|
|
||||||
def __init__(self, name: str, url: str, target: IssuePoster):
|
def __init__(self, name: str, url: str, targets: list[IssuePoster]):
|
||||||
'''Create a new feed reader'''
|
'''Create a new feed reader'''
|
||||||
self.name = name
|
self.name = name
|
||||||
self.url = url
|
self.url = url
|
||||||
self.target = target
|
self.targets = targets if type(targets) == list else [targets]
|
||||||
self.version_file = CONFIG_DIR + self.name
|
self.version_file = CONFIG_DIR + self.name
|
||||||
self.etag_file = CONFIG_DIR + self.name + ".etag"
|
self.etag_file = CONFIG_DIR + self.name + ".etag"
|
||||||
self.beta_strings = [ "nightly", "beta", "alpha", "rc", "pr" ]
|
self.beta_strings = [ "nightly", "beta", "alpha", "rc", "pr" ]
|
||||||
|
|
@ -223,10 +223,14 @@ class FeedReader:
|
||||||
if match:
|
if match:
|
||||||
return False
|
return False
|
||||||
# Match 2: with repository issues
|
# Match 2: with repository issues
|
||||||
if not self.target.issue_exists(self.name, version):
|
issues_posted = True
|
||||||
# Post the issue
|
for target in self.targets:
|
||||||
if not self.target.post_issue(self.name, version, link):
|
if not target.issue_exists(self.name, version):
|
||||||
return False
|
# Post the issue
|
||||||
|
if not target.post_issue(self.name, version, link):
|
||||||
|
issues_posted = False
|
||||||
|
if not issues_posted:
|
||||||
|
return False
|
||||||
# Save to disk
|
# Save to disk
|
||||||
if not os.path.isdir(CONFIG_DIR):
|
if not os.path.isdir(CONFIG_DIR):
|
||||||
os.makedirs(CONFIG_DIR)
|
os.makedirs(CONFIG_DIR)
|
||||||
|
|
@ -238,9 +242,9 @@ class FeedReader:
|
||||||
class PIPYReader(FeedReader):
|
class PIPYReader(FeedReader):
|
||||||
'''Reader specialized in the PIPY repository.'''
|
'''Reader specialized in the PIPY repository.'''
|
||||||
|
|
||||||
def __init__(self, name: str, package: str, target: IssuePoster):
|
def __init__(self, name: str, package: str, targets: IssuePoster):
|
||||||
'''Create a new PIPY reader for the given package.'''
|
'''Create a new PIPY reader for the given package.'''
|
||||||
super().__init__(name, f"https://pypi.org/rss/project/{package}/releases.xml", target)
|
super().__init__(name, f"https://pypi.org/rss/project/{package}/releases.xml", targets)
|
||||||
|
|
||||||
def entry_get_version(self, entry: dict[str, Any]) -> tuple[str, str]:
|
def entry_get_version(self, entry: dict[str, Any]) -> tuple[str, str]:
|
||||||
return entry.title, entry.title
|
return entry.title, entry.title
|
||||||
|
|
@ -252,9 +256,9 @@ class PIPYReader(FeedReader):
|
||||||
class GithubTagReader(FeedReader):
|
class GithubTagReader(FeedReader):
|
||||||
'''Reader specialized in GitHub Tags Atom feed.'''
|
'''Reader specialized in GitHub Tags Atom feed.'''
|
||||||
|
|
||||||
def __init__(self, name: str, project: str, target: IssuePoster):
|
def __init__(self, name: str, project: str, targets: IssuePoster):
|
||||||
'''Create a new GitHub Tags reader for the given project.'''
|
'''Create a new GitHub Tags reader for the given project.'''
|
||||||
super().__init__(name, f"https://github.com/{project}/tags.atom", target)
|
super().__init__(name, f"https://github.com/{project}/tags.atom", targets)
|
||||||
|
|
||||||
def entry_get_version(self, entry: dict[str, Any]) -> tuple[str, str]:
|
def entry_get_version(self, entry: dict[str, Any]) -> tuple[str, str]:
|
||||||
return entry.title, str(entry.id)
|
return entry.title, str(entry.id)
|
||||||
|
|
@ -266,8 +270,8 @@ class GithubTagReader(FeedReader):
|
||||||
class GithubReader(GithubTagReader):
|
class GithubReader(GithubTagReader):
|
||||||
'''Reader specialized in GitHub releases' Atom feed.'''
|
'''Reader specialized in GitHub releases' Atom feed.'''
|
||||||
|
|
||||||
def __init__(self, name: str, project: str, target: IssuePoster):
|
def __init__(self, name: str, project: str, targets: IssuePoster):
|
||||||
super().__init__(name, project, target)
|
super().__init__(name, project, targets)
|
||||||
self.url = f"https://github.com/{project}/releases.atom"
|
self.url = f"https://github.com/{project}/releases.atom"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue