def get_download_url(self): builder_url = "https://builder.blender.org" content = urlopen(builder_url + "/download").read() soup = BeautifulSoup(content, 'html.parser') platform = get_platform() if platform == 'Windows': build_url = soup.find( href=re.compile(r'blender-.+win.+64'))['href'] elif platform == 'Linux': build_url = soup.find( href=re.compile(r'blender-.+linux.+64'))['href'] # Start Experimental builder_url = "https://builder.blender.org" content = urlopen(builder_url + "/download").read() soup = BeautifulSoup(content, 'html.parser') platform = get_platform() links = [] if platform == 'Windows': for link in soup.find_all(href=re.compile(r'blender-.+win.+64')): links.append(builder_url + link['href']) # print(link) elif platform == 'Linux': for link in soup.find_all(href=re.compile(r'blender-.+linux.+64')): links.append(builder_url + link['href']) print("Daily Builds") print(links) content = urlopen(builder_url + "/download/branches").read() soup = BeautifulSoup(content, 'html.parser') links = [] if platform == 'Windows': for link in soup.find_all(href=re.compile(r'blender-.+win.+64')): links.append(builder_url + link['href']) # print(link.get(re.compile(r'build-var.+'))) elif platform == 'Linux': for link in soup.find_all(href=re.compile(r'blender-.+linux.+64')): links.append(builder_url + link['href']) print("Experimental Branches") print(links) # End Experimental return builder_url + build_url
def run(self): platform = get_platform() while self.is_running: try: self.download_url = self.get_download_url() commit = self.download_url.split('-', )[2] new_version = True if self.parent.layouts: if (commit in self.parent.layouts[0].git or commit in self.parent.progressBar.text()): new_version = False if new_version: datetime = self.get_commit_datetime(commit) if platform == 'Windows': locale.setlocale(locale.LC_ALL, 'eng_usa') elif platform == 'Linux': locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') self.strptime = time.strptime(datetime, '%a, %d %b %Y %H:%M:%S %z') strftime = time.strftime("%d-%b-%H:%M", self.strptime) info = urlopen(self.download_url).info() size = str(int(info['content-length']) // 1048576) + " MB" display_name = "Git-" + commit + " | " + strftime + " | " + size self.new_version_obtained.emit(display_name) except urllib.error.URLError as e: print(e) QThread.sleep(600) return
def __init__(self, parent, url, strptime): QThread.__init__(self) self.parent = parent self.url = url self.strptime = strptime self.root_folder = self.parent.settings.value('root_folder') self.is_running = False self.platform = get_platform()
def get_download_url(self): builder_url = "https://builder.blender.org" content = urlopen(builder_url + "/download").read() soup = BeautifulSoup(content, 'html.parser') platform = get_platform() if platform == 'Windows': build_url = soup.find( href=re.compile(r'blender-.+win.+64'))['href'] elif platform == 'Linux': build_url = soup.find( href=re.compile(r'blender-.+linux.+64'))['href'] return builder_url + build_url
import os import re import shutil import subprocess import tarfile import time import zipfile from pathlib import Path from subprocess import DEVNULL, PIPE, STDOUT from urllib.request import urlopen from PyQt5.QtCore import QThread, pyqtSignal from _platform import get_platform if get_platform() == 'Windows': from subprocess import CREATE_NO_WINDOW class BuildLoader(QThread): finished = pyqtSignal('PyQt_PyObject') block_abortion = pyqtSignal() progress_changed = pyqtSignal('PyQt_PyObject', 'PyQt_PyObject', 'PyQt_PyObject') def __init__(self, parent, url, strptime): QThread.__init__(self) self.parent = parent self.url = url self.strptime = strptime self.root_folder = self.parent.settings.value('root_folder')
def __init__(self, app): super().__init__() self.app = app self.platform = get_platform() self.setWindowFlags(Qt.FramelessWindowHint) self.setupUi(self) # Read icons self.icon_app = QIcon(":/icons/app.svg") self.icon_star = QIcon(":/icons/star.png") self.icon_trash = QIcon(":/icons/delete.png") self.icon_quit = QIcon(":/icons/quit.png") self.icon_fake = QIcon(":/icons/fake.svg") # Read settings self.settings = QSettings('b3d_version_manager', 'settings') is_register_blend = self.settings.value('is_register_blend', type=bool) self.is_run_minimized = self.settings.value('is_run_minimized', type=bool) is_run_on_startup = self.settings.value('is_run_on_startup', type=bool) root_folder = self.settings.value('root_folder') if (not root_folder) or (not os.path.isdir(root_folder)): exe_path = os.path.dirname(sys.executable) self.settings.setValue('root_folder', exe_path) # Custom title bar self.btnWiki.clicked.connect(lambda: webbrowser.open( "https://github.com/DotBow/Blender-Version-Manager/wiki")) self.title.setText("%s %s" % (QApplication.applicationName(), QApplication.applicationVersion())) self.btnClose.clicked.connect(self.hide) self.btnMinimize.clicked.connect(self.showMinimized) # Custom menu bar self.actionToggleRegisterBlend.setChecked(is_register_blend) self.actionToggleRegisterBlend.triggered.connect( self.toggle_register_blend) self.actionToggleRunMinimized.setChecked(self.is_run_minimized) self.actionToggleRunMinimized.triggered.connect( self.toggle_run_minimized) self.actionToggleRunOnStartup.setChecked(is_run_on_startup) self.actionToggleRunOnStartup.triggered.connect( self.toggle_run_on_startup) self.menubar.hide() self.btnSettings.setMenu(self.menuFile) self.menuFile.installEventFilter(self) # Root folder layout self.labelRootFolder.setText(self.settings.value('root_folder')) self.btnSetRootFolder.clicked.connect(self.set_root_folder) self.btnOpenRootFolder.clicked.connect(self.open_root_folder) # Tray layout self.blender_action = QAction(self.icon_star, "Blender ", self) show_action = QAction("Show", self) hide_action = QAction("Hide", self) quit_action = QAction(self.icon_quit, "Quit", self) self.blender_action.triggered.connect(self.open_latest_b3d) show_action.triggered.connect(self.bring_to_front) hide_action.triggered.connect(self.hide) quit_action.triggered.connect(self.quit) self.tray_menu = QMenu() self.tray_menu.setStyleSheet(self.menuFile.styleSheet()) self.tray_menu.addAction(self.blender_action) self.tray_menu.addAction(show_action) self.tray_menu.addAction(hide_action) self.tray_menu.addAction(quit_action) self.tray_icon = QSystemTrayIcon(self.icon_app, self) self.tray_icon.setToolTip("Blender Version Manager") self.tray_icon.setContextMenu(self.tray_menu) self.tray_icon.messageClicked.connect(self.bring_to_front) self.tray_icon.activated.connect(self.onTrayIconActivated) self.tray_icon.show() # Version layout self.btnUpdate.clicked.connect(self.update) self.set_task_visible(False) self.zeroBuildsWarning.hide() self.layouts = [] self.collect_versions() self.draw_list_versions() # Custom drag behaviour self.old_pos = self.pos() self.pressed = False # Update task self.is_update_running = False self.start_uptodate_thread() self.taskbar_progress = None self.left_click_timer = QTimer(self) self.left_click_timer.setSingleShot(True) self.left_click_timer.timeout.connect(self.bring_to_front)
def __init__(self, root_folder, version, is_latest, parent): super(B3dItemLayout, self).__init__(None) self.is_latest = is_latest self.btn_open_style = \ ("""QPushButton[IsRunning=false] { color: rgb(255, 255, 255); background-color: rgb(51, 51, 51); border-style: solid; border-color: rgb(51, 51, 51); border-width: 6px; } QPushButton[IsRunning=false]:pressed { background-color: rgb(80, 80, 80); border-color: rgb(80, 80, 80); } QPushButton[IsRunning=false]:hover { background-color: rgb(80, 80, 80); border-color: rgb(80, 80, 80); } QPushButton[IsRunning=true] { color: rgb(255, 255, 255); background-color: rgb(204, 102, 51); border-style: solid; border-color: rgb(204, 102, 51); border-width: 6px; } QPushButton[IsRunning=true]:pressed { background-color: rgb(223, 121, 70); border-color: rgb(223, 121, 70); } QPushButton[IsRunning=true]:hover { background-color: rgb(223, 121, 70); border-color: rgb(223, 121, 70); }""") self.btn_delete_style = \ ("""QPushButton[IsRunning=false] { color: rgb(255, 255, 255); background-color: rgb(51, 51, 51); border-style: solid; border-color: rgb(51, 51, 51); border-width: 0px 4px 0px 4px; qproperty-icon: url(:/icons/delete.png); qproperty-iconSize: 20px; } QPushButton[IsRunning=false]:pressed { background-color: rgb(80, 80, 80); border-color: rgb(80, 80, 80); } QPushButton[IsRunning=false]:hover { background-color: rgb(80, 80, 80); border-color: rgb(80, 80, 80); } QPushButton[IsRunning=true] { color: rgb(255, 255, 255); background-color: rgb(0, 122, 204); border-style: solid; border-color: rgb(0, 122, 204); border-width: 0px 13px 0px 13px; qproperty-icon: none; } QPushButton[IsRunning=true]:pressed { background-color: rgb(80, 80, 80); border-color: rgb(80, 80, 80); } QPushButton[IsRunning=true]:hover { background-color: rgb(80, 80, 80); border-color: rgb(80, 80, 80); }""") self.platform = get_platform() if self.platform == 'Windows': blender_exe = "blender.exe" elif self.platform == 'Linux': blender_exe = "blender" self.parent = parent self.root_folder = root_folder self.version = version self.processes = [] self.mtime = os.path.getmtime( os.path.join(root_folder, version, blender_exe)) self.setContentsMargins(6, 0, 6, 0) self.setSpacing(0) b3d_exe = os.path.join(root_folder, version, blender_exe) if self.platform == 'Windows': info = subprocess.check_output([b3d_exe, "-v"], creationflags=CREATE_NO_WINDOW, shell=True, stderr=DEVNULL, stdin=DEVNULL).decode('UTF-8') elif self.platform == 'Linux': info = subprocess.check_output([b3d_exe, "-v"], shell=False, stderr=DEVNULL, stdin=DEVNULL).decode('UTF-8') ctime = re.search("build commit time: " + "(.*)", info)[1].rstrip() cdate = re.search("build commit date: " + "(.*)", info)[1].rstrip() self.git = re.search("build hash: " + "(.*)", info)[1].rstrip() ver = re.search("Blender " + "(.*)", info)[1].rstrip() strptime = time.strptime(cdate + ' ' + ctime, "%Y-%m-%d %H:%M") self.btnOpen = QPushButton( "%s | %s | %s" % (ver, self.git, time.strftime("%d-%b-%H:%M", strptime))) self.btnOpen.clicked.connect(self.open) self.set_is_latest(self.is_latest) self.btnOpen.setFont(QFont("MS Shell Dlg 2", 10)) self.btnOpen.setCursor(QCursor(Qt.PointingHandCursor)) self.btnOpen.setStyleSheet(self.btn_open_style) self.btnOpen.setProperty('IsRunning', False) self.btnDelete = QPushButton("") self.btnDelete.setFlat(True) self.btnDelete.setToolTip("Delete From Drive") self.btnDelete.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.btnDelete.setCursor(QCursor(Qt.PointingHandCursor)) self.btnDelete.clicked.connect(lambda: self.delete()) self.btnDelete.setStyleSheet(self.btn_delete_style) self.btnDelete.setProperty('IsRunning', False) self.addWidget(self.btnOpen) self.addWidget(self.btnDelete)