コード例 #1
0
    def connection_error(self):
        set_locale()
        utcnow = strftime(('%H:%M'), localtime())
        self.set_status("Connection Error at " + utcnow)
        self.app_state = AppState.IDLE

        self.timer = threading.Timer(600.0, self.draw_downloads)
        self.timer.start()
コード例 #2
0
    def compare_datetime(self, other):
        if (self.date is None) or (other.date is None):
            return False
        else:
            set_locale()
            this_datetime = strptime(self.date, "%d-%b-%y-%H:%M")
            other_datetime = strptime(other.date, "%d-%b-%y-%H:%M")

            return this_datetime > other_datetime
コード例 #3
0
    def get_commit_time(self, commit):
        try:
            commit_url = "https://git.blender.org/gitweb/gitweb.cgi/blender.git/commit/"
            r = self.manager.request('GET', commit_url + commit)
            content = r.data
            soup = BeautifulSoup(content, 'html.parser')
            datetime = soup.find_all("span", {"class": "datetime"})[1].text

            set_locale()
            self.strptime = time.strptime(datetime, '%a, %d %b %Y %H:%M:%S %z')
            commit_time = time.strftime("%d-%b-%y-%H:%M", self.strptime)
            r.release_conn()
            r.close()
            return commit_time
        except Exception as e:
            return None
コード例 #4
0
    def draw_new_builds(self, builds):
        self.cashed_builds.clear()
        self.cashed_builds.extend(builds)

        library_widgets = []
        download_widgets = []

        library_widgets.extend(self.LibraryStableListWidget.items())
        library_widgets.extend(self.LibraryDailyListWidget.items())
        library_widgets.extend(self.LibraryExperimentalListWidget.items())

        download_widgets.extend(self.DownloadsStableListWidget.items())
        download_widgets.extend(self.DownloadsDailyListWidget.items())
        download_widgets.extend(self.DownloadsExperimentalListWidget.items())

        for widget in download_widgets:
            if widget.build_info in builds:
                builds.remove(widget.build_info)
            elif widget.state != DownloadState.DOWNLOADING:
                widget.destroy()

        for widget in library_widgets:
            if widget.build_info in builds:
                builds.remove(widget.build_info)

        for build_info in builds:
            self.draw_to_downloads(build_info, not self.started)

        if (len(builds) > 0) and (not self.started):
            self.show_message(
                "New builds of Blender is available!",
                type=MessageType.NEWBUILDS)

        set_locale()
        utcnow = strftime(('%H:%M'), localtime())
        self.set_status("Last check at " + utcnow)
        self.app_state = AppState.IDLE

        for page in self.DownloadsToolBox.pages:
            page.set_info_label_text("No new builds available")

        self.timer = threading.Timer(600.0, self.draw_downloads)
        self.timer.start()
        self.started = False
コード例 #5
0
    def new_blender_build(self, tag, url, branch_type):
        link = urljoin(url, tag['href']).rstrip('/')

        r = self.manager.request('HEAD', link)
        info = r.headers
        size = str(int(info['content-length']) // 1048576)

        commit_time = None
        build_hash = None

        stem = Path(link).stem
        match = re.findall(r'-\w{12}-', stem)

        if match:
            build_hash = match[-1].replace('-', '')

        # Old buidls style naming
        match = re.search(r'-\d\.\w+-', stem)

        if match is None:
            # New builds style naming
            match = re.search(r'-\d+\.\d+\.\d+-', stem)

        subversion = match.group(0).replace('-', '')

        if branch_type == 'experimental':
            branch = re.search(r'\A.+-blender', stem).group(0)[:-8]
            commit_time = self.get_commit_time(build_hash)
        elif branch_type == 'daily':
            branch = 'daily'
            commit_time = self.get_commit_time(build_hash)
        else:
            branch = 'stable'

        if commit_time is None:
            set_locale()
            self.strptime = time.strptime(info['last-modified'],
                                          '%a, %d %b %Y %H:%M:%S %Z')
            commit_time = time.strftime("%d-%b-%y-%H:%M", self.strptime)

        r.release_conn()
        r.close()
        return BuildInfo('link', link, subversion, build_hash, commit_time,
                         branch, size)
コード例 #6
0
    def scraper_finished(self):
        if self.new_downloads and not self.started:
            self.show_message("New builds of Blender is available!",
                              type=MessageType.NEWBUILDS)

        for list_widget in self.DownloadsToolBox.list_widgets:
            for widget in list_widget.widgets:
                if widget.build_info not in self.cashed_builds:
                    widget.destroy()

        set_locale()
        utcnow = strftime(('%H:%M'), localtime())
        self.set_status("Last check at " + utcnow)
        self.app_state = AppState.IDLE

        for page in self.DownloadsToolBox.pages:
            page.set_info_label_text("No new builds available")

        self.timer = threading.Timer(600.0, self.draw_downloads)
        self.timer.start()
        self.started = False
コード例 #7
0
    def write_build_info(self):
        # Read Blender Version
        platform = get_platform()

        if platform == 'Windows':
            blender_exe = "blender.exe"
        elif platform == 'Linux':
            blender_exe = "blender"

        exe_path = self.path / blender_exe

        try:
            if platform == 'Windows':
                info = subprocess.check_output([exe_path.as_posix(), "-v"],
                                               creationflags=CREATE_NO_WINDOW,
                                               shell=True,
                                               stderr=DEVNULL,
                                               stdin=DEVNULL)
            elif platform == 'Linux':
                info = subprocess.check_output([exe_path.as_posix(), "-v"],
                                               shell=False,
                                               stderr=DEVNULL,
                                               stdin=DEVNULL)
        except CalledProcessError:
            return 1

        info = info.decode('UTF-8')

        set_locale()
        ctime = re.search("build commit time: " + "(.*)", info)[1].rstrip()
        cdate = re.search("build commit date: " + "(.*)", info)[1].rstrip()
        strptime = time.strptime(cdate + ' ' + ctime, "%Y-%m-%d %H:%M")
        commit_time = time.strftime("%d-%b-%y-%H:%M", strptime)
        build_hash = re.search("build hash: " + "(.*)", info)[1].rstrip()
        subversion = re.search("Blender " + "(.*)", info)[1].rstrip()

        try:
            subfolder = self.path.parent.name
            name = self.path.name

            if platform == 'Windows':
                folder_parts = name.replace("blender-",
                                            "").replace("-windows64",
                                                        "").rsplit('-', 2)
            elif platform == 'Linux':
                folder_parts = name.replace("blender-",
                                            "").replace("-linux64",
                                                        "").rsplit('-', 2)

            if subfolder == 'experimental':
                branch = folder_parts[0]
            elif subfolder == 'daily':
                branch = "daily"
            elif subfolder == 'stable':
                branch = "stable"
                subversion = folder_parts[0]
            elif subfolder == 'custom':
                branch = self.path.name
        except Exception:
            branch = None

        # Write Version Information
        data = {}
        data['file_version'] = BuildInfo.file_version
        data['blinfo'] = []
        data['blinfo'].append({
            'branch': branch,
            'subversion': subversion,
            'build_hash': build_hash,
            'commit_time': commit_time,
        })

        path = self.path / '.blinfo'

        with open(path, 'w') as file:
            json.dump(data, file)

        return 0