mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-29 17:27:17 +00:00
commit
d2c974569e
1 changed files with 11 additions and 0 deletions
|
@ -3,6 +3,7 @@ import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -70,6 +71,14 @@ class Repo:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Failed to run {cmd} for {self.id}: {e}")
|
print(f"Failed to run {cmd} for {self.id}: {e}")
|
||||||
|
|
||||||
|
def cleanup(self, num_to_keep: int) -> None:
|
||||||
|
files = os.listdir(self.outputdir)
|
||||||
|
repo_images = [f for f in files if f.startswith(self.name)]
|
||||||
|
if len(repo_images) > num_to_keep:
|
||||||
|
repo_images.sort(key=lambda x: os.path.getmtime(os.path.join(self.outputdir, x)))
|
||||||
|
for image in repo_images[:-num_to_keep]:
|
||||||
|
shutil.rmtree(os.path.join(self.outputdir, image))
|
||||||
|
|
||||||
class GitHub(Repo):
|
class GitHub(Repo):
|
||||||
"""Class for tracking GitHub repositories."""
|
"""Class for tracking GitHub repositories."""
|
||||||
|
|
||||||
|
@ -126,8 +135,10 @@ def main():
|
||||||
while True:
|
while True:
|
||||||
for repo in repos:
|
for repo in repos:
|
||||||
repo.build()
|
repo.build()
|
||||||
|
repo.cleanup(num_to_keep=3)
|
||||||
for package in aptpkg:
|
for package in aptpkg:
|
||||||
package.build()
|
package.build()
|
||||||
|
repo.cleanup(num_to_keep=3)
|
||||||
sleep(config["check_interval"])
|
sleep(config["check_interval"])
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue