-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkUpdateNoMachine.py
50 lines (45 loc) · 1.61 KB
/
checkUpdateNoMachine.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests
import bs4
from bs4 import BeautifulSoup
import tqdm
import os
import subprocess
import urllib3
from nomachineScraper import downloadNomachineDeb
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def CheckNewVersion():
url = 'https://downloads.nomachine.com/download/?id=5'
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
# print(soup)
# #parse html and get link from id=link_download
link = soup.find(id='link_download')
#parse link and get only href
href = link.get('href')
print(href.split('/')[-1])
return href.split('/')[-1]
def compareVersion():
#check latestVersion.txt content and compare with CheckNewVersion()
#if not found download and update latestVersion.txt
#if found do sleep
#if not found download and update latestVersion.txt
#read latestVersion.txt, check all line
#save value form CheckNewVersion() to variable
#if variable not in latestVersion.txt
#download and update latestVersion.txt
#if variable in latestVersion.txt
#do sleep
#if not found download and update latestVersion.txt
currentVersion = CheckNewVersion()
#open latestVersion.txt first line and compare with currentVersion
with open('latestVersion.txt', 'r') as file:
data = file.read()
if currentVersion == data:
print('Already Latest Version')
else:
print('New Version Released')
#downloadNomachineDeb()
downloadNomachineDeb()
with open('latestVersion.txt', 'w+') as file:
file.write(currentVersion)
compareVersion()