diff options
author | SergioRosello | 2020-04-25 22:30:38 +0200 |
---|---|---|
committer | SergioRosello | 2020-04-25 22:30:38 +0200 |
commit | 83ff9847a7d63521614b7aa1dfb672aa28a95c74 (patch) | |
tree | fac1b6b68a305294f4fdc8cd3e4cb31d80fc1b60 | |
parent | 03a313d7c3b9c6e20c144978c2604eba331a714a (diff) | |
download | aur-83ff9847a7d63521614b7aa1dfb672aa28a95c74.tar.gz |
Created local and remote version checkers
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | requirements.txt | 17 | ||||
-rw-r--r-- | updater.py | 78 |
3 files changed, 96 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index fccf0edb9402..3b7d56239a2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ src/ +.venv/* *.rpm notes.md diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000000..d25c46bd36f5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,17 @@ +astroid==2.3.3 +certifi==2020.4.5.1 +chardet==3.0.4 +idna==2.9 +isort==4.3.21 +jedi==0.17.0 +lazy-object-proxy==1.4.3 +lxml==4.5.0 +mccabe==0.6.1 +parso==0.7.0 +pylint==2.4.4 +requests==2.23.0 +selenium==3.141.0 +six==1.14.0 +urllib3==1.25.9 +wrapt==1.11.2 +yapf==0.30.0 diff --git a/updater.py b/updater.py new file mode 100644 index 000000000000..9d4a68c39f94 --- /dev/null +++ b/updater.py @@ -0,0 +1,78 @@ +import re +from selenium import webdriver +from selenium.webdriver.chrome.options import Options + + +def read_file(): + pkgbuild = open("./PKGBUILD", "w+") + print(pkgbuild.read()) + + +# Configure chrome webdriver options +def configure_chrome_webdriver(): + options = Options() + options.add_argument("--headless") # Runs Chrome in headless mode. + options.add_argument('--no-sandbox') # # Bypass OS security model + options.add_argument('start-maximized') + options.add_argument('disable-infobars') + options.add_argument("--disable-extensions") + return options + + +# Connects to website and scrapes latest screen-desktop version +def get_remote_version(): + options = configure_chrome_webdriver() + driver = webdriver.Chrome(options=options) + driver.get("https://screen.so/#/download") + elem = driver.find_element_by_css_selector("p[class='version']").text + assert "No results found." not in driver.page_source + version = re.search(r'\d.*', elem).group(0) + driver.close() + return version + + +# Opens PKGBUILD file, and searhces for the version number +def get_local_version(): + myfile = open("./PKGBUILD", "rt") # open lorem.txt for reading text + pkgbuild = myfile.read() # read the entire file into a string + myfile.close() + version = re.search(r'pkgver=(\d.*)', pkgbuild).group(1) + return version + + +# Check wheather the download file has changed +# We will need to check the source +# with the actual package (Which we have in the pkgbuild file) +def check_updated(): + updated = False + remote_version = get_remote_version() + local_version = get_local_version() + if local_version != remote_version: + updated = True + return updated + + +# Updates the pkgbuild if the screen-desktop file has changed from source +#1. Modify the PKGBUILD to fit the new version +# * `nvim PKGBUILD` +#2. calculate the new hash +# * `makepkg -g` +#3. Modify the PKGBUILD to include the new md5sum +# * `nvim PKGBUILD` +#4. Update the .SRCINFO file +# * `makepkg --printsrcinfo > .SRCINFO` +#5. Commit and push +# * `gaa & gca -m "Message" & ggpush` +#6. Clean resulting workspace +def update_pkgbuild(): + print("todo") + + +def main(): + configure_chrome_webdriver() + if check_updated(): + update_pkgbuild() + + +if __name__ == "__main__": + main() |