コード例 #1
0
ファイル: __init__.py プロジェクト: kannibalox/tranny
    def cmd_start(options):
        import gevent
        import signal
        from tranny.manager import ServiceManager

        gevent.signal(signal.SIGQUIT, gevent.kill)

        application = ServiceManager()
        application.start()
コード例 #2
0
ファイル: __init__.py プロジェクト: leighmacdonald/tranny
def run_application(options):
    import gevent
    import signal
    from tranny.manager import ServiceManager

    gevent.signal(signal.SIGQUIT, gevent.kill)

    application = ServiceManager()
    from tranny.app import event_manager

    from tranny import metadata

    for handler in metadata.get_handlers():
        event_manager.register_handler(handler)
    application.start()
コード例 #3
0
ファイル: __init__.py プロジェクト: bobbintb/tranny
def run_application(options):
    import gevent
    import signal
    from tranny.manager import ServiceManager

    gevent.signal(signal.SIGQUIT, gevent.kill)

    application = ServiceManager()
    from tranny.app import event_manager

    from tranny import metadata

    for handler in metadata.get_handlers():
        event_manager.register_handler(handler)
    application.start()
コード例 #4
0
ファイル: upload.py プロジェクト: kannibalox/tranny
def handler():
    """ Called when a user used the popup modal to upload a torrent manually

    :return: Redirect response
    :rtype: Response
    """
    form = forms.UploadForm()
    if form.validate_on_submit():
        file_data = request.files['torrent_file'].stream.read()
        file_name = request.files['torrent_file'].filename
        if file_name.endswith(".torrent"):
            file_name = file_name[0:len(file_name)-8]

        try:
            torrent_struct = torrent.Torrent.from_str(file_data)
            tor_data = release.TorrentData(torrent_struct.name, file_data, form.section.data)
            if ServiceManager.add(Session(), tor_data, WebProvider()):
                flash("Torrent {} uploaded successfully".format(torrent_struct.name), "success")
            else:
                flash("Failed to upload torrent", "alert")
        except exceptions.TrannyException as err:
            flash(err.message, "alert")
    elif form.errors:
        for field, error in form.errors.items():
            try:
                flash("[{}] {}".format(field, ' && '.join(error)), "alert")
            except:
                pass
    try:
        next_url = request.form['next_url']
    except KeyError:
        next_url = url_for("home.index")
    return redirect(next_url)
コード例 #5
0
def handler():
    """ Called when a user used the popup modal to upload a torrent manually

    :return: Redirect response
    :rtype: Response
    """
    form = forms.UploadForm()
    if form.validate_on_submit():
        file_data = request.files['torrent_file'].stream.read()
        file_name = request.files['torrent_file'].filename
        if file_name.endswith(".torrent"):
            file_name = file_name[0:len(file_name) - 8]

        try:
            torrent_struct = torrent.Torrent.from_str(file_data)
            tor_data = release.TorrentData(torrent_struct.name, file_data,
                                           form.section.data)
            if ServiceManager.add(Session(), tor_data, WebProvider()):
                flash(
                    "Torrent {} uploaded successfully".format(
                        torrent_struct.name), "success")
            else:
                flash("Failed to upload torrent", "alert")
        except exceptions.TrannyException as err:
            flash(err.message, "alert")
    elif form.errors:
        for field, error in form.errors.items():
            try:
                flash("[{}] {}".format(field, ' && '.join(error)), "alert")
            except:
                pass
    try:
        next_url = request.form['next_url']
    except KeyError:
        next_url = url_for("home.index")
    return redirect(next_url)