Esempio n. 1
0
 def _action(self, action, params=None, params_str=None):
     args = []
     if params:
         for k, v in params.items():
             if utorrent.is_list_type(v):
                 for i in v:
                     args.append(
                         "{}={}".format(utorrent._url_quote(str(k)), utorrent._url_quote(self._action_val(i)))
                     )
             else:
                 args.append("{}={}".format(utorrent._url_quote(str(k)), utorrent._url_quote(self._action_val(v))))
     if params_str:
         params_str = "&" + params_str
     else:
         params_str = ""
     if action == "list":
         args.insert(0, "token=" + self._token)
         args.insert(1, "list=1")
         section = "gui/"
     elif action == "proxy":
         section = "proxy"
     else:
         args.insert(0, "token=" + self._token)
         args.insert(1, "action=" + utorrent._url_quote(str(action)))
         section = "gui/"
     return section + "?" + "&".join(args) + params_str
Esempio n. 2
0
 def _action(self, action, params=None, params_str=None):
     args = []
     if params:
         for k, v in params.items():
             if utorrent.is_list_type(v):
                 for i in v:
                     args.append("{}={}".format(
                         utorrent._url_quote(str(k)),
                         utorrent._url_quote(self._action_val(i))))
             else:
                 args.append("{}={}".format(
                     utorrent._url_quote(str(k)),
                     utorrent._url_quote(self._action_val(v))))
     if params_str:
         params_str = "&" + params_str
     else:
         params_str = ""
     if action == "list":
         args.insert(0, "token=" + self._token)
         args.insert(1, "list=1")
         section = "gui/"
     elif action == "proxy":
         section = "proxy"
     else:
         args.insert(0, "token=" + self._token)
         args.insert(1, "action=" + utorrent._url_quote(str(action)))
         section = "gui/"
     return section + "?" + "&".join(args) + params_str
Esempio n. 3
0
	def _get_hashes( self, torrents ):
		if not utorrent.is_list_type( torrents ):
			torrents = ( torrents, )
		out = []
		for t in torrents:
			if isinstance( t, self._TorrentClass ):
				hsh = t.hash_code
			elif isinstance( t, str ):
				hsh = t
			else:
				raise utorrent.uTorrentError( "Hash designation only supported via Torrent class or string" )
			self.check_hash( hsh )
			out.append( hsh )
		return out
Esempio n. 4
0
 def _get_hashes(self, torrents):
     if not utorrent.is_list_type(torrents):
         torrents = (torrents, )
     out = []
     for t in torrents:
         if isinstance(t, self._TorrentClass):
             hsh = t.hash_code
         elif isinstance(t, str):
             hsh = t
         else:
             raise utorrent.uTorrentError(
                 "Hash designation only supported via Torrent class or string"
             )
         self.check_hash(hsh)
         out.append(hsh)
     return out
Esempio n. 5
0
def dump_writer( obj, props, level1 = level2, level2 = level3 ):
	for name in sorted( props ):
		print_console( level1 + name, end = "" )
		try:
			value = getattr( obj, name )
			if utorrent_module.is_list_type( value ):
				print_console( ":" )
				for item in value:
					if opts.verbose and hasattr( item, "verbose_str" ):
						item_str = item.verbose_str( )
					else:
						item_str = str( item )
					print_console( level2 + item_str )
			else:
				if hasattr( obj, name + "_h" ):
					print_console( " = {} ({})".format( value, getattr( obj, name + "_h" ) ) )
				else:
					print_console( " = {}".format( value ) )
		except AttributeError:
			print_console( )
Esempio n. 6
0
def dump_writer(obj, props, level1=level2, level2=level3):
    for name in sorted(props):
        print_console(level1 + name, end="")
        try:
            value = getattr(obj, name)
            if utorrent_module.is_list_type(value):
                print_console(":")
                for item in value:
                    if opts.verbose and hasattr(item, "verbose_str"):
                        item_str = item.verbose_str()
                    else:
                        item_str = str(item)
                    print_console(level2 + item_str)
            else:
                if hasattr(obj, name + "_h"):
                    print_console(" = {} ({})".format(
                        value, getattr(obj, name + "_h")))
                else:
                    print_console(" = {}".format(value))
        except AttributeError:
            print_console()