Exemplo n.º 1
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 iteritems(other):
             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')
Exemplo n.º 2
0
 def _set_upload_limit(self, limit):
     """
     Set the upload limit.
     Can be a number, 'session' or None.
     """
     if isinstance(limit, integer_types):
         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")
Exemplo n.º 3
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")
Exemplo n.º 4
0
 def _set_priority(self, priority):
     """
     Set the priority as string.
     Can be one of 'low', 'normal', 'high'.
     """
     if isinstance(priority, string_types):
         self._fields['bandwidthPriority'] = Field(PRIORITY[priority], True)
         self._push()
Exemplo n.º 5
0
 def _set_peer_port(self, port):
     """
     Set the peer port.
     """
     if isinstance(port, integer_types):
         self._fields['peer_port'] = Field(port, True)
         self._push()
     else:
         raise ValueError("Not a valid limit")
Exemplo n.º 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")
Exemplo n.º 7
0
 def _set_seed_ratio_limit(self, limit):
     """
     Set the seed ratio limit as float.
     """
     if isinstance(limit, (integer_types, float)) and limit >= 0.0:
         self._fields['seedRatioLimit'] = Field(float(limit), True)
         self._push()
     else:
         raise ValueError("Not a valid limit")
Exemplo n.º 8
0
 def _set_seed_idle_limit(self, limit):
     """
     Set the seed idle limit in minutes.
     """
     if isinstance(limit, integer_types):
         self._fields['seedIdleLimit'] = Field(limit, True)
         self._push()
     else:
         raise ValueError("Not a valid limit")
Exemplo n.º 9
0
 def _set_queue_position(self, position):
     """Set the queue position for this torrent."""
     if self._rpc_version() >= 14:
         if isinstance(position, integer_types):
             self._fields['queuePosition'] = Field(position, True)
             self._push()
         else:
             raise ValueError("Not a valid position")
     else:
         pass