summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Konarev2022-05-06 17:13:34 +0300
committerAlexander Konarev2022-05-06 17:13:34 +0300
commitb32fb33c3f0e42210aaebce7d2ffdaa2eddabd2d (patch)
tree71fc44bbdbc7f169981dd851d7355f5f352977c4
parenta53c7ce0847c1e12078ae4993124e5f9e528f418 (diff)
downloadaur-b32fb33c3f0e42210aaebce7d2ffdaa2eddabd2d.tar.gz
fix downloading bugs
-rw-r--r--.SRCINFO4
-rwxr-xr-xPKGBUILD7
-rw-r--r--download.py53
3 files changed, 36 insertions, 28 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 8df535677796..87374dfc66af 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = aksusbd-bin
pkgdesc = Sentinel AKSUSB daemon supporting Sentinel HASP, HASP HL, HASP4 and Hardlock keys.
- pkgver = 8.41.1
+ pkgver = 8.41
pkgrel = 1
url = https://supportportal.thalesgroup.com
arch = i686
@@ -18,6 +18,6 @@ pkgbase = aksusbd-bin
source = 0001-patch.patch
source = download.py
sha256sums = 6fcb6c4fcba1d01c1b3e68258e95297c323b2cbe8ee75c0a14ac0e9006926312
- sha256sums = 91cb42b81b77b21f29552da1affa3e4d801fef5cbf2910c96f5a728cded952b3
+ sha256sums = 955d038821b7deee240f98713b39d6aa8aae12b86b8a4cb8d2005e8e22b9cd79
pkgname = aksusbd-bin
diff --git a/PKGBUILD b/PKGBUILD
index b29cb3f00fe2..e571276c7b16 100755
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,7 +2,7 @@
# Maintainer: Alexander Konarev (avkonarev) <AVKonarev@gmail.com>
pkgname=aksusbd-bin
-pkgver=8.41.1
+pkgver=8.41
pkgrel=1
pkgdesc="Sentinel AKSUSB daemon supporting Sentinel HASP, HASP HL, HASP4 and Hardlock keys."
arch=('i686' 'x86_64')
@@ -16,7 +16,7 @@ source=(
"0001-patch.patch"
"download.py")
sha256sums=('6fcb6c4fcba1d01c1b3e68258e95297c323b2cbe8ee75c0a14ac0e9006926312'
- '91cb42b81b77b21f29552da1affa3e4d801fef5cbf2910c96f5a728cded952b3')
+ '955d038821b7deee240f98713b39d6aa8aae12b86b8a4cb8d2005e8e22b9cd79')
makedepends=('libarchive'
'python'
'python-pip'
@@ -30,7 +30,8 @@ _nver=""
_nrel=""
pkgver() {
- echo $_nver.$_nrel
+ #echo $_nver.$_nrel
+ echo $_nver
}
prepare(){
diff --git a/download.py b/download.py
index d99063e53d2c..3d2cd7a0232d 100644
--- a/download.py
+++ b/download.py
@@ -1,11 +1,13 @@
import os
-import sys
-import glob
import re
+import sys
from pathlib import Path
from time import sleep
+
from selenium import webdriver
from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.support.ui import WebDriverWait
def humansize(nbytes):
@@ -19,40 +21,40 @@ def humansize(nbytes):
def message(msg):
- bar = "\u2588"
- sys.stdout.write(bar+"\r"+msg)
+ _bar = "\u2588"
+ sys.stdout.write(_bar+"\r"+msg)
# sys.stdout.flush()
_ldk_filename = "Sentinel_LDK_Linux_Run-time_Installer_script.tar.gz"
+
def wait_downloading():
timeout_start = 60
timeout_download = 60*5
target_path = Path(_ldk_filename)
-
- if not (target_path.exists() and target_path.stat().st_size>0):
- message(f"waiting for download to start {timeout_start} sec.")
+
+ if not (target_path.exists() and target_path.stat().st_size > 0):
while not list(Path('.').glob('*.part')) and timeout_start:
+ message(f"waiting for download to start {timeout_start} sec.")
sleep(1)
- timeout_start-=1
-
+ timeout_start -= 1
+
if not list(Path('.').glob('*.part')):
raise Exception("Download failed")
-
- while (tmp_files:=list(Path('.').glob('*.part'))) and timeout_download:
+
+ while (tmp_files := list(Path('.').glob('*.part'))) and timeout_download:
filesize = os.path.getsize(tmp_files[0])
message(f"Downloading file: {humansize(filesize)} wait {timeout_download} sec.")
sleep(1)
- timeout_download-=1
+ timeout_download -= 1
- if not (target_path.exists() and target_path.stat().st_size>0):
+ if not (target_path.exists() and target_path.stat().st_size > 0):
raise Exception("Download failed")
message("Downloading complete\n")
-print("Download init..")
options = webdriver.FirefoxOptions()
options.headless = True
options.set_preference("browser.download.folderList", 2)
@@ -62,26 +64,31 @@ options.set_preference(
"browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
try:
+ print("Selenium start..")
browser = webdriver.Firefox(options=options)
- browser.implicitly_wait(60)
+ print("Searching url..")
browser.get(
'https://supportportal.gemalto.com/csm?id=kb_article_view&sysparm_article=KB0018315#')
- browser.find_element(By.LINK_TEXT, "DOW0003342").click()
- browser.find_element(By.CSS_SELECTOR, ".btn-success").click()
-
+ wait = WebDriverWait(browser, 10)
+ element = wait.until(EC.element_to_be_clickable((By.LINK_TEXT, "DOW0003342")))
+ element.click()
+ element = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".btn-success")))
+ element.click()
+
wait_downloading()
-except:
- exit(1)
+except Exception as error:
+ print(error)
+ sys.exit(1)
finally:
browser.quit()
os.system(f"tar -xvzf {_ldk_filename}")
for root, dirs, files in os.walk(os.getcwd()):
for file in files:
- if match:=re.match("aksusbd-(\d+\.\d+)\.(\d+)", file):
+ if match := re.match(r"aksusbd-(\d+\.\d+)\.(\d+)", file):
_vers, _rel = match.groups()
os.system(f'echo "{_vers} {_rel}">version.txt')
- exit(0)
-exit(1) \ No newline at end of file
+ sys.exit(0)
+sys.exit(1)