Esempio n. 1
0
    def check_manifest_integrity(self, req, resp):
        headers = resp.headers

        rmtime = headers.get('x-amz-meta-mtime', None)

        if rmtime is None:
            rmtime = headers.get('last-modified', None)
            if rmtime is not None:
                rmtime = net.http_date_to_timestamp(rmtime)

        if rmtime is not None:
            try:
                rmtime = int(rmtime)
            except (TypeError, ValueError):
                rmtime = None

        prog_dir = util.program_dir()
        self.local_manifest_path = path.path(prog_dir) / path.path(self.remote_manifest_path).splitpath()[-1]

        needs_update = True

        if self.local_manifest_path.isfile():
            lmtime = int(self.local_manifest_path.mtime)
        else:
            lmtime = 0

        if sys.opts.force_update or lmtime != rmtime:
            log.info("MTime mismatch or sys.opts.force_update is True. Downloading manifest. (local=%r, remote=%r)", lmtime, rmtime)
            downloader.httpopen(self.remote_manifest_path, success = self.got_manifest_response, error = self.manifest_request_error)
        else:
            log.info("Local MTime matches remote. Not downloading manifest. (local=%r, remote=%r)", lmtime, rmtime)
            self.update_check_complete(False, None)
Esempio n. 2
0
    def got_updateyaml(self, req=None, fobj=None):
        '''
        an open fileobject that contains yaml with manifest locations in it.
        '''
        try:
            data = fobj.read()
        except Exception as e:
            return self.manifest_path_error(e)

        try:
            ui = syck.load(data)
        except Exception as e:
            return self.manifest_path_error(e)

        all = ui.get('all', {})
        mine = ui.get(config.platform, None) or {}

        merged = all.copy()
        merged.update(mine)

        manifest_path = merged.get(self.release_type,
                                   merged.get('release', None))
        if manifest_path is None:
            self.update_check_error(
                Exception("No manifest URL for %r in %r" %
                          (self.release_type, all)))
        else:
            log.info("Got manifest path: %r", manifest_path)
            self.remote_manifest_path = manifest_path
            downloader.httpopen(self.remote_manifest_path,
                                method='HEAD',
                                success=self.check_manifest_integrity,
                                error=self.manifest_check_error)
Esempio n. 3
0
    def got_updateyaml(self, req = None, fobj = None):
        '''
        an open fileobject that contains yaml with manifest locations in it.
        '''
        try:
            data = fobj.read()
        except Exception as e:
            return self.manifest_path_error(e)

        try:
            ui = syck.load(data)
        except Exception as e:
            return self.manifest_path_error(e)

        all = ui.get('all', {})
        mine = ui.get(config.platform, None) or {}

        merged = all.copy()
        merged.update(mine)

        manifest_path = merged.get(self.release_type, merged.get('release', None))
        if manifest_path is None:
            self.update_check_error(Exception("No manifest URL for %r in %r" % (self.release_type, all)))
        else:
            log.info("Got manifest path: %r", manifest_path)
            self.remote_manifest_path = manifest_path
            downloader.httpopen(self.remote_manifest_path, method = 'HEAD', success = self.check_manifest_integrity, error = self.manifest_check_error)
Esempio n. 4
0
    def check_manifest_integrity(self, req, resp):
        headers = resp.headers

        rmtime = headers.get('x-amz-meta-mtime', None)

        if rmtime is None:
            rmtime = headers.get('last-modified', None)
            if rmtime is not None:
                rmtime = net.http_date_to_timestamp(rmtime)

        if rmtime is not None:
            try:
                rmtime = int(rmtime)
            except (TypeError, ValueError):
                rmtime = None

        prog_dir = util.program_dir()
        self.local_manifest_path = path.path(prog_dir) / path.path(
            self.remote_manifest_path).splitpath()[-1]

        needs_update = True

        if self.local_manifest_path.isfile():
            lmtime = int(self.local_manifest_path.mtime)
        else:
            lmtime = 0

        if sys.opts.force_update or lmtime != rmtime:
            log.info(
                "MTime mismatch or sys.opts.force_update is True. Downloading manifest. (local=%r, remote=%r)",
                lmtime, rmtime)
            downloader.httpopen(self.remote_manifest_path,
                                success=self.got_manifest_response,
                                error=self.manifest_request_error)
        else:
            log.info(
                "Local MTime matches remote. Not downloading manifest. (local=%r, remote=%r)",
                lmtime, rmtime)
            self.update_check_complete(False, None)