Пример #1
0
 def upload_limit(self, limit):
     """Upload limit in Kbps or None."""
     if isinstance(limit, int):
         self._fields['uploadLimited'] = Field(True, True)
         self._fields['uploadLimit'] = Field(limit, True)
         self._push()
     elif limit is None:
         self._fields['uploadLimited'] = Field(False, True)
         self._push()
     else:
         raise ValueError('Not a valid limit')
Пример #2
0
 def _update_fields(self, other):
     """
     Update the session data from a Transmission JSON-RPC arguments dictionary
     """
     if isinstance(other, dict):
         for key, value in other.items():
             self._fields[key.replace('-', '_')] = Field(value, False)
     elif isinstance(other, Session):
         for key in list(other._fields.keys()):
             self._fields[key] = Field(other._fields[key].value, False)
     else:
         raise ValueError('Cannot update with supplied data')
Пример #3
0
 def _set_upload_limit(self, limit):
     """
     Set the upload limit.
     Can be a number, 'session' or None.
     """
     if isinstance(limit, int):
         self._fields['uploadLimited'] = Field(True, True)
         self._fields['uploadLimit'] = Field(limit, True)
         self._push()
     elif limit is None:
         self._fields['uploadLimited'] = Field(False, True)
         self._push()
     else:
         raise ValueError("Not a valid limit")
Пример #4
0
 def _set_pex_enabled(self, enabled):
     """Enable/disable peer exchange."""
     if isinstance(enabled, bool):
         self._fields['pex_enabled'] = Field(enabled, True)
         self._push()
     else:
         raise TypeError("Not a valid type")
Пример #5
0
 def _set_priority(self, priority):
     """
     Set the priority as string.
     Can be one of 'low', 'normal', 'high'.
     """
     if isinstance(priority, str):
         self._fields['bandwidthPriority'] = Field(PRIORITY[priority], True)
         self._push()
Пример #6
0
 def _set_seed_ratio_mode(self, mode):
     """
     Set the seed ratio mode as string. Can be one of 'global', 'single' or 'unlimited'.
     """
     if isinstance(mode, str):
         self._fields['seedRatioMode'] = Field(RATIO_LIMIT[mode], True)
         self._push()
     else:
         raise ValueError("Not a valid limit")
Пример #7
0
 def _set_seed_ratio_limit(self, limit):
     """
     Set the seed ratio limit as float.
     """
     if isinstance(limit, (int, float)) and limit >= 0.0:
         self._fields['seedRatioLimit'] = Field(float(limit), True)
         self._push()
     else:
         raise ValueError("Not a valid limit")
Пример #8
0
 def _set_seed_idle_limit(self, limit):
     """
     Set the seed idle limit in minutes.
     """
     if isinstance(limit, int):
         self._fields['seedIdleLimit'] = Field(limit, True)
         self._push()
     else:
         raise ValueError("Not a valid limit")
Пример #9
0
 def _set_peer_limit(self, limit):
     """
     Set the peer limit.
     """
     if isinstance(limit, int):
         self._fields['peer_limit'] = Field(limit, True)
         self._push()
     else:
         raise ValueError("Not a valid limit")
Пример #10
0
 def _set_peer_port(self, port):
     """
     Set the peer port.
     """
     if isinstance(port, int):
         self._fields['peer_port'] = Field(port, True)
         self._push()
     else:
         raise ValueError("Not a valid limit")
Пример #11
0
 def seed_idle_mode(self, mode):
     """
     Set the seed ratio mode as string. Can be one of 'global', 'single' or 'unlimited'.
     """
     if isinstance(mode, str):
         self._fields['seedIdleMode'] = Field(IDLE_LIMIT[mode], True)
         self._push()
     else:
         raise ValueError('Not a valid limit')
Пример #12
0
 def _set_queue_position(self, position):
     """Set the queue position for this torrent."""
     if self._rpc_version() >= 14:
         if isinstance(position, int):
             self._fields['queuePosition'] = Field(position, True)
             self._push()
         else:
             raise ValueError("Not a valid position")
     else:
         pass
Пример #13
0
 def queue_position(self, position):
     """Queue position"""
     if self._rpc_version() >= 14:
         if isinstance(position, int):
             self._fields['queuePosition'] = Field(position, True)
             self._push()
         else:
             raise ValueError('Not a valid position')
     else:
         pass