def __Tany(self, func, results, *args): if self.__append: results.append(func(*args)) else: results.extend(func(*args)) getLogger().debug("added to the results") return True
def anyThread(self, func, links, *args): results = [] while True: for x in range(self._threads): try: thread = WorkerThread(self.__Tany, func, results, links.pop(), *args) self.addThread(thread) except IndexError: getLogger().debug("threads for the pages are done") break self.isAllThreadsDone() if not len(links): break self.__cleanPool() return results
def wrapper(*args, **kwargs): for x in range(MAX_TRIES_REQUEST): try: resp = func(*args, **kwargs) except json.decoder.JSONDecodeError as e: getLogger().error("{}".format(e)) continue if not resp.get("validCaptcha"): if x > MAX_TRIES_REQUEST: raise ResponseException( "Ошибка капчи! {}".format(resp)) getLogger().error( "Invalid captcha encountered. Trying again... Current try: {}" .format(x)) continue elif resp.get("errorMessage"): if x > MAX_TRIES_REQUEST: raise CaptchaException( "Ошибка сервера! {}".format(resp)) getLogger().error( "Error message encountered. Trying again... Current try: {}" .format(x)) continue else: break return resp
import os, sys, re, platform import versions import internal as _internal _logger = _internal.getLogger(__name__) from pymel.util import path as _path sep = os.path.pathsep # A source command that will search for the Python script "file" in the specified path # (using the system path if none is provided) path and tries to call execfile() on it def source (file, searchPath=None, recurse=False) : """Looks for a python script in the specified path (uses system path if no path is specified) and executes it if it's found """ filepath = unicode(file) filename = os.path.basename(filepath) dirname = os.path.dirname(filepath) if searchPath is None : searchPath=sys.path if isinstance(searchPath, basestring ): searchPath = [searchPath] itpath = iter(searchPath) _logger.debug("looking for file as: "+filepath) while not os.path.exists(filepath) : try : p = os.path.abspath(os.path.realpath(itpath.next())) filepath = os.path.join(p, filename) _logger.debug('looking for file as: '+filepath) if recurse and not filepath.exists() : itsub = os.walk(p)
import os, sys, re, platform import versions import internal as _internal _logger = _internal.getLogger(__name__) from pymel.util import path as _path sep = os.path.pathsep # A source command that will search for the Python script "file" in the specified path # (using the system path if none is provided) path and tries to call execfile() on it def source(file, searchPath=None, recurse=False): """Looks for a python script in the specified path (uses system path if no path is specified) and executes it if it's found """ filepath = unicode(file) filename = os.path.basename(filepath) dirname = os.path.dirname(filepath) if searchPath is None: searchPath = sys.path if isinstance(searchPath, basestring): searchPath = [searchPath] itpath = iter(searchPath) _logger.debug("looking for file as: " + filepath) while not os.path.exists(filepath): try: p = os.path.abspath(os.path.realpath(itpath.next())) filepath = os.path.join(p, filename) _logger.debug('looking for file as: ' + filepath) if recurse and not filepath.exists(): itsub = os.walk(p)