예제 #1
0
파일: execute.py 프로젝트: antrix/Flexget
def index():
    context = {'progress': exec_parser.format_help().split('\n')}
    if request.method == 'POST':
        try:
            options = exec_parser.parse_args(request.form.get('options', ''), raise_errors=True)
        except ValueError as e:
            flash(escape(e.message), 'error')
            context['options'] = request.form['options']
        else:
            manager.execute(options=options.execute, output=bufferqueue)
            context['execute_progress'] = True
            context['progress'] = progress(as_list=True)

    return render_template('execute/execute.html', **context)
예제 #2
0
파일: execute.py 프로젝트: xfouloux/Flexget
def index():
    context = {'progress': exec_parser.format_help().split('\n')}
    if request.method == 'POST':
        try:
            options = exec_parser.parse_args(request.form.get('options', ''),
                                             raise_errors=True)
        except ValueError as e:
            flash(escape(e.message), 'error')
            context['options'] = request.form['options']
        else:
            manager.execute(options=options.execute, output=bufferqueue)
            context['execute_progress'] = True
            context['progress'] = progress(as_list=True)

    return render_template('execute/execute.html', **context)
예제 #3
0
파일: inject.py 프로젝트: ARLahan/Flexget
def do_inject():
    fields = {}
    # Requests is a special dict, and cannot be passed as keyword arguments, make it into a normal dict.
    for key, value in request.values.iteritems():
        # Translate on and off to True and False
        if value == 'on':
            fields[key] = True
        elif value == 'off':
            fields[key] = False
        else:
            fields[key] = value
    # If we only got a url, make a title from the url filename
    fields['title'] = fields.get('title') or posixpath.basename(urlparse.urlsplit(fields.get('url', '')).path)

    if fields.get('title') and fields.get('url'):
        # Create the entry for injection
        entry = Entry(**fields)
        manager.execute(options={'dump_entries': True, 'inject': [entry]})
        flash('Scheduled execution for entry `%s`' % entry['title'], 'success')
    else:
        flash('Title and URL required for inject.', 'error')

    return redirect(url_for('.index'))
예제 #4
0
파일: executor.py 프로젝트: Anaerin/Flexget
 def run(self):
     from flexget.ui.webui import manager
     while True:
         kwargs = self.queue.get() or {}
         opts = kwargs.pop('options', None)
         parsed_options = kwargs.pop('parsed_options', None)
         output = kwargs.pop('output', None)
         if opts:
             # make copy of original options and apply options from opts
             old_opts = copy(manager.options)
             self._apply_options(manager.options, opts)
         if parsed_options:
             old_opts = manager.options
             manager.options = parsed_options
         if output:
             old_stdout = sys.stdout
             old_stderr = sys.stderr
             sys.stdout = output
             sys.stderr = output
             # TODO: Use a filter to capture only the logging for this execution
             streamhandler = logging.StreamHandler(output)
             streamhandler.setFormatter(FlexGetFormatter())
             logging.getLogger().addHandler(streamhandler)
         try:
             manager.execute(**kwargs)
         finally:
             # Inform queue we are done processing this item.
             self.queue.task_done()
             # Restore manager's previous options and stdout
             if opts:
                 manager.options = old_opts
             if output:
                 # Write EOF to the output, so that a listener knows when the output is over
                 output.write('EOF')
                 sys.stdout = old_stdout
                 sys.stderr = old_stderr
                 logging.getLogger().removeHandler(streamhandler)
예제 #5
0
 def run(self):
     from flexget.ui.webui import manager
     while True:
         kwargs = self.queue.get() or {}
         opts = kwargs.pop('options', None)
         parsed_options = kwargs.pop('parsed_options', None)
         output = kwargs.pop('output', None)
         if opts:
             # make copy of original options and apply options from opts
             old_opts = copy(manager.options)
             self._apply_options(manager.options, opts)
         if parsed_options:
             old_opts = manager.options
             manager.options = parsed_options
         if output:
             old_stdout = sys.stdout
             old_stderr = sys.stderr
             sys.stdout = output
             sys.stderr = output
             # TODO: Use a filter to capture only the logging for this execution
             streamhandler = logging.StreamHandler(output)
             streamhandler.setFormatter(FlexGetFormatter())
             logging.getLogger().addHandler(streamhandler)
         try:
             manager.execute(**kwargs)
         finally:
             # Inform queue we are done processing this item.
             self.queue.task_done()
             # Restore manager's previous options and stdout
             if opts:
                 manager.options = old_opts
             if output:
                 # Write EOF to the output, so that a listener knows when the output is over
                 output.write('EOF')
                 sys.stdout = old_stdout
                 sys.stderr = old_stderr
                 logging.getLogger().removeHandler(streamhandler)
예제 #6
0
파일: inject.py 프로젝트: xfouloux/Flexget
def do_inject():
    fields = {}
    # Requests is a special dict, and cannot be passed as keyword arguments, make it into a normal dict.
    for key, value in request.values.iteritems():
        # Translate on and off to True and False
        if value == 'on':
            fields[key] = True
        elif value == 'off':
            fields[key] = False
        else:
            fields[key] = value
    # If we only got a url, make a title from the url filename
    fields['title'] = fields.get('title') or posixpath.basename(
        urlparse.urlsplit(fields.get('url', '')).path)

    if fields.get('title') and fields.get('url'):
        # Create the entry for injection
        entry = Entry(**fields)
        manager.execute(options={'dump_entries': True, 'inject': [entry]})
        flash('Scheduled execution for entry `%s`' % entry['title'], 'success')
    else:
        flash('Title and URL required for inject.', 'error')

    return redirect(url_for('.index'))