예제 #1
0
    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)
예제 #2
0
파일: cache.py 프로젝트: cungnv/scrapex
	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)
예제 #3
0
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')
예제 #4
0
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')
예제 #5
0
파일: core.py 프로젝트: igizm0/scrapex
 def put_file(self, filename, data):
     common.put_file(self.join_path(filename), data)
     return self
예제 #6
0
파일: core.py 프로젝트: cungnv/scrapex
	def put_file(self, filename, data):
		common.put_file(self.join_path(filename), data)	
		return self