docs: def submit(self, info, *flags):
          """Finish recording and upload or save the report.
  
          This closes the `Stats` object, no further methods should be called.
          The report is either saved, uploaded or discarded, depending on
          configuration. If uploading is enabled, previous reports might be
          uploaded too. If uploading is not explicitly enabled or disabled, the
          prompt will be shown, to ask the user to enable or disable it.
          """
          if not self.recording:
              return
          env_val = os.environ.get(self.env_var, '').lower()
          if env_val not in (None, '', '1', 'on', 'enabled', 'yes', 'true'):
              self.status = Stats.DISABLED_ENV
              self.notes = None
              return
  
          if self.notes is None:
              raise ValueError("This report has already been submitted")
  
          all_info, self.notes = self.notes, None
          all_info.extend(self._to_notes(info))
          for flag in flags:
              flag(self, all_info)
  
          now = time.time()
          secs = int(now)
          msecs = int((now - secs) * 1000)
          all_info.insert(0, ('date', '%d.%d' % (secs, msecs)))
  
          if self.user_id:
              all_info.insert(1, ('user', self.user_id))
  
          logger.debug("Generated report:\n%r", (all_info,))
  
          # Current report
          def generator():
              for key, value in all_info:
                  yield _encode(key) + b':' + _encode(value) + b'\n'
          filename = 'report_%d_%d.txt' % (secs, msecs)
  
          # Save current report and exit, unless user has opted in
          if not self.sending:
              fullname = os.path.join(self.location, filename)
              with open(fullname, 'wb') as fp:
                  for l in generator():
                      fp.write(l)
  
              # Show prompt
              sys.stderr.write(self.prompt.prompt)
              return
  
          # Post previous reports
          old_reports = [f for f in os.listdir(self.location)
                         if f.startswith('report_')]
          old_reports.sort()
          old_reports = old_reports[:4]  # Only upload 5 at a time
          for old_filename in old_reports:
              fullname = os.path.join(self.location, old_filename)
              try:
                  with open(fullname, 'rb') as fp:
                      # `data=fp` would make requests stream, which is currently
                      # not a good idea (WSGI chokes on it)
                      r = requests.post(self.drop_point, data=fp.read(),
                                        timeout=1, verify=self.ssl_verify)
                      r.raise_for_status()
              except Exception as e:
                  logger.warning("Couldn't upload %s: %s", old_filename, str(e))
                  break
              else:
                  logger.info("Submitted report %s", old_filename)
                  os.remove(fullname)
  
          # Post current report
          try:
              # `data=generator()` would make requests stream, which is currently
              # not a good idea (WSGI chokes on it)
              r = requests.post(self.drop_point, data=b''.join(generator()),
                                timeout=1, verify=self.ssl_verify)
          except requests.RequestException as e:
              logger.warning("Couldn't upload report: %s", str(e))
              fullname = os.path.join(self.location, filename)
              with open(fullname, 'wb') as fp:
                  for l in generator():
                      fp.write(l)
          else:
              try:
                  r.raise_for_status()
                  logger.info("Submitted report")
              except requests.RequestException as e:
                  logger.warning("Server rejected report: %s", str(e))