Post a new submission to the given subreddit.
346946
def post_submission(self):
        
        # Check that the subreddit can be submitted to
        name = self.content.name
        if '+' in name or name in ('/r/all', '/r/front', '/r/me', '/u/saved'):
            self.term.show_notification("Can't post to {0}".format(name))
            return

        submission_info = docs.SUBMISSION_FILE.format(name=name)
        with self.term.open_editor(submission_info) as text:
            if not text:
                self.term.show_notification('Canceled')
                return
            elif '\n' not in text:
                self.term.show_notification('Missing body')
                return

            title, content = text.split('\n', 1)
            with self.term.loader('Posting', delay=0):
                submission = self.reddit.submit(name, title, text=content,
                                                raise_captcha_exception=True)
                # Give reddit time to process the submission
                time.sleep(2.0)
            if self.term.loader.exception:
                raise TemporaryFileError()

        if not self.term.loader.exception:
            # Open the newly created submission
            self.selected_page = self.open_submission_page(submission=submission)
236541
def submit(self, fn, *args, **kwargs):
        """"""
        corofn = asyncio.coroutine(lambda: fn(*args, **kwargs))
        return run_coroutine_threadsafe(corofn(), self.loop)
167944
def submit(self):
        """"""
        self._newflg = False
        ret = list()
        for buf in self._buffer.values():
            buf = copy.deepcopy(buf)
            if self._fdpext:
                buf['fpout'] = f"{self._fproot}/{buf['label']}.{self._fdpext}"
            else:
                del buf['fpout']
            buf['index'] = tuple(buf['index'])
            ret.append(Info(buf))
        ret += self._stream
        return tuple(ret)
1252307
def process_submitters(self):
        """"""
        for submission in self.submissions.values():
            if submission.author and (self.distinguished or
                                      submission.distinguished is None):
                self.submitters[submission.author].append(submission)
443745
def combine_submissions(combined_submission_data, opts = {})
      data, _status_code, _headers = combine_submissions_with_http_info(combined_submission_data, opts)
      data
    end
1348544
def fetch_recent_submissions(self, max_duration):
        
        if max_duration:
            self.min_date = self.max_date - SECONDS_IN_A_DAY * max_duration
        for submission in self.subreddit.new(limit=None):
            if submission.created_utc <= self.min_date:
                break
            if submission.created_utc > self.max_date:
                continue
            self.submissions[submission.id] = MiniSubmission(submission)
490336
def post(self, request, *args, **kwargs):
        
        return self.update_type(request, *args, **kwargs)
305646
def submission(self):
        """"""
        if not self._submission:  # Comment not from submission
            self._submission = self.reddit_session.get_submission(
                url=self._fast_permalink)
        return self._submission
291797
def _listen_submissions(self):
        """"""
        # Collect submissions in a queue
        subs_queue = Queue(maxsize=self._n_jobs * 4)

        threads = []  # type: List[BotQueueWorker]

        try:
            # Create n_jobs SubmissionThreads
            for i in range(self._n_jobs):
                t = BotQueueWorker(name='SubmissionThread-t-{}'.format(i),
                                   jobs=subs_queue,
                                   target=self._process_submission)
                t.start()
                self._threads.append(t)

            # Iterate over all comments in the comment stream
            for submission in self._reddit.subreddit('+'.join(self._subs)).stream.submissions():

                # Check for stopping
                if self._stop:
                    self._do_stop(subs_queue, threads)
                    break

                subs_queue.put(submission)

            self.log.debug('Listen submissions stopped')
        except Exception as e:
            self._do_stop(subs_queue, threads)
            self.log.error('Exception while listening to submissions:')
            self.log.error(str(e))
            self.log.error('Waiting for 10 minutes and trying again.')
            time.sleep(10 * 60)

            # Retry:
            self._listen_submissions()
1010303
def submit(self, stanza):
        
        body = _encode(**stanza)
        self.service.post(self.path, body=body)
        return self
308098
def _post(self, url, data={}):
        """"""
        r = requests.post(self._api_prefix + url,
            data=json.dumps(data),
            headers=self.headers,
            auth=self.auth,
            allow_redirects=False,
        )
        return self._action(r)
1202356
def open_submission_page(self, url=None, submission=None):
        
        from .submission_page import SubmissionPage

        with self.term.loader('Loading submission'):
            page = SubmissionPage(self.reddit, self.term, self.config,
                                  self.oauth, url=url, submission=submission)
        if not self.term.loader.exception:
            return page
99402
protected function submitAddPriceRule()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->validateComponent('price_rule');
        $this->addPriceRule();
    }
1275230
def get_random_submission(self, subreddit='all'):
        
        url = self.config['subreddit_random'].format(
            subreddit=six.text_type(subreddit))
        try:
            item = self.request_json(url,
                                     params={'unique': self._unique_count})
            self._unique_count += 1  # Avoid network-level caching
            return objects.Submission.from_json(item)
        except errors.RedirectException as exc:
            self._unique_count += 1
            return self.get_submission(exc.response_url)
        raise errors.ClientException('Expected exception not raised.')
636667
def make_posts(generator, metadata, url):
    
    reddit = generator.get_reddit()
    title =  lxml.html.fromstring(metadata['title']).text_content()
    if reddit is None:
        log.info("Reddit plugin not enabled")
        return
    if metadata.get('status') == "draft": # people don't want to post drafts
        log.debug("ignoring draft %s" % title)
        return

    collection = generator.settings['REDDIT_POSTER_COLLECT_SUB']
    sub = reddit.subreddit(collection)
    results = sub.search(title)
    if len([result for result in results]) > 0:
        log.debug("ignoring %s because it is already on sub %s " % (title, collection))
        # post already was made to this sub
        return
    try:
        submission = sub.submit(title, url=url, resubmit=False)
        cross_post(reddit, submission, metadata.get('subreddit'))
    except praw.exceptions.APIException as e:
        log.error("got an api exception: %s", e)
    except AssertionError as e:
        log.error("Received an assertion error %s", e)
858386
def cmd(send, msg, args):
    
    if msg and not check_exists(msg):
        send("Non-existant subreddit.")
        return
    subreddit = msg if msg else None
    send(random_post(subreddit, args['config']['api']['bitlykey']))
253188
protected function submitAddPage()
    {
        $this->setSubmitted(null, $this->getParam());
        $this->validateComponent('page');
        $this->addPage();
    }