def upload_files(self, ultra):

        hashes = self.load_hashes(self.hub_project)
        files_scanned, files_to_upload = self.scan_files(hashes, ultra)

        if self.stopped:
            return False

        num_files = self.num_files
        if num_files <= 0:
            return True

        boundary = gen_boundary()

        local_deploy = self.hub_pool.host in ['127.0.0.1', '0.0.0.0', 'localhost']

        try:
            if local_deploy:
                params = {'files.path': self.get_meta_data_path(),
                          'encoding': 'gzip',
                          'project': self.hub_project,
                          'version': self.hub_version,
                          'versiontitle': self.hub_versiontitle,
                          'pluginmain': self.plugin_main,
                          'canvasmain': self.canvas_main,
                          'flashmain': self.flash_main,
                          'mappingtable': self.mapping_table,
                          'engineversion': self.engine_version,
                          'ismultiplayer': self.is_multiplayer,
                          'aspectratio': self.aspect_ratio,
                          'numfiles': str(num_files),
                          'numbytes': str(self.num_bytes),
                          'localversion': __version__}
                r = self.hub_pool.request('POST',
                                          '/dynamic/upload/begin',
                                          fields=params,
                                          headers={'Cookie': self.hub_cookie},
                                          timeout=self.hub_timeout)
            else:
                r = self.post('/dynamic/upload/begin',
                              [MultipartParam('files',
                                              filename='files.json',
                                              filetype='application/json; charset=utf-8',
                                              fileobj=open(self.get_meta_data_path(), 'rb')),
                               ('encoding', 'gzip'),
                               ('project', self.hub_project),
                               ('version', self.hub_version),
                               ('versiontitle', self.hub_versiontitle),
                               ('pluginmain', self.plugin_main),
                               ('canvasmain', self.canvas_main),
                               ('flashmain', self.flash_main),
                               ('mappingtable', self.mapping_table),
                               ('engineversion', self.engine_version),
                               ('ismultiplayer', self.is_multiplayer),
                               ('aspectratio', self.aspect_ratio),
                               ('numfiles', num_files),
                               ('numbytes', self.num_bytes),
                               ('localversion', __version__)],
                              boundary)
        except IOError:
            self.stop('Error opening file "%s".' % self.get_meta_data_path())
            return False
        except (HTTPError, SSLError) as e:
            self.stop('Error starting upload: "%s".' % e)
            return False

        if r.status == 504:
            self.stop('Hub timed out.')
            return False

        if r.headers.get('content-type', '') == 'application/json; charset=utf-8' and r.data != '':
            try:
                answer = json_loads(r.data)
            except JSONDecodeError as e:
                LOG.error(e)
                answer = {}
        else:
            answer = {}

        if r.status != 200:
            msg = answer.get('msg', False)
            if msg:
                self.stop(msg)
            else:
                self.stop('Error starting upload: "%s".' % r.reason)
            return False

        hub_session = answer.get('session', None)

        if not answer.get('ok', False) or not hub_session:
            self.stop('Unsupported response format from Hub.')
            return False

        self.hub_session = hub_session

        get_cached_file_name = _get_cached_file_name

        for file_name, file_size, file_hash in files_scanned:
            hashes.add(get_cached_file_name(file_name, file_hash, file_size))

            self.uploaded_bytes += file_size
            self.uploaded_files += 1

        if self.uploaded_files >= num_files:
            self.save_hashes(hashes)
            return True

        # we only reach this code if there are files to upload
        uploaded_queue = Queue()
        self.start_upload_workers(files_to_upload, uploaded_queue, boundary, local_deploy)

        while True:

            item = uploaded_queue.get()

            if item is None or self.stopped:
                break

            file_name, file_size, file_hash = item

            hashes.add(get_cached_file_name(file_name, file_hash, file_size))

            self.uploaded_bytes += file_size
            self.uploaded_files += 1
            if self.uploaded_files >= num_files:
                self.save_hashes(hashes)
                return True

            item = None

        self.save_hashes(hashes)
        return False
dataset/ETHPy150Open turbulenz/turbulenz_local/turbulenz_local/lib/deploy.py/Deployment.upload_files/original