def write(self, url='', data='', post='', file_name=None): logger = logging.getLogger(__name__) key = file_name if file_name else self.make_key(url, post) full_path = os.path.join(self.location, key) try: if not os.path.exists(full_path): common.put_file(full_path, data) except Exception as e: logger.exception(e)
def write(self, url='', data='', post='',filename = None): logger = logging.getLogger(__name__) key = filename if filename else self.make_key(url,post) full_path = os.path.join(self.location, key) try: if not os.path.exists(full_path): common.put_file(full_path, data) except Exception as e: logger.exception(e)
def set_default(log_file = 'log.txt', preserve=False): settings = default_settings.copy() if log_file: settings['handlers']['file_handler']['filename'] = log_file if not preserve: common.put_file(log_file,'') else: #just log to console settings['root']['handlers'] = ['console'] logging.config.dictConfig(settings) return logging.getLogger('scrapex')
def set_default(log_file='log.txt', preserve=False): settings = default_settings.copy() if log_file: settings['handlers']['file_handler']['filename'] = log_file if not preserve: common.put_file(log_file, '') else: #just log to console settings['root']['handlers'] = ['console'] logging.config.dictConfig(settings) return logging.getLogger('scrapex')
def put_file(self, filename, data): common.put_file(self.join_path(filename), data) return self