def _try_services(self, method_name, *args, **kwargs):
crypto = ((args and args[<NUM_LIT:0>]) or kwargs['<STR_LIT>']).lower()<EOL>address = kwargs.get('<STR_LIT:address>', '<STR_LIT>').lower()<EOL>fiat = kwargs.get('<STR_LIT>', '<STR_LIT>').lower()<EOL>if not self.services:<EOL><INDENT>raise CurrencyNotSupported("<STR_LIT>" % (method_name, crypto))<EOL><DEDENT>if self.random_wait_seconds > <NUM_LIT:0>:<EOL><INDENT>pause_time = random.random() * self.random_wait_seconds<EOL>if self.verbose:<EOL><INDENT>print("<STR_LIT>" % pause_time)<EOL><DEDENT>time.sleep(pause_time)<EOL><DEDENT>for service in self.services:<EOL><INDENT>if service.supported_cryptos and (crypto not in service.supported_cryptos):<EOL><INDENT>if self.verbose:<EOL><INDENT>print("<STR_LIT>", "<STR_LIT>" % (crypto, service.__class__.__name__))<EOL><DEDENT>continue<EOL><DEDENT>try:<EOL><INDENT>if self.verbose: print("<STR_LIT>", service, crypto, "<STR_LIT>" % (address, fiat))<EOL>ret =  getattr(service, method_name)(*args, **kwargs)<EOL>self._successful_service = service<EOL>return ret<EOL><DEDENT>except (KeyError, IndexError, TypeError, ValueError,<EOL>requests.exceptions.Timeout, requests.exceptions.ConnectionError) as exc:<EOL><INDENT>if self.verbose: print("<STR_LIT>", service, exc.__class__.__name__, exc)<EOL>self._failed_services.append({<EOL>'<STR_LIT>': service,<EOL>'<STR_LIT:error>': "<STR_LIT>" % (exc.__class__.__name__, exc)<EOL>})<EOL><DEDENT>except NoService as exc:<EOL><INDENT>if self.verbose: print("<STR_LIT>", exc.__class__.__name__, exc)<EOL>self._failed_services.append({'<STR_LIT>': service, '<STR_LIT:error>': "<STR_LIT>" % str(exc)})<EOL><DEDENT>except NotImplementedError as exc:<EOL><INDENT>if self.verbose: print("<STR_LIT>", exc.__class__.__name__, exc)<EOL>self._failed_services.append({'<STR_LIT>': service, '<STR_LIT:error>': "<STR_LIT>"})<EOL><DEDENT><DEDENT>if not self._failed_services:<EOL><INDENT>raise NotImplementedError(<EOL>"<STR_LIT>" % (crypto, method_name)<EOL>)<EOL><DEDENT>if set(x['<STR_LIT:error>'] for x in self._failed_services) == set(['<STR_LIT>']) and method_name.endswith("<STR_LIT>"):<EOL><INDENT>raise RevertToPrivateMode("<STR_LIT>" % method_name)<EOL><DEDENT>failed_msg = '<STR_LIT:U+002CU+0020>'.join(<EOL>["<STR_LIT>".format(**x) for x in self._failed_services]<EOL>)<EOL>raise NoService(self.no_service_msg(*args, **kwargs) + "<STR_LIT>" + failed_msg)<EOL>
Try each service until one returns a response. This function only
catches the bare minimum of exceptions from the service class. We want
exceptions to be raised so the service classes can be debugged and
fixed quickly.