Beispiel #1
0
def handle_speed_overall(message=None):
    try:
        up, dn = client.get().current_speeds()
    except ClientNotAvailable as exc:
        api.error_handler(exc, api.EVENT_SPEED_OVERALL_RESPONSE)
    else:
        api.emit(api.EVENT_SPEED_OVERALL_RESPONSE, dict(up=up, dn=dn))
Beispiel #2
0
def handle_speed_overall(message=None):
    try:
        up, dn = torrent_client.current_speeds()
    except ClientNotAvailable as exc:
        api.error_handler(exc, events.EVENT_SPEED_OVERALL_RESPONSE)
    else:
        api.emit(events.EVENT_SPEED_OVERALL_RESPONSE, dict(up=up, dn=dn))
Beispiel #3
0
def handle_list_all():
    """ Return a list of all torrents currently being tracked """
    try:
        torrent_list = torrent_client.torrent_list()
    except ClientNotAvailable as exc:
        api.error_handler(exc, events.EVENT_TORRENT_LIST_RESPONSE)
    else:
        api.emit(events.EVENT_TORRENT_LIST_RESPONSE, data=torrent_list)
Beispiel #4
0
def handle_list_all():
    """ Return a list of all torrents currently being tracked """
    try:
        torrent_list = client.get().torrent_list()
    except Exception as exc:
        api.error_handler(exc, api.EVENT_TORRENT_LIST_RESPONSE)
    else:
        api.emit(api.EVENT_TORRENT_LIST_RESPONSE, data=torrent_list)
Beispiel #5
0
def handle_list_all():
    """ Return a list of all torrents currently being tracked """
    try:
        torrent_list = torrent_client.torrent_list()
    except ClientNotAvailable as exc:
        api.error_handler(exc, events.EVENT_TORRENT_LIST_RESPONSE)
    else:
        api.emit(events.EVENT_TORRENT_LIST_RESPONSE, data=torrent_list)
Beispiel #6
0
def handle_start(message):
    info_hash = message.get('info_hash', [])
    try:
        client.get().torrent_start(info_hash)
    except ClientNotAvailable as exc:
        api.error_handler(exc, api.EVENT_TORRENT_START_RESPONSE)
    else:
        api.emit(api.EVENT_TORRENT_START_RESPONSE, dict(info_hash=info_hash))
        api.flash("Started successfully")
Beispiel #7
0
def handle_stop(message):
    info_hash = message.get('info_hash', [])
    try:
        torrent_client.torrent_stop(info_hash)
    except ClientNotAvailable as exc:
        api.error_handler(exc, events.EVENT_TORRENT_SPEED_RESPONSE)
    else:
        api.emit(events.EVENT_TORRENT_SPEED_RESPONSE, dict(info_hash=info_hash))
        api.flash("Stopped successfully")
Beispiel #8
0
def handle_start(message):
    info_hash = message.get('info_hash', [])
    try:
        torrent_client.torrent_start(info_hash)
    except ClientNotAvailable as exc:
        api.error_handler(exc, events.EVENT_TORRENT_START_RESPONSE)
    else:
        api.emit(events.EVENT_TORRENT_START_RESPONSE,
                 dict(info_hash=info_hash))
        api.flash("Started successfully")
Beispiel #9
0
def handle_details(message):
    try:
        info_hash = message.get('info_hash', None)
        data = dict()
        if info_hash:
            data = client.get().torrent_status(info_hash)
            status = api.STATUS_OK
        else:
            status = api.STATUS_INCOMPLETE_REQUEST
    except ClientNotAvailable as exc:
        api.error_handler(exc, api.EVENT_TORRENT_DETAILS_RESPONSE)
    else:
        api.emit(api.EVENT_TORRENT_DETAILS_RESPONSE, data=data, status=status)
Beispiel #10
0
def handle_details(message):
    try:
        info_hash = message.get('info_hash', None)
        data = dict()
        if info_hash:
            data = torrent_client.torrent_status(info_hash)
            status = api.STATUS_OK
        else:
            status = api.STATUS_INCOMPLETE_REQUEST
    except ClientNotAvailable as exc:
        api.error_handler(exc, events.EVENT_TORRENT_DETAILS_RESPONSE)
    else:
        api.emit(events.EVENT_TORRENT_DETAILS_RESPONSE,
                 data=data,
                 status=status)