Skip to content

Commit

Permalink
Updated v2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-the-hito committed Mar 5, 2024
1 parent 8ee434c commit 309c4af
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 11 deletions.
82 changes: 72 additions & 10 deletions Strawberry/Strawberry.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
import asyncio
import json
import mistune
import urllib3
import logging
import requests
import html2text
from bs4 import BeautifulSoup

app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)
Expand Down Expand Up @@ -157,7 +162,7 @@ def setUpMainWindow(self):
widg2.setLayout(blay2)

widg3 = QWidget()
lbl1 = QLabel('Version 2.0.3', self)
lbl1 = QLabel('Version 2.0.4', self)
blay3 = QHBoxLayout()
blay3.setContentsMargins(0, 0, 0, 0)
blay3.addStretch()
Expand Down Expand Up @@ -620,25 +625,31 @@ def __init__(self):

def initUI(self): # 说明页面内信息

lbl = QLabel('Current Version: 2.0.3', self)
lbl.move(110, 75)
self.lbl = QLabel('Current Version: v2.0.4', self)
self.lbl.move(30, 45)

lbl0 = QLabel('Check Now:', self)
lbl0.move(30, 20)
lbl0 = QLabel('Download Update:', self)
lbl0.move(30, 75)

bt1 = QPushButton('Github', self)
lbl1 = QLabel('Latest Version:', self)
lbl1.move(30, 15)

self.lbl2 = QLabel('', self)
self.lbl2.move(122, 15)

bt1 = QPushButton('Google Drive', self)
bt1.setFixedWidth(120)
bt1.clicked.connect(self.upd)
bt1.move(110, 15)
bt1.move(150, 75)

bt2 = QPushButton('Dropbox', self)
bt2.setFixedWidth(120)
bt2.clicked.connect(self.upd2)
bt2.move(110, 45)
bt2.move(150, 105)

self.resize(300, 110)
self.resize(300, 150)
self.center()
self.setWindowTitle('Check for Updates')
self.setWindowTitle('Strawberry Updates')
self.setFocus()
self.setWindowFlags(Qt.WindowType.WindowStaysOnTopHint)

Expand All @@ -656,6 +667,54 @@ def center(self): # 设置窗口居中

def activate(self): # 设置窗口显示
self.show()
self.checkupdate()

def checkupdate(self):
targetURL = 'https://github.com/Ryan-the-hito/Strawberry/releases'
try:
# Fetch the HTML content from the URL
urllib3.disable_warnings()
logging.captureWarnings(True)
s = requests.session()
s.keep_alive = False # 关闭多余连接
response = s.get(targetURL, verify=False)
response.encoding = 'utf-8'
html_content = response.text
# Parse the HTML using BeautifulSoup
soup = BeautifulSoup(html_content, "html.parser")
# Remove all images from the parsed HTML
for img in soup.find_all("img"):
img.decompose()
# Convert the parsed HTML to plain text using html2text
text_maker = html2text.HTML2Text()
text_maker.ignore_links = True
text_maker.ignore_images = True
plain_text = text_maker.handle(str(soup))
# Convert the plain text to UTF-8
plain_text_utf8 = plain_text.encode(response.encoding).decode("utf-8")

for i in range(10):
plain_text_utf8 = plain_text_utf8.replace('\n\n\n\n', '\n\n')
plain_text_utf8 = plain_text_utf8.replace('\n\n\n', '\n\n')
plain_text_utf8 = plain_text_utf8.replace(' ', ' ')
plain_text_utf8 = plain_text_utf8.replace(' ', ' ')

pattern2 = re.compile(r'(v\d+\.\d+\.\d+)\sLatest')
result = pattern2.findall(plain_text_utf8)
result = ''.join(result)
nowversion = self.lbl.text().replace('Current Version: ', '')
if result == nowversion:
alertupdate = result + '. You are up to date!'
self.lbl2.setText(alertupdate)
self.lbl2.adjustSize()
else:
alertupdate = result + ' is ready!'
self.lbl2.setText(alertupdate)
self.lbl2.adjustSize()
except:
alertupdate = 'No Intrenet'
self.lbl2.setText(alertupdate)
self.lbl2.adjustSize()


class CustomDialog_warn(QDialog): # 提醒检查路径
Expand Down Expand Up @@ -8958,6 +9017,9 @@ def addcit2(self):

self.leii2.clear()

with open(BasePath + 'filename.txt', 'w', encoding='utf-8') as f0:
f0.write('')

def clinp(self):
if self.textii2.toPlainText() != '' and self.leii1.text() != '':
path1 = codecs.open(BasePath + 'path_scr.txt', 'r', encoding='utf-8').read()
Expand Down
2 changes: 1 addition & 1 deletion Strawberry/Strawberry.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

block_cipher = None

__version__ = '2.0.3'
__version__ = '2.0.4'


a = Analysis(
Expand Down

0 comments on commit 309c4af

Please sign in to comment.