예제 #1
0
파일: torrents.py 프로젝트: bobbintb/tranny
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))
예제 #2
0
파일: torrents.py 프로젝트: bobbintb/tranny
def handle_speed(message):
    info_hash = message.get('info_hash', None)
    if info_hash:
        tor_speed = torrent_client.torrent_speed(info_hash)
        api.emit(events.EVENT_TORRENT_SPEED_RESPONSE, data=tor_speed)
    else:
        api.emit(events.EVENT_TORRENT_SPEED_RESPONSE, status=api.STATUS_FAIL)
예제 #3
0
파일: torrents.py 프로젝트: crawln45/tranny
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))
예제 #4
0
파일: torrents.py 프로젝트: crawln45/tranny
def handle_speed(message):
    info_hash = message.get('info_hash', None)
    if info_hash:
        tor_speed = client.get().torrent_speed(info_hash)
        api.emit(api.EVENT_TORRENT_SPEED_RESPONSE, data=tor_speed)
    else:
        api.emit(api.EVENT_TORRENT_SPEED_RESPONSE, status=api.STATUS_FAIL)
예제 #5
0
파일: torrents.py 프로젝트: bobbintb/tranny
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)
예제 #6
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)
예제 #7
0
파일: torrents.py 프로젝트: crawln45/tranny
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)
예제 #8
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")
예제 #9
0
파일: torrents.py 프로젝트: crawln45/tranny
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")
예제 #10
0
파일: torrents.py 프로젝트: bobbintb/tranny
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")
예제 #11
0
 def update(self, payload=None):
     """
     Update tick handler registered as a plugin
     """
     self.log.debug("Fetching new torrent events")
     new_event = self.get_events()
     for k, v in new_event.items():
         self.log.debug("[{}] {}".format(k, v))
     if new_event:
         api.emit(events.EVENT_TORRENT_UPDATE, data=new_event)
     return payload
예제 #12
0
 def update(self, payload=None):
     """
     Update tick handler registered as a plugin
     """
     self.log.debug("Fetching new torrent events")
     new_event = self.get_events()
     for k, v in new_event.items():
         self.log.debug("[{}] {}".format(k, v))
     if new_event:
         api.emit(events.EVENT_TORRENT_UPDATE, data=new_event)
     return payload
예제 #13
0
파일: torrents.py 프로젝트: crawln45/tranny
def handle_announce(message):
    """ (re)announce the torrent(s) to the tracker

    :param message:
    :type message: dict
    :return:
    :rtype:
    """
    info_hash = message.get('data', [])
    status = api.STATUS_OK if client.get().torrent_reannounce(info_hash) else api.STATUS_FAIL
    api.emit(api.EVENT_TORRENT_ANNOUNCE_RESPONSE, status=status)
예제 #14
0
파일: torrents.py 프로젝트: bobbintb/tranny
def handle_announce(message):
    """ (re)announce the torrent(s) to the tracker

    :param message:
    :type message: dict
    :return:
    :rtype:
    """
    info_hash = message.get('data', [])
    status = api.STATUS_OK if torrent_client.torrent_reannounce(
        info_hash) else api.STATUS_FAIL
    api.emit(events.EVENT_TORRENT_ANNOUNCE_RESPONSE, status=status)
예제 #15
0
파일: torrents.py 프로젝트: crawln45/tranny
def handle_remove(message):
    info_hash = message.get('info_hash', None)
    remove_data = message.get('remove_data', False)
    torrent = client.get().torrent_status(info_hash)
    if not torrent:
        status = api.STATUS_INVALID_INFO_HASH
    else:
        if client.get().torrent_remove(info_hash, remove_data=remove_data):
            status = api.STATUS_OK
        else:
            status = api.STATUS_FAIL
    api.emit(api.EVENT_TORRENT_REMOVE_RESPONSE, data=dict(info_hash=info_hash), status=status)
예제 #16
0
파일: torrents.py 프로젝트: crawln45/tranny
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)
예제 #17
0
파일: torrents.py 프로젝트: bobbintb/tranny
def handle_remove(message):
    info_hash = message.get('info_hash', None)
    remove_data = message.get('remove_data', False)
    torrent = torrent_client.torrent_status(info_hash)
    if not torrent:
        status = api.STATUS_INVALID_INFO_HASH
    else:
        if torrent_client.torrent_remove(info_hash, remove_data=remove_data):
            status = api.STATUS_OK
        else:
            status = api.STATUS_FAIL
    api.emit(events.EVENT_TORRENT_REMOVE_RESPONSE,
             data=dict(info_hash=info_hash),
             status=status)
예제 #18
0
파일: torrents.py 프로젝트: bobbintb/tranny
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)
예제 #19
0
def handle_event_update(message):
    e = torrent_client.get_events()
    api.emit(events.EVENT_UPDATE_RESPONSE)
예제 #20
0
파일: torrents.py 프로젝트: crawln45/tranny
def handle_files(message):
    info_hash = message.get('info_hash', None)
    tor_files = client.get().torrent_files(info_hash)
    api.emit(api.EVENT_TORRENT_FILES_RESPONSE, tor_files)
예제 #21
0
파일: torrents.py 프로젝트: bobbintb/tranny
def handle_recheck(message):
    info_hash = message.get('info_hash', [])
    resp = torrent_client.torrent_recheck(info_hash)
    api.emit(events.EVENT_TORRENT_RECHECK_RESPONSE, resp)
    api.flash("Rechecking..!")
예제 #22
0
파일: torrents.py 프로젝트: bobbintb/tranny
def handle_event_update(message):
    e = torrent_client.get_events()
    api.emit(events.EVENT_UPDATE_RESPONSE)
예제 #23
0
파일: torrents.py 프로젝트: bobbintb/tranny
def handle_peers(message):
    info_hash = message.get('info_hash', None)
    data = torrent_client.torrent_peers(info_hash)
    api.emit(events.EVENT_TORRENT_PEERS_RESPONSE, data=dict(peers=data))
예제 #24
0
파일: torrents.py 프로젝트: bobbintb/tranny
def handle_files(message):
    info_hash = message.get('info_hash', None)
    tor_files = torrent_client.torrent_files(info_hash)
    api.emit(events.EVENT_TORRENT_FILES_RESPONSE, tor_files)
예제 #25
0
파일: torrents.py 프로젝트: crawln45/tranny
def handle_peers(message):
    info_hash = message.get('info_hash', None)
    data = client.get().torrent_peers(info_hash)
    api.emit(api.EVENT_TORRENT_PEERS_RESPONSE, data=data)
예제 #26
0
파일: torrents.py 프로젝트: crawln45/tranny
def handle_event_update(message):
    events = client.get().get_events()
    api.emit(api.EVENT_UPDATE_RESPONSE)
예제 #27
0
def handle_peers(message):
    info_hash = message.get('info_hash', None)
    data = torrent_client.torrent_peers(info_hash)
    api.emit(events.EVENT_TORRENT_PEERS_RESPONSE, data=dict(peers=data))
예제 #28
0
파일: torrents.py 프로젝트: crawln45/tranny
def handle_recheck(message):
    info_hash = message.get('info_hash', [])
    resp = client.get().torrent_recheck(info_hash)
    api.emit(api.EVENT_TORRENT_RECHECK_RESPONSE, resp)
    api.flash("Rechecking..!")